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 2022/08/06 10:39:11 UTC
[groovy] branch master updated: Check `Lookup` constants
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new 5817ca1dd8 Check `Lookup` constants
5817ca1dd8 is described below
commit 5817ca1dd8e39849796c818064019c209e852585
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Aug 6 18:38:53 2022 +0800
Check `Lookup` constants
---
src/main/java/org/apache/groovy/lang/GroovyObjectHelper.java | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/main/java/org/apache/groovy/lang/GroovyObjectHelper.java b/src/main/java/org/apache/groovy/lang/GroovyObjectHelper.java
index 494e8b1e44..5ccf4d237c 100644
--- a/src/main/java/org/apache/groovy/lang/GroovyObjectHelper.java
+++ b/src/main/java/org/apache/groovy/lang/GroovyObjectHelper.java
@@ -19,6 +19,7 @@
package org.apache.groovy.lang;
import groovy.lang.GroovyObject;
+import org.codehaus.groovy.GroovyBugError;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodHandles.Lookup;
@@ -133,6 +134,13 @@ public class GroovyObjectHelper {
private static final Lookup LOOKUP = MethodHandles.lookup();
private static final Lookup NULL_LOOKUP = MethodHandles.lookup();
+ static {
+ if (NULL_LOOKUP == LOOKUP) {
+ // should never happen
+ throw new GroovyBugError("`MethodHandles.lookup()` returns the same `Lookup` instance");
+ }
+ }
+
private static final ClassValue<AtomicReference<Lookup>> LOOKUP_MAP = new ClassValue<AtomicReference<Lookup>>() {
@Override
protected AtomicReference<Lookup> computeValue(Class<?> type) {