changeset 431:c78764535f4e

meth-info-7087570: update
author jrose
date Sat, 22 Sep 2012 01:40:18 -0700
parents 7325272c5eb4
children 0a42ce213e8b
files meth-info-7087570.patch
diffstat 1 files changed, 122 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/meth-info-7087570.patch	Fri Sep 21 23:50:31 2012 -0700
+++ b/meth-info-7087570.patch	Sat Sep 22 01:40:18 2012 -0700
@@ -5,43 +5,58 @@
 diff --git a/src/share/classes/java/lang/invoke/DirectMethodHandle.java b/src/share/classes/java/lang/invoke/DirectMethodHandle.java
 --- a/src/share/classes/java/lang/invoke/DirectMethodHandle.java
 +++ b/src/share/classes/java/lang/invoke/DirectMethodHandle.java
-@@ -54,15 +54,19 @@
-         this.member = member;
+@@ -55,8 +55,7 @@
      }
  
--    // Factory methods:
+     // Factory methods:
 -
 -    static DirectMethodHandle make(Class<?> receiver, MemberName member) {
-+    private static MethodType computeMethodType(Class<?> receiver, MemberName member) {
++    static DirectMethodHandle make(byte refKind, Class<?> receiver, MemberName member) {
          MethodType mtype = member.getMethodOrFieldType();
          if (!member.isStatic()) {
              if (!member.getDeclaringClass().isAssignableFrom(receiver) || member.isConstructor())
-                 throw new InternalError(member.toString());
+@@ -64,8 +63,14 @@
              mtype = mtype.insertParameterTypes(0, receiver);
          }
-+        return mtype;
+         if (!member.isField()) {
+-            LambdaForm lform = preparedLambdaForm(member);
+-            return new DirectMethodHandle(mtype, lform, member);
++            if (refKind == REF_invokeSpecial) {
++                member = member.asSpecial();
++                LambdaForm lform = preparedLambdaForm(member);
++                return new Special(mtype, lform, member);
++            } else {
++                LambdaForm lform = preparedLambdaForm(member);
++                return new DirectMethodHandle(mtype, lform, member);
++            }
+         } else {
+             LambdaForm lform = preparedFieldLambdaForm(member);
+             if (member.isStatic()) {
+@@ -79,6 +84,12 @@
+             }
+         }
+     }
++    static DirectMethodHandle make(Class<?> receiver, MemberName member) {
++        byte refKind = member.getReferenceKind();
++        if (refKind == REF_invokeSpecial)
++            refKind =  REF_invokeVirtual;
++        return make(refKind, receiver, member);
 +    }
-+
-+    // Factory methods:
-+    static DirectMethodHandle make(Class<?> receiver, MemberName member) {
-+        MethodType mtype = computeMethodType(receiver, member);
-         if (!member.isField()) {
-             LambdaForm lform = preparedLambdaForm(member);
-             return new DirectMethodHandle(mtype, lform, member);
-@@ -84,6 +88,12 @@
+     static DirectMethodHandle make(MemberName member) {
+         if (member.isConstructor())
              return makeAllocator(member);
-         return make(member.getDeclaringClass(), member);
-     }
-+    static DirectMethodHandle makeSpecial(Class<?> receiver, MemberName member) {
-+        assert(member.getReferenceKind() == REF_invokeSpecial) : member;
-+        MethodType mtype = computeMethodType(receiver, member);
-+        LambdaForm lform = preparedLambdaForm(member);
-+        return new Special(mtype, lform, member);
+@@ -114,6 +125,10 @@
+ 
+     //// Implementation methods.
+     @Override
++    MethodHandle viewAsType(MethodType newType) {
++        return new DirectMethodHandle(newType, form, member);
 +    }
-     static DirectMethodHandle make(Method method) {
-         return make(method.getDeclaringClass(), new MemberName(method));
-     }
-@@ -357,6 +367,18 @@
++    @Override
+     @ForceInline
+     MemberName internalMemberName() {
+         return member;
+@@ -357,6 +372,21 @@
          ((DirectMethodHandle)mh).ensureInitialized();
      }
  
@@ -50,20 +65,65 @@
 +        private Special(MethodType mtype, LambdaForm form, MemberName member) {
 +            super(mtype, form, member);
 +        }
-+        /*non-public*/
 +        @Override
 +        boolean isInvokeSpecial() {
 +            return true;
 +        }
++        @Override
++        MethodHandle viewAsType(MethodType newType) {
++            return new Special(newType, form, member);
++        }
 +    }
 +
      /** This subclass handles constructor references. */
      static class Constructor extends DirectMethodHandle {
          final MemberName initMethod;
+@@ -369,6 +399,10 @@
+             this.instanceClass = instanceClass;
+             assert(initMethod.isResolved());
+         }
++        @Override
++        MethodHandle viewAsType(MethodType newType) {
++            return new Constructor(newType, form, member, initMethod, instanceClass);
++        }
+     }
+ 
+     /*non-public*/ static Object constructorMethod(Object mh) {
+@@ -395,6 +429,10 @@
+         @Override Object checkCast(Object obj) {
+             return fieldType.cast(obj);
+         }
++        @Override
++        MethodHandle viewAsType(MethodType newType) {
++            return new Accessor(newType, form, member, fieldOffset);
++        }
+     }
+ 
+     @ForceInline
+@@ -434,6 +472,10 @@
+         @Override Object checkCast(Object obj) {
+             return fieldType.cast(obj);
+         }
++        @Override
++        MethodHandle viewAsType(MethodType newType) {
++            return new StaticAccessor(newType, form, member, staticBase, staticOffset);
++        }
+     }
+ 
+     @ForceInline
 diff --git a/src/share/classes/java/lang/invoke/MethodHandle.java b/src/share/classes/java/lang/invoke/MethodHandle.java
 --- a/src/share/classes/java/lang/invoke/MethodHandle.java
 +++ b/src/share/classes/java/lang/invoke/MethodHandle.java
-@@ -1268,6 +1268,11 @@
+@@ -1250,8 +1250,6 @@
+     /*non-public*/
+     MethodHandle viewAsType(MethodType newType) {
+         // No actual conversions, just a new view of the same method.
+-        if (!type.isViewableAs(newType))
+-            throw new InternalError();
+         return MethodHandleImpl.makePairwiseConvert(this, newType, 0);
+     }
+ 
+@@ -1268,6 +1266,11 @@
      }
  
      /*non-public*/
@@ -75,6 +135,38 @@
      Object internalValues() {
          return null;
      }
+diff --git a/src/share/classes/java/lang/invoke/MethodHandleImpl.java b/src/share/classes/java/lang/invoke/MethodHandleImpl.java
+--- a/src/share/classes/java/lang/invoke/MethodHandleImpl.java
++++ b/src/share/classes/java/lang/invoke/MethodHandleImpl.java
+@@ -366,11 +366,11 @@
+ 
+         @Override
+         MethodHandle viewAsType(MethodType newType) {
+-            MethodHandle mh = super.viewAsType(newType);
++            if (newType.lastParameterType() != type().lastParameterType())
++                throw new InternalError();
++            MethodHandle newTarget = asFixedArity().viewAsType(newType);
+             // put back the varargs bit:
+-            MethodType type = mh.type();
+-            int arity = type.parameterCount();
+-            return mh.asVarargsCollector(type.parameterType(arity-1));
++            return new AsVarargsCollector(newTarget, newType, arrayType);
+         }
+ 
+         @Override
+@@ -378,6 +378,12 @@
+             return asFixedArity().internalMemberName();
+         }
+ 
++        /*non-public*/
++        @Override
++        boolean isInvokeSpecial() {
++            return asFixedArity().isInvokeSpecial();
++        }
++
+ 
+         @Override
+         MethodHandle bindArgument(int pos, char basicType, Object value) {
 diff --git a/src/share/classes/java/lang/invoke/MethodHandleInfo.java b/src/share/classes/java/lang/invoke/MethodHandleInfo.java
 --- a/src/share/classes/java/lang/invoke/MethodHandleInfo.java
 +++ b/src/share/classes/java/lang/invoke/MethodHandleInfo.java
@@ -101,16 +193,12 @@
 diff --git a/src/share/classes/java/lang/invoke/MethodHandles.java b/src/share/classes/java/lang/invoke/MethodHandles.java
 --- a/src/share/classes/java/lang/invoke/MethodHandles.java
 +++ b/src/share/classes/java/lang/invoke/MethodHandles.java
-@@ -1211,7 +1211,11 @@
+@@ -1208,7 +1208,7 @@
              checkMethod(refKind, refc, method);
              if (method.isMethodHandleInvoke())
                  return fakeMethodHandleInvoke(method);
 -            MethodHandle mh = DirectMethodHandle.make(refc, method);
-+            MethodHandle mh;
-+            if (refKind != REF_invokeSpecial)
-+                mh = DirectMethodHandle.make(refc, method);
-+            else
-+                mh = DirectMethodHandle.makeSpecial(refc, method.asSpecial());
-             mh = maybeBindCaller(method, mh);
++            MethodHandle mh = DirectMethodHandle.make(refKind, refc, method);
              mh = mh.setVarargs(method);
              if (doRestrict)
+                 mh = restrictReceiver(method, mh, lookupClass());