You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by GitBox <gi...@apache.org> on 2021/06/25 00:39:31 UTC

[GitHub] [groovy] paulk-asert commented on a change in pull request #1598: GROOVY-10145: Support JDK16

paulk-asert commented on a change in pull request #1598:
URL: https://github.com/apache/groovy/pull/1598#discussion_r657685086



##########
File path: buildSrc/src/main/groovy/org.apache.groovy-core.gradle
##########
@@ -50,6 +50,10 @@ sourceSets {
                 exclude '**/v10/*'
                 exclude '**/vm10/*'
             }
+            if (!JavaVersion.current().isJava11Compatible()) {
+                exclude '**/v16/*'
+                exclude '**/vm16/*'
+            }

Review comment:
       The version check for the JVM version warning in the main `build.gradle` and the `checkCompatibility` version check in `org.apache.groovy-core.gradle` should both be bumped to 11.

##########
File path: src/main/java/org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java
##########
@@ -941,4 +944,24 @@ public V call(final Object... args) {
         }
     }
 
+    private static final MethodHandle IS_SEALED_METHODHANDLE;
+    static {
+        MethodHandle mh = null;
+        try {
+            mh = MethodHandles.lookup().findVirtual(Class.class, "isSealed", MethodType.methodType(boolean.class, new Class[0]));
+        } catch (NoSuchMethodException | IllegalAccessException ignored) {
+        }
+        IS_SEALED_METHODHANDLE = mh;
+    }
+
+    private static boolean isSealed(Class<?> clazz) {
+        if (null == IS_SEALED_METHODHANDLE) return false;
+
+        boolean sealed = false;
+        try {
+            sealed = (boolean) IS_SEALED_METHODHANDLE.bindTo(clazz).invokeExact();
+        } catch (Throwable ignored) {
+        }
+        return sealed;
+    }

Review comment:
       It might be worth putting this utility method somewhere else. ReflectionUtils? I imagine we will want to change the Groovy compiler so that Groovy classes can't extend from sealed Java classes.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org