Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions checker/tests/resourceleak/Issue7217.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import java.util.Collection;

class Issue7217<E extends Enum<E>> {

/**
* This method triggers a Least Upper Bound (LUB) merge of two collections of a captured type
* variable E. * Before the fix, the ternary operator causes the Resource Leak Checker to crash
* with a NullPointerException in CFAbstractValue.
*/
Comment thread
Suvrat1629 marked this conversation as resolved.
Outdated
void test(boolean b, Collection<E> c1, Collection<E> c2) {
Object x = b ? c1 : c2;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,9 @@ private final AnnotationMirror lowestQualifier(AnnotationMirror qual1, Annotatio
AnnotatedTypeVariable typeVar,
AnnotationMirror top,
boolean canCombinedSetBeMissingAnnos) {
if (typeVar == null) {
return annotation;
}

AnnotationMirror upperBound = typeVar.getEffectiveAnnotationInHierarchy(top);
TypeMirror upperBoundTM = typeVar.getUpperBound().getUnderlyingType();
Expand Down Expand Up @@ -591,6 +594,9 @@ public ValueLub(boolean shouldWiden) {
AnnotatedTypeVariable typeVar,
AnnotationMirror top,
boolean canCombinedSetBeMissingAnnos) {
if (typeVar == null) {
return annotation;
}
TypeMirror typeVarTM = typeVar.getUnderlyingType();
if (canCombinedSetBeMissingAnnos) {
// anno is the primary annotation on the use of a type variable. typeVar is a use of
Expand Down Expand Up @@ -700,6 +706,9 @@ protected class ValueGlb extends AnnotationSetCombiner {
AnnotatedTypeVariable typeVar,
AnnotationMirror top,
boolean canCombinedSetBeMissingAnnos) {
if (typeVar == null) {
return annotation;
}
TypeMirror typeVarTM = typeVar.getUnderlyingType();
if (canCombinedSetBeMissingAnnos) {
// anno is the primary annotation on the use of a type variable. typeVar is a use of
Expand Down
Loading