Undeclared globals in eval code can refer to anything in the containing environment, so even if they qualify for the fast-scope flag within the eval script, the callsite should not be handled as fast scope when linking with a property of the containing environment. This bug can be replicated by running the test case from JDK-8026167 with objects fields: jjs -Dnashorn.fields.objects test/script/basic/JDK-8026167.js Exception in thread "main" java.lang.ClassCastException: Cannot cast jdk.nashorn.internal.scripts.JO2P0 to jdk.nashorn.internal.scripts.JO1P1 at java.lang.invoke.MethodHandleImpl.newClassCastException(MethodHandleImpl.java:361) at java.lang.invoke.MethodHandleImpl.castReference(MethodHandleImpl.java:356) at jdk.nashorn.internal.scripts.Script$Recompilation$8$\^eval\_#1\!27\^eval\_.:program(<eval>#1:27<eval>:1) at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:636) at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:228) at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393) at jdk.nashorn.internal.runtime.Context.eval(Context.java:712) at jdk.nashorn.internal.objects.Global.directEval(Global.java:1250)