Re: RFR: JDK-8281006 Module::getResourceAsStream should check if the resource is open unconditionally when caller is null [v5]
On Wed, 20 Apr 2022 01:03:23 GMT, Tim Prinzing wrote: >> Created a test called NullCallerGetResource to test >> Module::getResourceAsStream and Class::getResourceAsStream from the native >> level. >> >> At the java level the test builds a test module called 'n' which opens the >> package 'open' to everyone. There is also a package 'closed' which is >> neither opened or exported. Both packages have a text file called >> 'test.txt'. The open package has a class called OpenResources and the closed >> package has a class called ClosedResources. The native test is launched with >> the test module n added. >> >> At the native level the test tries to read both the open and closed resource >> from both the classes and the module. It performs the equivalent of the >> following java operations: >> >> Class c = open.OpenResources.fetchClass(); >> InputStream in = c.getResourceAsStream("test.txt"); >> assert(in != null); in.close(); >> >> Module n = c.getModule(); >> in = n.getResourceAsStream("open/test.txt"); >> assert(in != null); in.close(); >> >> Class closed = closed.ClosedResources.fetchClass(); >> assert(closedsStream("test.txt") == null); >> assert(n.getResourceAsStream("closed/test.txt") == null); >> >> The test initially threw an NPE when trying to fetch the open resource. The >> Module class was fixed by removing the fragment with the (caller == null) >> test in getResourceAsStream, and changing the call to isOpen(String,Module) >> to use EVERYONE_MODULE if the caller module is null. > > Tim Prinzing has updated the pull request incrementally with one additional > commit since the last revision: > > some cleanup of the test Thanks for the test update. Looks good. - Marked as reviewed by mchung (Reviewer). PR: https://git.openjdk.java.net/jdk/pull/8134
Re: RFR: JDK-8281006 Module::getResourceAsStream should check if the resource is open unconditionally when caller is null [v5]
On Wed, 20 Apr 2022 01:03:23 GMT, Tim Prinzing wrote: >> Created a test called NullCallerGetResource to test >> Module::getResourceAsStream and Class::getResourceAsStream from the native >> level. >> >> At the java level the test builds a test module called 'n' which opens the >> package 'open' to everyone. There is also a package 'closed' which is >> neither opened or exported. Both packages have a text file called >> 'test.txt'. The open package has a class called OpenResources and the closed >> package has a class called ClosedResources. The native test is launched with >> the test module n added. >> >> At the native level the test tries to read both the open and closed resource >> from both the classes and the module. It performs the equivalent of the >> following java operations: >> >> Class c = open.OpenResources.fetchClass(); >> InputStream in = c.getResourceAsStream("test.txt"); >> assert(in != null); in.close(); >> >> Module n = c.getModule(); >> in = n.getResourceAsStream("open/test.txt"); >> assert(in != null); in.close(); >> >> Class closed = closed.ClosedResources.fetchClass(); >> assert(closedsStream("test.txt") == null); >> assert(n.getResourceAsStream("closed/test.txt") == null); >> >> The test initially threw an NPE when trying to fetch the open resource. The >> Module class was fixed by removing the fragment with the (caller == null) >> test in getResourceAsStream, and changing the call to isOpen(String,Module) >> to use EVERYONE_MODULE if the caller module is null. > > Tim Prinzing has updated the pull request incrementally with one additional > commit since the last revision: > > some cleanup of the test Marked as reviewed by alanb (Reviewer). - PR: https://git.openjdk.java.net/jdk/pull/8134
Re: RFR: JDK-8281006 Module::getResourceAsStream should check if the resource is open unconditionally when caller is null [v5]
> Created a test called NullCallerGetResource to test > Module::getResourceAsStream and Class::getResourceAsStream from the native > level. > > At the java level the test builds a test module called 'n' which opens the > package 'open' to everyone. There is also a package 'closed' which is neither > opened or exported. Both packages have a text file called 'test.txt'. The > open package has a class called OpenResources and the closed package has a > class called ClosedResources. The native test is launched with the test > module n added. > > At the native level the test tries to read both the open and closed resource > from both the classes and the module. It performs the equivalent of the > following java operations: > > Class c = open.OpenResources.fetchClass(); > InputStream in = c.getResourceAsStream("test.txt"); > assert(in != null); in.close(); > > Module n = c.getModule(); > in = n.getResourceAsStream("open/test.txt"); > assert(in != null); in.close(); > > Class closed = closed.ClosedResources.fetchClass(); > assert(closedsStream("test.txt") == null); > assert(n.getResourceAsStream("closed/test.txt") == null); > > The test initially threw an NPE when trying to fetch the open resource. The > Module class was fixed by removing the fragment with the (caller == null) > test in getResourceAsStream, and changing the call to isOpen(String,Module) > to use EVERYONE_MODULE if the caller module is null. Tim Prinzing has updated the pull request incrementally with one additional commit since the last revision: some cleanup of the test - Changes: - all: https://git.openjdk.java.net/jdk/pull/8134/files - new: https://git.openjdk.java.net/jdk/pull/8134/files/c5fef46b..15de2394 Webrevs: - full: https://webrevs.openjdk.java.net/?repo=jdk=8134=04 - incr: https://webrevs.openjdk.java.net/?repo=jdk=8134=03-04 Stats: 62 lines in 4 files changed: 21 ins; 27 del; 14 mod Patch: https://git.openjdk.java.net/jdk/pull/8134.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/8134/head:pull/8134 PR: https://git.openjdk.java.net/jdk/pull/8134
Re: RFR: JDK-8281006 Module::getResourceAsStream should check if the resource is open unconditionally when caller is null [v4]
On Mon, 11 Apr 2022 00:48:34 GMT, Tim Prinzing wrote: >> Created a test called NullCallerGetResource to test >> Module::getResourceAsStream and Class::getResourceAsStream from the native >> level. >> >> At the java level the test builds a test module called 'n' which opens the >> package 'open' to everyone. There is also a package 'closed' which is >> neither opened or exported. Both packages have a text file called >> 'test.txt'. The open package has a class called OpenResources and the closed >> package has a class called ClosedResources. The native test is launched with >> the test module n added. >> >> At the native level the test tries to read both the open and closed resource >> from both the classes and the module. It performs the equivalent of the >> following java operations: >> >> Class c = open.OpenResources.fetchClass(); >> InputStream in = c.getResourceAsStream("test.txt"); >> assert(in != null); in.close(); >> >> Module n = c.getModule(); >> in = n.getResourceAsStream("open/test.txt"); >> assert(in != null); in.close(); >> >> Class closed = closed.ClosedResources.fetchClass(); >> assert(closedsStream("test.txt") == null); >> assert(n.getResourceAsStream("closed/test.txt") == null); >> >> The test initially threw an NPE when trying to fetch the open resource. The >> Module class was fixed by removing the fragment with the (caller == null) >> test in getResourceAsStream, and changing the call to isOpen(String,Module) >> to use EVERYONE_MODULE if the caller module is null. > > Tim Prinzing has updated the pull request incrementally with one additional > commit since the last revision: > > requested changes Marked as reviewed by mchung (Reviewer). test/jdk/java/lang/module/exeNullCallerGetResource/exeNullCallerGetResource.c line 95: > 93: jclass class_OpenResources = (*env)->FindClass(env, > "open/OpenResources"); > 94: assert(class_OpenResources != NULL); > 95: jmethodID mid_OpenResources_fetchClass = > (*env)->GetStaticMethodID(env, class_OpenResources, "fetchClass", > "()Ljava/lang/Class;" ); It seems that invoking `fetchClass` isn't necessary since you can simply use `class_OpenResources`. Similarly for `class_ClosedResources` test/jdk/java/lang/module/exeNullCallerGetResource/exeNullCallerGetResource.c line 183: > 181: exit(-1); > 182: } > 183: assert(in == NULL); assert is typically used for sanity test. As part of the test validation, e.g. in this case `in == NULL` or `in != NULL` in line 157, it may be clearer if it's an explicit check and throw exception to indicate test failure especially in case `#undef NDEBUG` may not be set in the test. - PR: https://git.openjdk.java.net/jdk/pull/8134
Re: RFR: JDK-8281006 Module::getResourceAsStream should check if the resource is open unconditionally when caller is null [v4]
On Mon, 11 Apr 2022 00:48:34 GMT, Tim Prinzing wrote: >> Created a test called NullCallerGetResource to test >> Module::getResourceAsStream and Class::getResourceAsStream from the native >> level. >> >> At the java level the test builds a test module called 'n' which opens the >> package 'open' to everyone. There is also a package 'closed' which is >> neither opened or exported. Both packages have a text file called >> 'test.txt'. The open package has a class called OpenResources and the closed >> package has a class called ClosedResources. The native test is launched with >> the test module n added. >> >> At the native level the test tries to read both the open and closed resource >> from both the classes and the module. It performs the equivalent of the >> following java operations: >> >> Class c = open.OpenResources.fetchClass(); >> InputStream in = c.getResourceAsStream("test.txt"); >> assert(in != null); in.close(); >> >> Module n = c.getModule(); >> in = n.getResourceAsStream("open/test.txt"); >> assert(in != null); in.close(); >> >> Class closed = closed.ClosedResources.fetchClass(); >> assert(closedsStream("test.txt") == null); >> assert(n.getResourceAsStream("closed/test.txt") == null); >> >> The test initially threw an NPE when trying to fetch the open resource. The >> Module class was fixed by removing the fragment with the (caller == null) >> test in getResourceAsStream, and changing the call to isOpen(String,Module) >> to use EVERYONE_MODULE if the caller module is null. > > Tim Prinzing has updated the pull request incrementally with one additional > commit since the last revision: > > requested changes Thanks for the update, the src changes in c5fef46b look okay. - PR: https://git.openjdk.java.net/jdk/pull/8134
Re: RFR: JDK-8281006 Module::getResourceAsStream should check if the resource is open unconditionally when caller is null [v4]
> Created a test called NullCallerGetResource to test > Module::getResourceAsStream and Class::getResourceAsStream from the native > level. > > At the java level the test builds a test module called 'n' which opens the > package 'open' to everyone. There is also a package 'closed' which is neither > opened or exported. Both packages have a text file called 'test.txt'. The > open package has a class called OpenResources and the closed package has a > class called ClosedResources. The native test is launched with the test > module n added. > > At the native level the test tries to read both the open and closed resource > from both the classes and the module. It performs the equivalent of the > following java operations: > > Class c = open.OpenResources.fetchClass(); > InputStream in = c.getResourceAsStream("test.txt"); > assert(in != null); in.close(); > > Module n = c.getModule(); > in = n.getResourceAsStream("open/test.txt"); > assert(in != null); in.close(); > > Class closed = closed.ClosedResources.fetchClass(); > assert(closedsStream("test.txt") == null); > assert(n.getResourceAsStream("closed/test.txt") == null); > > The test initially threw an NPE when trying to fetch the open resource. The > Module class was fixed by removing the fragment with the (caller == null) > test in getResourceAsStream, and changing the call to isOpen(String,Module) > to use EVERYONE_MODULE if the caller module is null. Tim Prinzing has updated the pull request incrementally with one additional commit since the last revision: requested changes - Changes: - all: https://git.openjdk.java.net/jdk/pull/8134/files - new: https://git.openjdk.java.net/jdk/pull/8134/files/912896d7..c5fef46b Webrevs: - full: https://webrevs.openjdk.java.net/?repo=jdk=8134=03 - incr: https://webrevs.openjdk.java.net/?repo=jdk=8134=02-03 Stats: 2 lines in 2 files changed: 0 ins; 0 del; 2 mod Patch: https://git.openjdk.java.net/jdk/pull/8134.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/8134/head:pull/8134 PR: https://git.openjdk.java.net/jdk/pull/8134
Re: RFR: JDK-8281006 Module::getResourceAsStream should check if the resource is open unconditionally when caller is null [v3]
On Thu, 7 Apr 2022 21:08:34 GMT, Tim Prinzing wrote: >> Created a test called NullCallerGetResource to test >> Module::getResourceAsStream and Class::getResourceAsStream from the native >> level. >> >> At the java level the test builds a test module called 'n' which opens the >> package 'open' to everyone. There is also a package 'closed' which is >> neither opened or exported. Both packages have a text file called >> 'test.txt'. The open package has a class called OpenResources and the closed >> package has a class called ClosedResources. The native test is launched with >> the test module n added. >> >> At the native level the test tries to read both the open and closed resource >> from both the classes and the module. It performs the equivalent of the >> following java operations: >> >> Class c = open.OpenResources.fetchClass(); >> InputStream in = c.getResourceAsStream("test.txt"); >> assert(in != null); in.close(); >> >> Module n = c.getModule(); >> in = n.getResourceAsStream("open/test.txt"); >> assert(in != null); in.close(); >> >> Class closed = closed.ClosedResources.fetchClass(); >> assert(closedsStream("test.txt") == null); >> assert(n.getResourceAsStream("closed/test.txt") == null); >> >> The test initially threw an NPE when trying to fetch the open resource. The >> Module class was fixed by removing the fragment with the (caller == null) >> test in getResourceAsStream, and changing the call to isOpen(String,Module) >> to use EVERYONE_MODULE if the caller module is null. > > Tim Prinzing has updated the pull request incrementally with one additional > commit since the last revision: > > revert Module::isOpen The updated changes to Class and Module in 912896d7 look okay, just minor comments. src/java.base/share/classes/java/lang/Class.java line 3007: > 3005: if (callerModule == null) { > 3006: // no caller > 3007: return thisModule.isOpen(pn); It might be clear if the comment read "no caller, return true if the package is open to all modules". src/java.base/share/classes/java/lang/Module.java line 1658: > 1656: if (getPackages().contains(pn)) { > 1657: if (caller == null) { > 1658: if (! isOpen(pn)) { Minor nit, can you remove the space in "! isOpen". - PR: https://git.openjdk.java.net/jdk/pull/8134
Re: RFR: JDK-8281006 Module::getResourceAsStream should check if the resource is open unconditionally when caller is null [v3]
> Created a test called NullCallerGetResource to test > Module::getResourceAsStream and Class::getResourceAsStream from the native > level. > > At the java level the test builds a test module called 'n' which opens the > package 'open' to everyone. There is also a package 'closed' which is neither > opened or exported. Both packages have a text file called 'test.txt'. The > open package has a class called OpenResources and the closed package has a > class called ClosedResources. The native test is launched with the test > module n added. > > At the native level the test tries to read both the open and closed resource > from both the classes and the module. It performs the equivalent of the > following java operations: > > Class c = open.OpenResources.fetchClass(); > InputStream in = c.getResourceAsStream("test.txt"); > assert(in != null); in.close(); > > Module n = c.getModule(); > in = n.getResourceAsStream("open/test.txt"); > assert(in != null); in.close(); > > Class closed = closed.ClosedResources.fetchClass(); > assert(closedsStream("test.txt") == null); > assert(n.getResourceAsStream("closed/test.txt") == null); > > The test initially threw an NPE when trying to fetch the open resource. The > Module class was fixed by removing the fragment with the (caller == null) > test in getResourceAsStream, and changing the call to isOpen(String,Module) > to use EVERYONE_MODULE if the caller module is null. Tim Prinzing has updated the pull request incrementally with one additional commit since the last revision: revert Module::isOpen - Changes: - all: https://git.openjdk.java.net/jdk/pull/8134/files - new: https://git.openjdk.java.net/jdk/pull/8134/files/4b344e4d..912896d7 Webrevs: - full: https://webrevs.openjdk.java.net/?repo=jdk=8134=02 - incr: https://webrevs.openjdk.java.net/?repo=jdk=8134=01-02 Stats: 10 lines in 2 files changed: 5 ins; 0 del; 5 mod Patch: https://git.openjdk.java.net/jdk/pull/8134.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/8134/head:pull/8134 PR: https://git.openjdk.java.net/jdk/pull/8134
Re: RFR: JDK-8281006 Module::getResourceAsStream should check if the resource is open unconditionally when caller is null [v2]
On Thu, 7 Apr 2022 05:52:24 GMT, Alan Bateman wrote: > Tim - this creates a conflict between the spec and implementation, the > changes to the 2-arg isOpen method need to be dropped so that it continues to > throw NPE if module is null. okay - PR: https://git.openjdk.java.net/jdk/pull/8134
Re: RFR: JDK-8281006 Module::getResourceAsStream should check if the resource is open unconditionally when caller is null [v2]
On Thu, 7 Apr 2022 00:56:42 GMT, Tim Prinzing wrote: >> Created a test called NullCallerGetResource to test >> Module::getResourceAsStream and Class::getResourceAsStream from the native >> level. >> >> At the java level the test builds a test module called 'n' which opens the >> package 'open' to everyone. There is also a package 'closed' which is >> neither opened or exported. Both packages have a text file called >> 'test.txt'. The open package has a class called OpenResources and the closed >> package has a class called ClosedResources. The native test is launched with >> the test module n added. >> >> At the native level the test tries to read both the open and closed resource >> from both the classes and the module. It performs the equivalent of the >> following java operations: >> >> Class c = open.OpenResources.fetchClass(); >> InputStream in = c.getResourceAsStream("test.txt"); >> assert(in != null); in.close(); >> >> Module n = c.getModule(); >> in = n.getResourceAsStream("open/test.txt"); >> assert(in != null); in.close(); >> >> Class closed = closed.ClosedResources.fetchClass(); >> assert(closedsStream("test.txt") == null); >> assert(n.getResourceAsStream("closed/test.txt") == null); >> >> The test initially threw an NPE when trying to fetch the open resource. The >> Module class was fixed by removing the fragment with the (caller == null) >> test in getResourceAsStream, and changing the call to isOpen(String,Module) >> to use EVERYONE_MODULE if the caller module is null. > > Tim Prinzing has updated the pull request incrementally with one additional > commit since the last revision: > > update copyright date Build change looks good. - Marked as reviewed by erikj (Reviewer). PR: https://git.openjdk.java.net/jdk/pull/8134
Re: RFR: JDK-8281006 Module::getResourceAsStream should check if the resource is open unconditionally when caller is null [v2]
On Thu, 7 Apr 2022 00:56:42 GMT, Tim Prinzing wrote: >> Created a test called NullCallerGetResource to test >> Module::getResourceAsStream and Class::getResourceAsStream from the native >> level. >> >> At the java level the test builds a test module called 'n' which opens the >> package 'open' to everyone. There is also a package 'closed' which is >> neither opened or exported. Both packages have a text file called >> 'test.txt'. The open package has a class called OpenResources and the closed >> package has a class called ClosedResources. The native test is launched with >> the test module n added. >> >> At the native level the test tries to read both the open and closed resource >> from both the classes and the module. It performs the equivalent of the >> following java operations: >> >> Class c = open.OpenResources.fetchClass(); >> InputStream in = c.getResourceAsStream("test.txt"); >> assert(in != null); in.close(); >> >> Module n = c.getModule(); >> in = n.getResourceAsStream("open/test.txt"); >> assert(in != null); in.close(); >> >> Class closed = closed.ClosedResources.fetchClass(); >> assert(closedsStream("test.txt") == null); >> assert(n.getResourceAsStream("closed/test.txt") == null); >> >> The test initially threw an NPE when trying to fetch the open resource. The >> Module class was fixed by removing the fragment with the (caller == null) >> test in getResourceAsStream, and changing the call to isOpen(String,Module) >> to use EVERYONE_MODULE if the caller module is null. > > Tim Prinzing has updated the pull request incrementally with one additional > commit since the last revision: > > update copyright date Tim - this creates a conflict between the spec and implementation, the changes to the 2-arg isOpen method need to be dropped so that it continues to throw NPE if module is null. - Changes requested by alanb (Reviewer). PR: https://git.openjdk.java.net/jdk/pull/8134
Re: RFR: JDK-8281006 Module::getResourceAsStream should check if the resource is open unconditionally when caller is null [v2]
> Created a test called NullCallerGetResource to test > Module::getResourceAsStream and Class::getResourceAsStream from the native > level. > > At the java level the test builds a test module called 'n' which opens the > package 'open' to everyone. There is also a package 'closed' which is neither > opened or exported. Both packages have a text file called 'test.txt'. The > open package has a class called OpenResources and the closed package has a > class called ClosedResources. The native test is launched with the test > module n added. > > At the native level the test tries to read both the open and closed resource > from both the classes and the module. It performs the equivalent of the > following java operations: > > Class c = open.OpenResources.fetchClass(); > InputStream in = c.getResourceAsStream("test.txt"); > assert(in != null); in.close(); > > Module n = c.getModule(); > in = n.getResourceAsStream("open/test.txt"); > assert(in != null); in.close(); > > Class closed = closed.ClosedResources.fetchClass(); > assert(closedsStream("test.txt") == null); > assert(n.getResourceAsStream("closed/test.txt") == null); > > The test initially threw an NPE when trying to fetch the open resource. The > Module class was fixed by removing the fragment with the (caller == null) > test in getResourceAsStream, and changing the call to isOpen(String,Module) > to use EVERYONE_MODULE if the caller module is null. Tim Prinzing has updated the pull request incrementally with one additional commit since the last revision: update copyright date - Changes: - all: https://git.openjdk.java.net/jdk/pull/8134/files - new: https://git.openjdk.java.net/jdk/pull/8134/files/b702cae4..4b344e4d Webrevs: - full: https://webrevs.openjdk.java.net/?repo=jdk=8134=01 - incr: https://webrevs.openjdk.java.net/?repo=jdk=8134=00-01 Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod Patch: https://git.openjdk.java.net/jdk/pull/8134.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/8134/head:pull/8134 PR: https://git.openjdk.java.net/jdk/pull/8134
RFR: JDK-8281006 Module::getResourceAsStream should check if the resource is open unconditionally when caller is null
Created a test called NullCallerGetResource to test Module::getResourceAsStream and Class::getResourceAsStream from the native level. At the java level the test builds a test module called 'n' which opens the package 'open' to everyone. There is also a package 'closed' which is neither opened or exported. Both packages have a text file called 'test.txt'. The open package has a class called OpenResources and the closed package has a class called ClosedResources. The native test is launched with the test module n added. At the native level the test tries to read both the open and closed resource from both the classes and the module. It performs the equivalent of the following java operations: Class c = open.OpenResources.fetchClass(); InputStream in = c.getResourceAsStream("test.txt"); assert(in != null); in.close(); Module n = c.getModule(); in = n.getResourceAsStream("open/test.txt"); assert(in != null); in.close(); Class closed = closed.ClosedResources.fetchClass(); assert(closedsStream("test.txt") == null); assert(n.getResourceAsStream("closed/test.txt") == null); The test initially threw an NPE when trying to fetch the open resource. The Module class was fixed by removing the fragment with the (caller == null) test in getResourceAsStream, and changing the call to isOpen(String,Module) to use EVERYONE_MODULE if the caller module is null. - Commit messages: - JDK-8281006 Module::getResourceAsStream should check if the resource is open unconditionally when caller is null Changes: https://git.openjdk.java.net/jdk/pull/8134/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk=8134=00 Issue: https://bugs.openjdk.java.net/browse/JDK-8281006 Stats: 397 lines in 7 files changed: 391 ins; 5 del; 1 mod Patch: https://git.openjdk.java.net/jdk/pull/8134.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/8134/head:pull/8134 PR: https://git.openjdk.java.net/jdk/pull/8134