You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2020/07/19 12:28:51 UTC

[groovy] branch danielsun/tweak-vmplugin updated (5f18481 -> 9c5db3c)

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a change to branch danielsun/tweak-vmplugin
in repository https://gitbox.apache.org/repos/asf/groovy.git.


 discard 5f18481  Try to fix the failing build on JDK14
     new 9c5db3c  Try to fix the failing build on JDK14

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (5f18481)
            \
             N -- N -- N   refs/heads/danielsun/tweak-vmplugin (9c5db3c)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/main/java/org/codehaus/groovy/vmplugin/v8/Java8.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


[groovy] 01/01: Try to fix the failing build on JDK14

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch danielsun/tweak-vmplugin
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 9c5db3c571266679d6c9d2a049547f942711c1ad
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sun Jul 19 20:28:21 2020 +0800

    Try to fix the failing build on JDK14
---
 src/main/java/org/codehaus/groovy/vmplugin/v8/Java8.java | 11 ++++++-----
 src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java |  5 +++++
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v8/Java8.java b/src/main/java/org/codehaus/groovy/vmplugin/v8/Java8.java
index bf865da..c8e2301 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v8/Java8.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v8/Java8.java
@@ -141,6 +141,10 @@ public class Java8 implements VMPlugin {
         mn.setAnnotationDefault(true);
     }
 
+    protected MethodHandles.Lookup newLookup(final Class<?> declaringClass) {
+        return of(declaringClass);
+    }
+
     private static Constructor<MethodHandles.Lookup> getLookupConstructor() {
         return LookupHolder.LOOKUP_Constructor;
     }
@@ -618,16 +622,13 @@ public class Java8 implements VMPlugin {
     public Object getInvokeSpecialHandle(Method method, Object receiver) {
         final Class<?> receiverType = receiver.getClass();
         try {
-            return of(receiverType).unreflectSpecial(method, receiverType).bindTo(receiver);
+            return newLookup(receiverType).unreflectSpecial(method, receiverType).bindTo(receiver);
         } catch (ReflectiveOperationException e) {
             return getInvokeSpecialHandleFallback(method, receiver);
         }
     }
 
     private Object getInvokeSpecialHandleFallback(Method method, Object receiver) {
-        if (getLookupConstructor() == null) {
-            throw new GroovyBugError("getInvokeSpecialHandle requires at least JDK 7 for private access to Lookup");
-        }
         if (!method.isAccessible()) {
             AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
                 ReflectionUtils.trySetAccessible(method);
@@ -636,7 +637,7 @@ public class Java8 implements VMPlugin {
         }
         Class<?> declaringClass = method.getDeclaringClass();
         try {
-            return getLookupConstructor().newInstance(declaringClass, -1).
+            return newLookup(declaringClass).
                     unreflectSpecial(method, declaringClass).
                     bindTo(receiver);
         } catch (ReflectiveOperationException e) {
diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java b/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java
index a004a67..90a21c2 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java
@@ -156,6 +156,11 @@ public class Java9 extends Java8 {
         }
     }
 
+    @Override
+    protected MethodHandles.Lookup newLookup(final Class<?> declaringClass) {
+        return of(declaringClass);
+    }
+
     private static Constructor<MethodHandles.Lookup> getLookupConstructor() {
         return LookupHolder.LOOKUP_Constructor;
     }