changeset 14058:c6766c447aac

Interpreter: simplify workaround for array clone
author jrose
date Fri, 10 Jun 2016 17:49:08 -0700
parents 0ce7c64463e2
children 1be991c83c66
files interpreter/src/valhalla/interpreter/Interpreter.java
diffstat 1 files changed, 2 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/interpreter/src/valhalla/interpreter/Interpreter.java	Fri Jun 10 19:09:50 2016 -0400
+++ b/interpreter/src/valhalla/interpreter/Interpreter.java	Fri Jun 10 17:49:08 2016 -0700
@@ -346,23 +346,6 @@
     protected HandlerAction invokeOp(Frame f) throws InterpreterError {
         ClassModel.MemberDesc ref = f.readMemberRef(1);
         MethodType methodType = MethodType.fromMethodDescriptorString(ref.desc, f.curClassLoader());
-        if (f.curOpcode() == INVOKEVIRTUAL && ref.owner.startsWith("[")
-                && ref.name.equals("clone") && ref.desc.equals("()Ljava/lang/Object;")) {
-            try {
-                trace(f, "special array clone handling for " + ref.owner);
-                Object[] args = f.popArgs(ref.desc);
-                Object receiver = f.apop();
-                Method m = Object.class.getDeclaredMethod("clone");
-                m.setAccessible(true);
-                f.apush(m.invoke(receiver, args));
-                return next();
-            }
-            catch (ReflectiveOperationException e) {
-                if (TRACING)
-                    System.out.printf("Exception in field lookup: " + e);
-                // fall through to standard processing
-            }
-        }
         return memberOp(f, toClass(f, ref.owner), ref.name, methodType);
     }
 
@@ -555,6 +538,8 @@
             throws LinkageError {
         if (opcode == INVOKEVIRTUAL && owner.isInterface())  // corner case for List.hashCode (ugly!)
             opcode = INVOKEINTERFACE;
+        if (opcode == INVOKEVIRTUAL && owner.isArray())  // workaround for bugs with lookup to T[].clone, etc.
+            owner = Object[].class;
         try {
             return opcode == INVOKESPECIAL && name.equals("<init>")
                    ? InternalHelpers.findSpecialConstructor(owner, (MethodType) type)