Details
-
Bug
-
Resolution: Fixed
-
P2
-
None
-
b82
-
generic
-
generic
-
Not verified
Description
From: Bryan Castillo <castillo.bryan@gmail.com>
I just ran into an error using Nashorn today with slf4j. I don't see this
error with Rhino.
source:
----------------
package bcc;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
public class UseSlf4j {
public static void main(String[] args) throws Exception {
ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
engine.eval(
"var logger =
Packages.org.slf4j.LoggerFactory.getLogger('my_script');\n" +
"java.lang.System.out.println('Here is a logger: ' + logger);\n" +
"logger.info('From a script.');"
);
}
}
output:
-----------------
Here is a logger: org.slf4j.impl.Log4jLoggerAdapter(my_script)
Exception in thread "main" java.lang.IllegalAccessError: Failed to
unreflect method public java.lang.String
org.slf4j.helpers.NamedLoggerBase.getName()
at org.dynalang.dynalink.support.Lookup.unreflect(Lookup.java:61)
at
org.dynalang.dynalink.beans.FacetIntrospector.unreflect(FacetIntrospector.java:113)
at
org.dynalang.dynalink.beans.AbstractJavaLinker.<init>(AbstractJavaLinker.java:101)
at org.dynalang.dynalink.beans.BeanLinker.<init>(BeanLinker.java:44)
at
org.dynalang.dynalink.beans.BeansLinker$1.computeValue(BeansLinker.java:71)
at
org.dynalang.dynalink.beans.BeansLinker$1.computeValue(BeansLinker.java:67)
at java.lang.ClassValue.getFromHashMap(ClassValue.java:227)
at java.lang.ClassValue.getFromBackup(ClassValue.java:209)
at java.lang.ClassValue.get(ClassValue.java:115)
at
org.dynalang.dynalink.beans.BeansLinker.getLinkerForClass(BeansLinker.java:93)
at
org.dynalang.dynalink.beans.BeansLinker.getGuardedInvocation(BeansLinker.java:111)
at
org.dynalang.dynalink.support.CompositeGuardingDynamicLinker.getGuardedInvocation(CompositeGuardingDynamicLinker.java:58)
at
org.dynalang.dynalink.support.LinkerServicesImpl.getGuardedInvocation(LinkerServicesImpl.java:72)
at org.dynalang.dynalink.DynamicLinker.relink(DynamicLinker.java:163)
at jdk.nashorn.internal.scripts.Script$?003Ceval?003E.runScript(<eval>:3)
at
jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:359)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:310)
at
jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:438)
at
jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:423)
at
jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:150)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
at bcc.UseSlf4j.main(UseSlf4j.java:10)
Caused by: java.lang.IllegalAccessException: class is not public:
org.slf4j.helpers.NamedLoggerBase.getName()String/invokeVirtual, from
java.lang.Object/public
at java.lang.invoke.MemberName.makeAccessException(MemberName.java:732)
at
java.lang.invoke.MethodHandles$Lookup.checkAccess(MethodHandles.java:1135)
at
java.lang.invoke.MethodHandles$Lookup.checkMethod(MethodHandles.java:1098)
at
java.lang.invoke.MethodHandles$Lookup.getDirectMethodCommon(MethodHandles.java:1209)
at
java.lang.invoke.MethodHandles$Lookup.getDirectMethod(MethodHandles.java:1199)
at java.lang.invoke.MethodHandles$Lookup.unreflect(MethodHandles.java:914)
at org.dynalang.dynalink.support.Lookup.unreflect(Lookup.java:59)
... 21 more
jdk:
-----------------
C:\Users\bcastill>"c:\Program Files\Java\jdk1.8.0\bin\java" -version
java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b71)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b14, mixed mode)
Nashorn version:
------------------------------------------
bcastill@US-SEA-R9CMKD3 /cygdrive/c/bcastill/nashorn
$ hg log -l 1
changeset: 6:5a1b0714df0e
tag: tip
user: jlaskey
date: Fri Jan 04 09:58:33 2013 -0400
summary: 8005663: Update copyright year to 2013
Slf4j related jars:
----------------------------------
$ ls -l *slf4j*.jar log*.jar
----------+ 1 bcastill Domain Users 17308 Jan 5 21:59
jcl-over-slf4j-1.6.1.jar
----------+ 1 bcastill Domain Users 481534 Jan 5 22:00 log4j-1.2.16.jar
----------+ 1 bcastill Domain Users 25496 Jan 5 21:59 slf4j-api-1.6.1.jar
----------+ 1 bcastill Domain Users 9753 Jan 5 21:59
slf4j-log4j12-1.6.1.jar
I just ran into an error using Nashorn today with slf4j. I don't see this
error with Rhino.
source:
----------------
package bcc;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
public class UseSlf4j {
public static void main(String[] args) throws Exception {
ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
engine.eval(
"var logger =
Packages.org.slf4j.LoggerFactory.getLogger('my_script');\n" +
"java.lang.System.out.println('Here is a logger: ' + logger);\n" +
"logger.info('From a script.');"
);
}
}
output:
-----------------
Here is a logger: org.slf4j.impl.Log4jLoggerAdapter(my_script)
Exception in thread "main" java.lang.IllegalAccessError: Failed to
unreflect method public java.lang.String
org.slf4j.helpers.NamedLoggerBase.getName()
at org.dynalang.dynalink.support.Lookup.unreflect(Lookup.java:61)
at
org.dynalang.dynalink.beans.FacetIntrospector.unreflect(FacetIntrospector.java:113)
at
org.dynalang.dynalink.beans.AbstractJavaLinker.<init>(AbstractJavaLinker.java:101)
at org.dynalang.dynalink.beans.BeanLinker.<init>(BeanLinker.java:44)
at
org.dynalang.dynalink.beans.BeansLinker$1.computeValue(BeansLinker.java:71)
at
org.dynalang.dynalink.beans.BeansLinker$1.computeValue(BeansLinker.java:67)
at java.lang.ClassValue.getFromHashMap(ClassValue.java:227)
at java.lang.ClassValue.getFromBackup(ClassValue.java:209)
at java.lang.ClassValue.get(ClassValue.java:115)
at
org.dynalang.dynalink.beans.BeansLinker.getLinkerForClass(BeansLinker.java:93)
at
org.dynalang.dynalink.beans.BeansLinker.getGuardedInvocation(BeansLinker.java:111)
at
org.dynalang.dynalink.support.CompositeGuardingDynamicLinker.getGuardedInvocation(CompositeGuardingDynamicLinker.java:58)
at
org.dynalang.dynalink.support.LinkerServicesImpl.getGuardedInvocation(LinkerServicesImpl.java:72)
at org.dynalang.dynalink.DynamicLinker.relink(DynamicLinker.java:163)
at jdk.nashorn.internal.scripts.Script$?003Ceval?003E.runScript(<eval>:3)
at
jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:359)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:310)
at
jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:438)
at
jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:423)
at
jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:150)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
at bcc.UseSlf4j.main(UseSlf4j.java:10)
Caused by: java.lang.IllegalAccessException: class is not public:
org.slf4j.helpers.NamedLoggerBase.getName()String/invokeVirtual, from
java.lang.Object/public
at java.lang.invoke.MemberName.makeAccessException(MemberName.java:732)
at
java.lang.invoke.MethodHandles$Lookup.checkAccess(MethodHandles.java:1135)
at
java.lang.invoke.MethodHandles$Lookup.checkMethod(MethodHandles.java:1098)
at
java.lang.invoke.MethodHandles$Lookup.getDirectMethodCommon(MethodHandles.java:1209)
at
java.lang.invoke.MethodHandles$Lookup.getDirectMethod(MethodHandles.java:1199)
at java.lang.invoke.MethodHandles$Lookup.unreflect(MethodHandles.java:914)
at org.dynalang.dynalink.support.Lookup.unreflect(Lookup.java:59)
... 21 more
jdk:
-----------------
C:\Users\bcastill>"c:\Program Files\Java\jdk1.8.0\bin\java" -version
java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b71)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b14, mixed mode)
Nashorn version:
------------------------------------------
bcastill@US-SEA-R9CMKD3 /cygdrive/c/bcastill/nashorn
$ hg log -l 1
changeset: 6:5a1b0714df0e
tag: tip
user: jlaskey
date: Fri Jan 04 09:58:33 2013 -0400
summary: 8005663: Update copyright year to 2013
Slf4j related jars:
----------------------------------
$ ls -l *slf4j*.jar log*.jar
----------+ 1 bcastill Domain Users 17308 Jan 5 21:59
jcl-over-slf4j-1.6.1.jar
----------+ 1 bcastill Domain Users 481534 Jan 5 22:00 log4j-1.2.16.jar
----------+ 1 bcastill Domain Users 25496 Jan 5 21:59 slf4j-api-1.6.1.jar
----------+ 1 bcastill Domain Users 9753 Jan 5 21:59
slf4j-log4j12-1.6.1.jar