From yikesaroni at gmail.com Thu Feb 1 13:19:14 2018 From: yikesaroni at gmail.com (yikes aroni) Date: Thu, 1 Feb 2018 08:19:14 -0500 Subject: loading file twice locks the file Message-ID: I find that, when i load a javascript file in java *twice *using this pattern ScriptObjectMirror som = scriptEngine.eval("load('c:/temp/test.js');"); it locks the JS file (prevents its deletion). This does NOT happen if i load the file only once. Furthermore, this happens even if i null out the resulting ScriptObjectMirrors. My question is: how can I avoid this? I need to be able to load the file and get the resulting ScriptObjectMirror multiple times and be able to delete the source file. Is Nashorn not properly closing a stream? It's odd that it doesn't lock the file for the first SOM, but does for the second (and subsequent) SOMs.... Try it with this code. Instructions: 1) Create a file "test.js" and put it where you want. I put it in c:\temp\test.js (function(module) { var exports = module.exports; exports.test = function() { return "test ok"; } return module.exports;})({exports:{}, id:'test'}); 2) Create a Temp.java as follows and run it first with *loadSecondSom = true*. The deletion will fail. Then run it with *loadSecondSom = false*. The deletion will succeed. (Note: the "pause" is only to make it clearer...) import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import javax.script.ScriptEngine; import javax.script.ScriptException; import jdk.nashorn.api.scripting.NashornScriptEngineFactory; import jdk.nashorn.api.scripting.ScriptObjectMirror; public class Temp { private static final NashornScriptEngineFactory nashornFactory = new NashornScriptEngineFactory(); private static ScriptEngine scriptEngine = nashornFactory.getScriptEngine(); private static void deleteFile(String sPath) throws IOException { Path p = Paths.get(sPath); Files.delete(p); } private static void pause(int numsecs) { int x; try { for (int i=0;i References: Message-ID: <5A732E8B.3060306@oracle.com> Will you please file a bug with test case attached? Thanks, -Sundar On 01/02/18, 6:49 PM, yikes aroni wrote: > I find that, when i load a javascript file in java *twice *using this > pattern > > ScriptObjectMirror som = scriptEngine.eval("load('c:/temp/test.js');"); > > > it locks the JS file (prevents its deletion). This does NOT happen if i > load the file only once. Furthermore, this happens even if i null out the > resulting ScriptObjectMirrors. My question is: how can I avoid this? I need > to be able to load the file and get the resulting ScriptObjectMirror > multiple times and be able to delete the source file. > > Is Nashorn not properly closing a stream? It's odd that it doesn't lock > the file for the first SOM, but does for the second (and subsequent) > SOMs.... > > Try it with this code. Instructions: > > 1) Create a file "test.js" and put it where you want. I put it in > c:\temp\test.js > > (function(module) { > var exports = module.exports; > exports.test = function() { > return "test ok"; > } > return module.exports;})({exports:{}, id:'test'}); > > > 2) Create a Temp.java as follows and run it first with *loadSecondSom = > true*. The deletion will fail. Then run it with *loadSecondSom = false*. > The deletion will succeed. (Note: the "pause" is only to make it clearer...) > > import java.io.IOException; > import java.nio.file.Files; > import java.nio.file.Path; > import java.nio.file.Paths; > > import javax.script.ScriptEngine; > import javax.script.ScriptException; > > import jdk.nashorn.api.scripting.NashornScriptEngineFactory; > import jdk.nashorn.api.scripting.ScriptObjectMirror; > > public class Temp { > private static final NashornScriptEngineFactory nashornFactory = new > NashornScriptEngineFactory(); > private static ScriptEngine scriptEngine = nashornFactory.getScriptEngine(); > > private static void deleteFile(String sPath) throws IOException { > Path p = Paths.get(sPath); > Files.delete(p); > } > private static void pause(int numsecs) { > int x; > try { > for (int i=0;i Thread.sleep(1000); > x = i; > } > } catch (InterruptedException e) { > e.printStackTrace(); > } > } > > public static void main(String[] ss) { > boolean loadSecondSom = true; > String sPath = "C:/temp/test.js"; > try { > System.out.println("loading and calling som1..."); > ScriptObjectMirror som1 = (ScriptObjectMirror)scriptEngine.eval("load('" + > sPath + "');"); > System.out.println(som1.callMember("test")); > System.out.println("Sleeping ... "); > pause(2); > if (loadSecondSom) { > System.out.println("loading and calling som2..."); > ScriptObjectMirror som2 = (ScriptObjectMirror)scriptEngine.eval("load('" + > sPath + "');"); > System.out.println(som2.callMember("test")); > } > > System.out.println("Sleeping ... "); > pause(2); > > System.out.println("Attempting to delete the file from the fs..."); > try { > deleteFile(sPath); > } catch (IOException e) { > System.out.println("Cannot delete the file: "+e); > } > > System.out.println("DONE"); > } catch (ScriptException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > } > } From yikesaroni at gmail.com Fri Feb 2 15:55:51 2018 From: yikesaroni at gmail.com (yikes aroni) Date: Fri, 2 Feb 2018 10:55:51 -0500 Subject: loading file twice locks the file Message-ID: done. internal review ID : 9052500 thanks On Fri, Feb 2, 2018 at 7:00 AM, wrote: > Send nashorn-dev mailing list submissions to > nashorn-dev at openjdk.java.net > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.openjdk.java.net/mailman/listinfo/nashorn-dev > or, via email, send a message with subject or body 'help' to > nashorn-dev-request at openjdk.java.net > > You can reach the person managing the list at > nashorn-dev-owner at openjdk.java.net > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of nashorn-dev digest..." > > > Today's Topics: > > 1. loading file twice locks the file (yikes aroni) > 2. Re: loading file twice locks the file > (Sundararajan Athijegannathan) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Thu, 1 Feb 2018 08:19:14 -0500 > From: yikes aroni > To: nashorn-dev at openjdk.java.net > Subject: loading file twice locks the file > Message-ID: > gmail.com> > Content-Type: text/plain; charset="UTF-8" > > I find that, when i load a javascript file in java *twice *using this > pattern > > ScriptObjectMirror som = scriptEngine.eval("load('c:/temp/test.js');"); > > > it locks the JS file (prevents its deletion). This does NOT happen if i > load the file only once. Furthermore, this happens even if i null out the > resulting ScriptObjectMirrors. My question is: how can I avoid this? I need > to be able to load the file and get the resulting ScriptObjectMirror > multiple times and be able to delete the source file. > > Is Nashorn not properly closing a stream? It's odd that it doesn't lock > the file for the first SOM, but does for the second (and subsequent) > SOMs.... > > Try it with this code. Instructions: > > 1) Create a file "test.js" and put it where you want. I put it in > c:\temp\test.js > > (function(module) { > var exports = module.exports; > exports.test = function() { > return "test ok"; > } > return module.exports;})({exports:{}, id:'test'}); > > > 2) Create a Temp.java as follows and run it first with *loadSecondSom = > true*. The deletion will fail. Then run it with *loadSecondSom = false*. > The deletion will succeed. (Note: the "pause" is only to make it > clearer...) > > import java.io.IOException; > import java.nio.file.Files; > import java.nio.file.Path; > import java.nio.file.Paths; > > import javax.script.ScriptEngine; > import javax.script.ScriptException; > > import jdk.nashorn.api.scripting.NashornScriptEngineFactory; > import jdk.nashorn.api.scripting.ScriptObjectMirror; > > public class Temp { > private static final NashornScriptEngineFactory nashornFactory = new > NashornScriptEngineFactory(); > private static ScriptEngine scriptEngine = nashornFactory. > getScriptEngine(); > > private static void deleteFile(String sPath) throws IOException { > Path p = Paths.get(sPath); > Files.delete(p); > } > private static void pause(int numsecs) { > int x; > try { > for (int i=0;i Thread.sleep(1000); > x = i; > } > } catch (InterruptedException e) { > e.printStackTrace(); > } > } > > public static void main(String[] ss) { > boolean loadSecondSom = true; > String sPath = "C:/temp/test.js"; > try { > System.out.println("loading and calling som1..."); > ScriptObjectMirror som1 = (ScriptObjectMirror)scriptEngine.eval("load('" + > sPath + "');"); > System.out.println(som1.callMember("test")); > System.out.println("Sleeping ... "); > pause(2); > if (loadSecondSom) { > System.out.println("loading and calling som2..."); > ScriptObjectMirror som2 = (ScriptObjectMirror)scriptEngine.eval("load('" + > sPath + "');"); > System.out.println(som2.callMember("test")); > } > > System.out.println("Sleeping ... "); > pause(2); > > System.out.println("Attempting to delete the file from the fs..."); > try { > deleteFile(sPath); > } catch (IOException e) { > System.out.println("Cannot delete the file: "+e); > } > > System.out.println("DONE"); > } catch (ScriptException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > } > } > > > ------------------------------ > > Message: 2 > Date: Thu, 01 Feb 2018 20:43:15 +0530 > From: Sundararajan Athijegannathan > > To: nashorn-dev at openjdk.java.net > Subject: Re: loading file twice locks the file > Message-ID: <5A732E8B.3060306 at oracle.com> > Content-Type: text/plain; charset=UTF-8; format=flowed > > Will you please file a bug with test case attached? > > Thanks, > -Sundar > > On 01/02/18, 6:49 PM, yikes aroni wrote: > > I find that, when i load a javascript file in java *twice *using this > > pattern > > > > ScriptObjectMirror som = scriptEngine.eval("load('c:/temp/test.js');"); > > > > > > it locks the JS file (prevents its deletion). This does NOT happen if i > > load the file only once. Furthermore, this happens even if i null out the > > resulting ScriptObjectMirrors. My question is: how can I avoid this? I > need > > to be able to load the file and get the resulting ScriptObjectMirror > > multiple times and be able to delete the source file. > > > > Is Nashorn not properly closing a stream? It's odd that it doesn't lock > > the file for the first SOM, but does for the second (and subsequent) > > SOMs.... > > > > Try it with this code. Instructions: > > > > 1) Create a file "test.js" and put it where you want. I put it in > > c:\temp\test.js > > > > (function(module) { > > var exports = module.exports; > > exports.test = function() { > > return "test ok"; > > } > > return module.exports;})({exports:{}, id:'test'}); > > > > > > 2) Create a Temp.java as follows and run it first with *loadSecondSom = > > true*. The deletion will fail. Then run it with *loadSecondSom = false*. > > The deletion will succeed. (Note: the "pause" is only to make it > clearer...) > > > > import java.io.IOException; > > import java.nio.file.Files; > > import java.nio.file.Path; > > import java.nio.file.Paths; > > > > import javax.script.ScriptEngine; > > import javax.script.ScriptException; > > > > import jdk.nashorn.api.scripting.NashornScriptEngineFactory; > > import jdk.nashorn.api.scripting.ScriptObjectMirror; > > > > public class Temp { > > private static final NashornScriptEngineFactory nashornFactory = new > > NashornScriptEngineFactory(); > > private static ScriptEngine scriptEngine = nashornFactory. > getScriptEngine(); > > > > private static void deleteFile(String sPath) throws IOException { > > Path p = Paths.get(sPath); > > Files.delete(p); > > } > > private static void pause(int numsecs) { > > int x; > > try { > > for (int i=0;i > Thread.sleep(1000); > > x = i; > > } > > } catch (InterruptedException e) { > > e.printStackTrace(); > > } > > } > > > > public static void main(String[] ss) { > > boolean loadSecondSom = true; > > String sPath = "C:/temp/test.js"; > > try { > > System.out.println("loading and calling som1..."); > > ScriptObjectMirror som1 = (ScriptObjectMirror)scriptEngine.eval("load('" > + > > sPath + "');"); > > System.out.println(som1.callMember("test")); > > System.out.println("Sleeping ... "); > > pause(2); > > if (loadSecondSom) { > > System.out.println("loading and calling som2..."); > > ScriptObjectMirror som2 = (ScriptObjectMirror)scriptEngine.eval("load('" > + > > sPath + "');"); > > System.out.println(som2.callMember("test")); > > } > > > > System.out.println("Sleeping ... "); > > pause(2); > > > > System.out.println("Attempting to delete the file from the fs..."); > > try { > > deleteFile(sPath); > > } catch (IOException e) { > > System.out.println("Cannot delete the file: "+e); > > } > > > > System.out.println("DONE"); > > } catch (ScriptException e) { > > // TODO Auto-generated catch block > > e.printStackTrace(); > > } > > } > > } > > > End of nashorn-dev Digest, Vol 63, Issue 1 > ****************************************** > From yikesaroni at gmail.com Fri Feb 2 15:58:09 2018 From: yikesaroni at gmail.com (yikes aroni) Date: Fri, 2 Feb 2018 10:58:09 -0500 Subject: loading file twice locks the file Message-ID: done. internal review ID : 9052500 thanks On Fri, Feb 2, 2018 at 7:00 AM, wrote: > Send nashorn-dev mailing list submissions to > nashorn-dev at openjdk.java.net > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.openjdk.java.net/mailman/listinfo/nashorn-dev > or, via email, send a message with subject or body 'help' to > nashorn-dev-request at openjdk.java.net > > You can reach the person managing the list at > nashorn-dev-owner at openjdk.java.net > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of nashorn-dev digest..." > > > Today's Topics: > > 1. loading file twice locks the file (yikes aroni) > 2. Re: loading file twice locks the file > (Sundararajan Athijegannathan) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Thu, 1 Feb 2018 08:19:14 -0500 > From: yikes aroni > To: nashorn-dev at openjdk.java.net > Subject: loading file twice locks the file > Message-ID: > gmail.com> > Content-Type: text/plain; charset="UTF-8" > > I find that, when i load a javascript file in java *twice *using this > pattern > > ScriptObjectMirror som = scriptEngine.eval("load('c:/temp/test.js');"); > > > it locks the JS file (prevents its deletion). This does NOT happen if i > load the file only once. Furthermore, this happens even if i null out the > resulting ScriptObjectMirrors. My question is: how can I avoid this? I need > to be able to load the file and get the resulting ScriptObjectMirror > multiple times and be able to delete the source file. > > Is Nashorn not properly closing a stream? It's odd that it doesn't lock > the file for the first SOM, but does for the second (and subsequent) > SOMs.... > > Try it with this code. Instructions: > > 1) Create a file "test.js" and put it where you want. I put it in > c:\temp\test.js > > (function(module) { > var exports = module.exports; > exports.test = function() { > return "test ok"; > } > return module.exports;})({exports:{}, id:'test'}); > > > 2) Create a Temp.java as follows and run it first with *loadSecondSom = > true*. The deletion will fail. Then run it with *loadSecondSom = false*. > The deletion will succeed. (Note: the "pause" is only to make it > clearer...) > > import java.io.IOException; > import java.nio.file.Files; > import java.nio.file.Path; > import java.nio.file.Paths; > > import javax.script.ScriptEngine; > import javax.script.ScriptException; > > import jdk.nashorn.api.scripting.NashornScriptEngineFactory; > import jdk.nashorn.api.scripting.ScriptObjectMirror; > > public class Temp { > private static final NashornScriptEngineFactory nashornFactory = new > NashornScriptEngineFactory(); > private static ScriptEngine scriptEngine = nashornFactory. > getScriptEngine(); > > private static void deleteFile(String sPath) throws IOException { > Path p = Paths.get(sPath); > Files.delete(p); > } > private static void pause(int numsecs) { > int x; > try { > for (int i=0;i Thread.sleep(1000); > x = i; > } > } catch (InterruptedException e) { > e.printStackTrace(); > } > } > > public static void main(String[] ss) { > boolean loadSecondSom = true; > String sPath = "C:/temp/test.js"; > try { > System.out.println("loading and calling som1..."); > ScriptObjectMirror som1 = (ScriptObjectMirror)scriptEngine.eval("load('" + > sPath + "');"); > System.out.println(som1.callMember("test")); > System.out.println("Sleeping ... "); > pause(2); > if (loadSecondSom) { > System.out.println("loading and calling som2..."); > ScriptObjectMirror som2 = (ScriptObjectMirror)scriptEngine.eval("load('" + > sPath + "');"); > System.out.println(som2.callMember("test")); > } > > System.out.println("Sleeping ... "); > pause(2); > > System.out.println("Attempting to delete the file from the fs..."); > try { > deleteFile(sPath); > } catch (IOException e) { > System.out.println("Cannot delete the file: "+e); > } > > System.out.println("DONE"); > } catch (ScriptException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > } > } > > > ------------------------------ > > Message: 2 > Date: Thu, 01 Feb 2018 20:43:15 +0530 > From: Sundararajan Athijegannathan > > To: nashorn-dev at openjdk.java.net > Subject: Re: loading file twice locks the file > Message-ID: <5A732E8B.3060306 at oracle.com> > Content-Type: text/plain; charset=UTF-8; format=flowed > > Will you please file a bug with test case attached? > > Thanks, > -Sundar > > On 01/02/18, 6:49 PM, yikes aroni wrote: > > I find that, when i load a javascript file in java *twice *using this > > pattern > > > > ScriptObjectMirror som = scriptEngine.eval("load('c:/temp/test.js');"); > > > > > > it locks the JS file (prevents its deletion). This does NOT happen if i > > load the file only once. Furthermore, this happens even if i null out the > > resulting ScriptObjectMirrors. My question is: how can I avoid this? I > need > > to be able to load the file and get the resulting ScriptObjectMirror > > multiple times and be able to delete the source file. > > > > Is Nashorn not properly closing a stream? It's odd that it doesn't lock > > the file for the first SOM, but does for the second (and subsequent) > > SOMs.... > > > > Try it with this code. Instructions: > > > > 1) Create a file "test.js" and put it where you want. I put it in > > c:\temp\test.js > > > > (function(module) { > > var exports = module.exports; > > exports.test = function() { > > return "test ok"; > > } > > return module.exports;})({exports:{}, id:'test'}); > > > > > > 2) Create a Temp.java as follows and run it first with *loadSecondSom = > > true*. The deletion will fail. Then run it with *loadSecondSom = false*. > > The deletion will succeed. (Note: the "pause" is only to make it > clearer...) > > > > import java.io.IOException; > > import java.nio.file.Files; > > import java.nio.file.Path; > > import java.nio.file.Paths; > > > > import javax.script.ScriptEngine; > > import javax.script.ScriptException; > > > > import jdk.nashorn.api.scripting.NashornScriptEngineFactory; > > import jdk.nashorn.api.scripting.ScriptObjectMirror; > > > > public class Temp { > > private static final NashornScriptEngineFactory nashornFactory = new > > NashornScriptEngineFactory(); > > private static ScriptEngine scriptEngine = nashornFactory. > getScriptEngine(); > > > > private static void deleteFile(String sPath) throws IOException { > > Path p = Paths.get(sPath); > > Files.delete(p); > > } > > private static void pause(int numsecs) { > > int x; > > try { > > for (int i=0;i > Thread.sleep(1000); > > x = i; > > } > > } catch (InterruptedException e) { > > e.printStackTrace(); > > } > > } > > > > public static void main(String[] ss) { > > boolean loadSecondSom = true; > > String sPath = "C:/temp/test.js"; > > try { > > System.out.println("loading and calling som1..."); > > ScriptObjectMirror som1 = (ScriptObjectMirror)scriptEngine.eval("load('" > + > > sPath + "');"); > > System.out.println(som1.callMember("test")); > > System.out.println("Sleeping ... "); > > pause(2); > > if (loadSecondSom) { > > System.out.println("loading and calling som2..."); > > ScriptObjectMirror som2 = (ScriptObjectMirror)scriptEngine.eval("load('" > + > > sPath + "');"); > > System.out.println(som2.callMember("test")); > > } > > > > System.out.println("Sleeping ... "); > > pause(2); > > > > System.out.println("Attempting to delete the file from the fs..."); > > try { > > deleteFile(sPath); > > } catch (IOException e) { > > System.out.println("Cannot delete the file: "+e); > > } > > > > System.out.println("DONE"); > > } catch (ScriptException e) { > > // TODO Auto-generated catch block > > e.printStackTrace(); > > } > > } > > } > > > End of nashorn-dev Digest, Vol 63, Issue 1 > ****************************************** > From james.laskey at oracle.com Wed Feb 14 13:37:20 2018 From: james.laskey at oracle.com (Jim Laskey) Date: Wed, 14 Feb 2018 09:37:20 -0400 Subject: RFR: 8196959: NullPointerException in discovery003.java In-Reply-To: References: Message-ID: <729FEE70-BC0C-4015-837F-C31E0C93FF2A@oracle.com> +1 > On Feb 14, 2018, at 1:24 AM, Srinivas Dama wrote: > > Jim, > > May I have second review for this thread in core-libs-dev group. > > Regards, > Srinivas > > ----- Forwarded Message ----- > From: sundararajan.athijegannathan at oracle.com > To: srinivas.dama at oracle.com > Cc: core-libs-dev at openjdk.java.net > Sent: Monday, February 12, 2018 6:25:08 PM GMT +05:30 Chennai, Kolkata, Mumbai, New Delhi > Subject: Re: RFR: 8196959: NullPointerException in discovery003.java > > Looks good. > > -Sundar > > On 12/02/18, 5:31 PM, Srinivas Dama wrote: >> Hi, >> >> Please review http://cr.openjdk.java.net/~sdama/8196959/webrev.00/ >> for https://bugs.openjdk.java.net/browse/JDK-8196959 >> >> This is small modification of fix for https://bugs.openjdk.java.net/browse/JDK-8011697. >> Fix is to handle the corner case where the engineName is null. >> >> >> Regards, >> Srinivas From pmartins at redhat.com Fri Feb 16 12:19:00 2018 From: pmartins at redhat.com (Paulo Lopes) Date: Fri, 16 Feb 2018 13:19:00 +0100 Subject: ES6 after JDK9 Message-ID: <1518783540.9990.14.camel@redhat.com> Hi all, I've generated the kangax "compat-tables" for nashorn 1.8 and nashorn 9 (JDK1.8 and JDK9) respectively: https://www.jetdrone.xyz/assets/compat-table/es6/ The current script is waiting a PR review to be merged on the official project: https://github.com/kangax/compat-table/pull/1261 I've been using Nashorn to get JavaScript support on Eclipse Vert.x and while I've rerun the script to generate the report for JDK10 but there seems to be no changes from JDK9. Now with the announcement of Project Detroit: http://mail.openjdk.java.net/pipermail/announce/2018-January/000243.htm l What does this mean for Nashorn? Will the development stall and all focus will go to the new project? are there any plans to add more ES6 features e.g.: "class" support as many of the missing features can be added with polyfills e.g.: Promise, missing API, etc... Cheers, Paulo From natedogith1 at gmail.com Fri Feb 23 01:39:47 2018 From: natedogith1 at gmail.com (Nathan Faulkner) Date: Thu, 22 Feb 2018 20:39:47 -0500 Subject: defineClass doesn't exist on extended ClassLoader Message-ID: When extending java.lang.ClassLoader, I can't seem to execute defineClass. Here's my test case showing the issue. var superLoader = Java.super(new (Java.extend(java.lang.ClassLoader))(){}); // defineClass on the super object doesn't exist for some reason print("defineClass: " + (superLoader.defineClass !== undefined)); // definePackage is protected, but isn't undefined, so that isn't the issue print("definePackage: " + (superLoader.definePackage !== undefined)); and here's the output of "java -version": java version "1.8.0_161" Java(TM) SE Runtime Environment (build 1.8.0_161-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode) From sundararajan.athijegannathan at oracle.com Fri Feb 23 02:53:16 2018 From: sundararajan.athijegannathan at oracle.com (Sundararajan Athijegannathan) Date: Fri, 23 Feb 2018 08:23:16 +0530 Subject: defineClass doesn't exist on extended ClassLoader In-Reply-To: References: Message-ID: <5A8F821C.9090204@oracle.com> Hi, Two things: * Nashorn allows access only to public methods and fields (of exported) classes only. * With Java.extend, Nashorn adds public overrides of all non-final protected methods of the superclass. ClassLoader.definePackage is non-final protected method. ClassLoader.defineClass is final protected method. Hence no override of ClassLoader.defineClass added to generated subclass. -Sundar On 23/02/18, 7:09 AM, Nathan Faulkner wrote: > When extending java.lang.ClassLoader, I can't seem to execute defineClass. > Here's my test case showing the issue. > > var superLoader = Java.super(new (Java.extend(java.lang.ClassLoader))(){}); > // defineClass on the super object doesn't exist for some reason > print("defineClass: " + (superLoader.defineClass !== undefined)); > // definePackage is protected, but isn't undefined, so that isn't the issue > print("definePackage: " + (superLoader.definePackage !== undefined)); > > > and here's the output of "java -version": > java version "1.8.0_161" > Java(TM) SE Runtime Environment (build 1.8.0_161-b12) > Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode) From natedogith1 at gmail.com Fri Feb 23 21:49:23 2018 From: natedogith1 at gmail.com (Nathan Faulkner) Date: Fri, 23 Feb 2018 16:49:23 -0500 Subject: defineClass doesn't exist on extended ClassLoader In-Reply-To: <5A8F821C.9090204@oracle.com> References: <5A8F821C.9090204@oracle.com> Message-ID: Ah, so that's the difference (javadocs don't included "final" in method summaries so I didn't notice). Guess this means I get to make an enhancement request. On Thu, Feb 22, 2018 at 9:53 PM, Sundararajan Athijegannathan < sundararajan.athijegannathan at oracle.com> wrote: > Hi, > > Two things: > > * Nashorn allows access only to public methods and fields (of exported) > classes only. > > * With Java.extend, Nashorn adds public overrides of all non-final > protected methods of the superclass. > ClassLoader.definePackage is non-final protected method. > ClassLoader.defineClass is final protected method. > Hence no override of ClassLoader.defineClass added to generated subclass. > > -Sundar > > > On 23/02/18, 7:09 AM, Nathan Faulkner wrote: > >> When extending java.lang.ClassLoader, I can't seem to execute defineClass. >> Here's my test case showing the issue. >> >> var superLoader = Java.super(new (Java.extend(java.lang.ClassLo >> ader))(){}); >> // defineClass on the super object doesn't exist for some reason >> print("defineClass: " + (superLoader.defineClass !== undefined)); >> // definePackage is protected, but isn't undefined, so that isn't the >> issue >> print("definePackage: " + (superLoader.definePackage !== undefined)); >> >> >> and here's the output of "java -version": >> java version "1.8.0_161" >> Java(TM) SE Runtime Environment (build 1.8.0_161-b12) >> Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode) >> >