# HG changeset patch # User lana # Date 1398927562 25200 # Node ID 2ca464cf3093444f73e27ace78993629d2f15cb9 # Parent aa02e673d7687b273af884c900e907ccd1df27eb# Parent ae85d184a58aebd43c554967b83f4c4e4290cbf6 Merge diff -r aa02e673d768 -r 2ca464cf3093 src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java --- a/src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java Wed Apr 30 11:17:23 2014 -0700 +++ b/src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java Wed Apr 30 23:59:22 2014 -0700 @@ -131,7 +131,7 @@ * implemented securely. */ final class JavaAdapterBytecodeGenerator { - static final Type OBJECT_TYPE = Type.getType(Object.class); + static final Type OBJECT_TYPE = Type.getType(Object.class); static final String OBJECT_TYPE_NAME = OBJECT_TYPE.getInternalName(); @@ -139,6 +139,7 @@ static final String GLOBAL_FIELD_NAME = "global"; + // "global" is declared as Object instead of Global - avoid static references to internal Nashorn classes when possible. static final String GLOBAL_TYPE_DESCRIPTOR = OBJECT_TYPE.getDescriptor(); static final String SET_GLOBAL_METHOD_DESCRIPTOR = Type.getMethodDescriptor(Type.VOID_TYPE, OBJECT_TYPE); @@ -642,7 +643,7 @@ mv.athrow(); } else { // If the super method is not abstract, delegate to it. - emitSuperCall(mv, name, methodDesc); + emitSuperCall(mv, method.getDeclaringClass(), name, methodDesc); } mv.visitLabel(handleDefined); @@ -671,7 +672,7 @@ // stack: [creatingGlobal, creatingGlobal, handle] // Emit code for switching to the creating global - // ScriptObject currentGlobal = Context.getGlobal(); + // Global currentGlobal = Context.getGlobal(); invokeGetGlobal(mv); mv.dup(); @@ -814,12 +815,12 @@ SUPER_PREFIX + name, methodDesc, null, getExceptionNames(method.getExceptionTypes()))); mv.visitCode(); - emitSuperCall(mv, name, methodDesc); + emitSuperCall(mv, method.getDeclaringClass(), name, methodDesc); endMethod(mv); } - private void emitSuperCall(final InstructionAdapter mv, final String name, final String methodDesc) { + private void emitSuperCall(final InstructionAdapter mv, final Class owner, final String name, final String methodDesc) { mv.visitVarInsn(ALOAD, 0); int nextParam = 1; final Type methodType = Type.getMethodType(methodDesc); @@ -827,7 +828,13 @@ mv.load(nextParam, t); nextParam += t.getSize(); } - mv.invokespecial(superClassName, name, methodDesc, false); + + // default method - non-abstract, interface method + if (Modifier.isInterface(owner.getModifiers())) { + mv.invokespecial(Type.getInternalName(owner), name, methodDesc, false); + } else { + mv.invokespecial(superClassName, name, methodDesc, false); + } mv.areturn(methodType.getReturnType()); }