Review request for JDK-8014953

Attila Szegedi attila.szegedi at oracle.com
Tue May 21 04:14:42 PDT 2013


It'd be simpler, but I like that we're throwing an exception consistent with Java platform. Also, we get shorter stack traces - none of the linker plumbing stack traces are visible.

Namely:

Caused by: java.lang.ClassNotFoundException: java.util.ArrrayList
	at jdk.nashorn.internal.runtime.NativeJavaPackage.classNotFound(NativeJavaPackage.java:157)
	at jdk.nashorn.internal.scripts.Script$x.runScript(x.js:1)

vs.

Exception in thread "main" java.lang.RuntimeException: java.lang.ClassNotFoundException: java.util.ArrrayList
	at jdk.nashorn.internal.runtime.NativeJavaPackage.createClassNotFoundInvocation(NativeJavaPackage.java:146)
	at jdk.nashorn.internal.runtime.NativeJavaPackage.findNewMethod(NativeJavaPackage.java:137)
	at jdk.nashorn.internal.runtime.ScriptObject.lookup(ScriptObject.java:1614)
	at jdk.nashorn.internal.runtime.linker.NashornLinker.getGuardedInvocation(NashornLinker.java:75)
	at jdk.internal.dynalink.support.CompositeTypeBasedGuardingDynamicLinker.getGuardedInvocation(CompositeTypeBasedGuardingDynamicLinker.java:176)
	at jdk.internal.dynalink.support.CompositeGuardingDynamicLinker.getGuardedInvocation(CompositeGuardingDynamicLinker.java:124)
	at jdk.internal.dynalink.support.LinkerServicesImpl.getGuardedInvocation(LinkerServicesImpl.java:138)
	at jdk.internal.dynalink.DynamicLinker.relink(DynamicLinker.java:229)
	at jdk.nashorn.internal.scripts.Script$x.runScript(x.js:1)

On May 21, 2013, at 12:46 PM, Hannes Wallnoefer <hannes.wallnoefer at oracle.com> wrote:

> This looks correct, but I wouldn't it be simpler to just throw a RuntimeException/TypeError with a "class not found" message directly in findNewMethod/findCallMethod? This is the same thing that ScriptObject does, and I think the message is more important to script writers than the exception type.
> 
> Hannes
> 
> Am 2013-05-21 12:24, schrieb Attila Szegedi:
>> Please review JDK-8014953 at http://cr.openjdk.java.net/~attila/8014953/webrev.00
>> 
>> Thanks,
>>   Attila.
> 



More information about the nashorn-dev mailing list