Skip to content

Commit

Permalink
#22 Add escape hatch for fatal exception on latest JDK versions.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
arjantijms committed Apr 3, 2021
1 parent bf7ef2e commit adc9d76
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 30 deletions.
16 changes: 15 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,18 @@ build/**
.idea/**
*.iml
**/dependency-reduced-pom.xml
/target/
/target/
*.ipr
*.iml
*.iws
*.swp
*~
*.output
*.class
target/
.idea
nbactions.xml
nb-configuration.xml
.classpath
.project
.settings/
4 changes: 2 additions & 2 deletions api-only/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
<parent>
<groupId>org.glassfish.gmbal</groupId>
<artifactId>gmbal-project</artifactId>
<version>4.0.1-SNAPSHOT</version>
<version>4.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<groupId>org.glassfish.gmbal</groupId>
<artifactId>gmbal-api-only</artifactId>
<version>4.0.1-SNAPSHOT</version>
<version>4.0.3-SNAPSHOT</version>

<name>GMBAL (API only)</name>
<description>GlassFish MBean Annotation Library (API only)</description>
Expand Down
4 changes: 2 additions & 2 deletions impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
<parent>
<groupId>org.glassfish.gmbal</groupId>
<artifactId>gmbal-project</artifactId>
<version>4.0.1-SNAPSHOT</version>
<version>4.0.3-SNAPSHOT</version>
</parent>

<groupId>org.glassfish.gmbal</groupId>
<artifactId>gmbal</artifactId>
<version>4.0.1-SNAPSHOT</version>
<version>4.0.3-SNAPSHOT</version>

<name>GMBAL (Implementation)</name>
<description>GlassFish MBean Annotation Library (Implementation)</description>
Expand Down
49 changes: 28 additions & 21 deletions impl/src/main/java/org/glassfish/gmbal/typelib/TypeEvaluator.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -316,11 +317,13 @@ private Pair<Class<?>,List<Type>> 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 ;
}
Expand Down Expand Up @@ -601,8 +604,10 @@ private EvaluatedType visitWildcardType( WildcardType wt ) {
List<Type> 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) ) ;
Expand All @@ -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] ) ;
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<groupId>org.glassfish.gmbal</groupId>
<artifactId>gmbal-project</artifactId>
<version>4.0.1-SNAPSHOT</version>
<version>4.0.3-SNAPSHOT</version>
<packaging>pom</packaging>

<name>GMBAL</name>
Expand Down Expand Up @@ -83,7 +83,7 @@

<properties>
<jdkVersion>8</jdkVersion>
<pfl.version>4.1.0</pfl.version>
<pfl.version>4.1.2</pfl.version>
<gmbal.commons.version>3.2.3</gmbal.commons.version>
<legal.doc.source>${project.basedir}/..</legal.doc.source>
</properties>
Expand Down Expand Up @@ -123,7 +123,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<version>4.13.2</version>
</dependency>
</dependencies>
</dependencyManagement>
Expand Down Expand Up @@ -154,7 +154,7 @@
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>4.2.1</version>
<version>5.1.2</version>
</plugin>
<!-- override default "built-by" entry, which points to a developer's user id -->
<plugin>
Expand Down

0 comments on commit adc9d76

Please sign in to comment.