From adc9d7681ba8876f099e909098da60b82d9eb021 Mon Sep 17 00:00:00 2001 From: arjantijms Date: Sat, 3 Apr 2021 22:28:00 +0200 Subject: [PATCH] #22 Add escape hatch for fatal exception on latest JDK versions. Note this fatal exception has been lurking in the code all along, but it seems like in ~14 years nobody ever uses GMBAL on a code base where a method had a generic type with two bounds. Also updated .gitignore and pom.xml Signed-off-by: arjantijms --- .gitignore | 16 +++++- api-only/pom.xml | 4 +- impl/pom.xml | 4 +- .../gmbal/typelib/TypeEvaluator.java | 49 +++++++++++-------- pom.xml | 8 +-- 5 files changed, 51 insertions(+), 30 deletions(-) diff --git a/.gitignore b/.gitignore index bba684d..5ad7b33 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,18 @@ build/** .idea/** *.iml **/dependency-reduced-pom.xml -/target/ \ No newline at end of file +/target/ +*.ipr +*.iml +*.iws +*.swp +*~ +*.output +*.class +target/ +.idea +nbactions.xml +nb-configuration.xml +.classpath +.project +.settings/ \ No newline at end of file diff --git a/api-only/pom.xml b/api-only/pom.xml index e6144f2..40417a1 100644 --- a/api-only/pom.xml +++ b/api-only/pom.xml @@ -16,13 +16,13 @@ org.glassfish.gmbal gmbal-project - 4.0.1-SNAPSHOT + 4.0.3-SNAPSHOT ../pom.xml org.glassfish.gmbal gmbal-api-only - 4.0.1-SNAPSHOT + 4.0.3-SNAPSHOT GMBAL (API only) GlassFish MBean Annotation Library (API only) diff --git a/impl/pom.xml b/impl/pom.xml index a7770da..bc8a666 100644 --- a/impl/pom.xml +++ b/impl/pom.xml @@ -16,12 +16,12 @@ org.glassfish.gmbal gmbal-project - 4.0.1-SNAPSHOT + 4.0.3-SNAPSHOT org.glassfish.gmbal gmbal - 4.0.1-SNAPSHOT + 4.0.3-SNAPSHOT GMBAL (Implementation) GlassFish MBean Annotation Library (Implementation) diff --git a/impl/src/main/java/org/glassfish/gmbal/typelib/TypeEvaluator.java b/impl/src/main/java/org/glassfish/gmbal/typelib/TypeEvaluator.java index 025fcd3..e047217 100644 --- a/impl/src/main/java/org/glassfish/gmbal/typelib/TypeEvaluator.java +++ b/impl/src/main/java/org/glassfish/gmbal/typelib/TypeEvaluator.java @@ -10,33 +10,34 @@ package org.glassfish.gmbal.typelib; -import java.lang.reflect.Field; -import java.security.PrivilegedActionException; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.ArrayList; -import java.util.Arrays; - -import static java.lang.reflect.Modifier.* ; +import static java.lang.Boolean.FALSE; +import static java.lang.reflect.Modifier.PUBLIC; -import java.lang.reflect.Type ; +import java.lang.reflect.Field; import java.lang.reflect.GenericArrayType ; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import java.lang.reflect.WildcardType ; import java.lang.reflect.ParameterizedType ; +import java.lang.reflect.Type ; import java.lang.reflect.TypeVariable ; +import java.lang.reflect.WildcardType ; import java.math.BigDecimal; import java.math.BigInteger; import java.security.AccessController; import java.security.PrivilegedAction; +import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; +import java.util.ArrayList; +import java.util.Arrays; import java.util.Date; +import java.util.HashMap; import java.util.Iterator; +import java.util.List; +import java.util.Map; import java.util.WeakHashMap; + import javax.management.ObjectName; + import org.glassfish.gmbal.impl.trace.TraceTypelib; import org.glassfish.gmbal.impl.trace.TraceTypelibEval; import org.glassfish.pfl.basic.algorithm.Algorithms; @@ -316,11 +317,13 @@ private Pair,List> getKey( Class cls ) { Type[] bounds = tv.getBounds() ; if (bounds.length > 0) { if (bounds.length > 1) { - throw Exceptions.self - .multipleUpperBoundsNotSupported( tv ) ; - } else { - type = bounds[0] ; - } + if (!Boolean.valueOf(System.getProperty("org.glassfish.gmbal.no.multipleUpperBoundsException"))) { + throw Exceptions.self + .multipleUpperBoundsNotSupported( tv ) ; + } + } + + type = bounds[0] ; } else { type = Object.class ; } @@ -601,8 +604,10 @@ private EvaluatedType visitWildcardType( WildcardType wt ) { List ub = Arrays.asList( wt.getUpperBounds() ) ; if (ub.size() > 0) { if (ub.size() > 1) { - throw Exceptions.self.multipleUpperBoundsNotSupported( - wt) ; + if (!Boolean.valueOf(System.getProperty("org.glassfish.gmbal.no.multipleUpperBoundsException"))) { + throw Exceptions.self.multipleUpperBoundsNotSupported( + wt) ; + } } result = evaluateType( ub.get(0) ) ; @@ -628,8 +633,10 @@ private EvaluatedType lookup( TypeVariable tvar ) { Type[] bounds = tvar.getBounds() ; if (bounds.length > 0) { if (bounds.length > 1) { - throw Exceptions.self - .multipleUpperBoundsNotSupported( tvar ) ; + if (!Boolean.valueOf(System.getProperty("org.glassfish.gmbal.no.multipleUpperBoundsException"))) { + throw Exceptions.self + .multipleUpperBoundsNotSupported( tvar ) ; + } } result = evaluateType( bounds[0] ) ; diff --git a/pom.xml b/pom.xml index 9293043..1321d8a 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ org.glassfish.gmbal gmbal-project - 4.0.1-SNAPSHOT + 4.0.3-SNAPSHOT pom GMBAL @@ -83,7 +83,7 @@ 8 - 4.1.0 + 4.1.2 3.2.3 ${project.basedir}/.. @@ -123,7 +123,7 @@ junit junit - 4.12 + 4.13.2 @@ -154,7 +154,7 @@ org.apache.felix maven-bundle-plugin - 4.2.1 + 5.1.2