Mercurial > hg > openjdk > aarch64-port > nashorn
changeset 858:2ca464cf3093 jdk8u20-b13
Merge
author | lana |
---|---|
date | Wed, 30 Apr 2014 23:59:22 -0700 |
parents | aa02e673d768 (current diff) ae85d184a58a (diff) |
children | 2f6add5fefb3 8f06a63adf4e |
files | |
diffstat | 1 files changed, 13 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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()); }