Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: issue optional warning using '==' for wrapper types #2188

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
be4d139
feat: issue optional warning using '==' for wrapper types
dashorst Mar 20, 2024
5d9a86e
refactor: ComparingWrapper constant -> 1202
dashorst Apr 6, 2024
33b3448
docs: clarify ComparingWrapper detection of boxed types
dashorst Apr 6, 2024
f4e2db9
refactor: use already available severity computation
dashorst Apr 6, 2024
221dcd4
refactor: rename to unlikely equal expression argument type
dashorst Apr 6, 2024
dcd55f0
fix: also rename compiler option and document it
dashorst Apr 6, 2024
0784fef
refactor: UnlikelyEqualExpressionArgumenType -> UnlikelyReferenceComp…
dashorst Apr 8, 2024
389bdfb
refactor: add operator to unlikelyReferenceComparison message
dashorst Apr 8, 2024
b3140c8
fix: CompilerInvocationTests
dashorst Apr 8, 2024
4b3c272
feat: add support for more reference comparison detections
dashorst Apr 8, 2024
384a8ae
fix: UnlikelyReferenceComparison with null should not warn
dashorst Apr 9, 2024
843cc58
test: Ignore unlikely reference comparison in AssignmentTest
dashorst Apr 9, 2024
2eaf0f3
test: Ignore unlikely reference comparison in CastTest
dashorst Apr 9, 2024
ee3fa2d
test: ignore unlikely reference comparison in AutoBoxingTest
dashorst Apr 12, 2024
4372822
test: replace comparingWrapper with unlikelyReferenceComparison in Ba…
dashorst Apr 12, 2024
b07953b
fix: change default of unlikelyReferenceComparison to INFO in Irritan…
dashorst Apr 12, 2024
94fd84b
test: ignore unlikely reference comparison in NegativeLambdaExpressio…
dashorst Apr 12, 2024
89ea49a
test: fix BatchCompilerTest (correctly identified unlikely comparison)
dashorst Apr 12, 2024
b3cf7e2
refactor: unlikelyReferenceComparison -> dubiousReferenceComparison
dashorst May 9, 2024
d4eb747
fix: test runner gave errors on non-normalized paths
dashorst May 9, 2024
df2ef7e
fix: give better test failure messages
dashorst May 9, 2024
d6393d1
Update warning message from Unlikely -> Dubious
dashorst May 9, 2024
3c0d8ac
test: Normalise path differences in assertion
dashorst May 12, 2024
2ec884d
refactor: implement review comments
dashorst May 18, 2024
bf2fec3
clean: remove duplicate entry in CompilerOptions
dashorst May 18, 2024
5d54c68
Merge branch 'master' into dashorst:issue_2176
stephan-herrmann Jun 6, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* Utility class to hold results of processor-based tests.
* All methods are static.
*/
@SuppressWarnings("reference-comparison")
public final class ProcessorTestStatus {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2184,6 +2184,8 @@ public interface IProblem {
int UnlikelyCollectionMethodArgumentType = 1200;
/** @since 3.13 */
int UnlikelyEqualsArgumentType = 1201;
/** @since 3.38 */
int DubiousReferenceComparison = 1202;

/* Local-Variable Type Inference */
/** @since 3.14 */
Expand Down Expand Up @@ -2621,5 +2623,4 @@ public interface IProblem {
* @noreference preview feature
*/
int DisallowedStatementInPrologue = PreviewRelated + 2023;

}
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,25 @@ public TypeBinding resolveType(BlockScope scope) {
}
}
}

boolean leftTypeIsNumber = new String(leftType.readableName()).equals("java.lang.Number"); //$NON-NLS-1$
boolean rightTypeIsNumber = new String(rightType.readableName()).equals("java.lang.Number"); //$NON-NLS-1$

// Check for dubious comparisons of references, for both wrapper types or strings.
// Putting primitives (or calculations) in the mix results in unboxing the wrappers to their
// primitives, so this only warns when both sides are wrappers. e.g. (x1 == (x2 + 1)) results in
// (x2 + 1) becoming a primitive, and an unboxing of x1 as well, not necessitating a warning.
// When comparing a reference to null the assumption is that the developer is aware of comparing
// references, so the comparison is not unlikely
if((leftType != TypeBinding.NULL && rightType != TypeBinding.NULL) &&
((leftType.isBoxedPrimitiveType() && rightType.isBoxedPrimitiveType()) ||
(!leftType.isPrimitiveType() && (rightType.isBoxedPrimitiveType() || rightTypeIsNumber)) ||
((leftType.isBoxedPrimitiveType() || leftTypeIsNumber) && !rightType.isPrimitiveType()) ||
(leftType.id == rightType.id && (leftType.id == TypeIds.T_JavaLangString || leftType.isArrayType()))))
{
scope.problemReporter().dubiousComparison(this, operatorToString(), leftType, rightType);
}

// both base type
if (leftType.isBaseType() && rightType.isBaseType()) {
int leftTypeID = leftType.id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,7 @@
if (destinationPath == null) {
destinationPath = this.main.destinationPath;
}
if (destinationPath != null && destinationPath != NONE) {

Check warning on line 1305 in org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/Main.java

View check run for this annotation

Jenkins - Eclipse JDT / Compiler and API Tools

Potential Programming Problem

LOW: Dubious operand types for '!=': java.lang.String and java.lang.String are references
if (File.separatorChar == '/') {
parameters.put(Logger.OUTPUT, destinationPath);
} else {
Expand Down Expand Up @@ -3973,6 +3973,9 @@
CompilerOptions.OPTION_ReportDeadCodeInTrivialIfStatement,
CompilerOptions.DISABLED);
return;
} else if (token.equals("dubiousReferenceComparison")) { //$NON-NLS-1$
setSeverity(CompilerOptions.OPTION_ReportDubiousReferenceComparison, severity, isEnabling);
return;
}
break;
case 'e' :
Expand Down Expand Up @@ -4649,11 +4652,11 @@
if (this.destinationPath == null) {
currentDestinationPath =
extractDestinationPathFromSourceFile(unitResult);
} else if (this.destinationPath != NONE) {

Check warning on line 4655 in org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/Main.java

View check run for this annotation

Jenkins - Eclipse JDT / Compiler and API Tools

Potential Programming Problem

LOW: Dubious operand types for '!=': java.lang.String and java.lang.String are references
currentDestinationPath = this.destinationPath;
generateClasspathStructure = true;
} // else leave currentDestinationPath null
} else if (compilationUnit.destinationPath != NONE) {

Check warning on line 4659 in org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/batch/Main.java

View check run for this annotation

Jenkins - Eclipse JDT / Compiler and API Tools

Potential Programming Problem

LOW: Dubious operand types for '!=': java.lang.String and java.lang.String are references
currentDestinationPath = compilationUnit.destinationPath;
generateClasspathStructure = true;
} // else leave currentDestinationPath null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,9 @@ misc.usage.warn = {1} {2}\n\
\ dep-ann missing @Deprecated annotation\n\
\ deprecation + deprecation outside deprecated code\n\
\ discouraged + use of types matching a discouraged access rule\n\
\ dubiousReferenceComparison\n\
\ + dubious reference comparison of primitive wrappers\n\
\ or strings\n\
\ emptyBlock undocumented empty block\n\
\ enumIdentifier ''enum'' used as identifier\n\
\ enumSwitch incomplete enum switch\n\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ public class CompilerOptions {
public static final String OPTION_ReportUnlikelyCollectionMethodArgumentType = "org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType"; //$NON-NLS-1$
public static final String OPTION_ReportUnlikelyCollectionMethodArgumentTypeStrict = "org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict"; //$NON-NLS-1$
public static final String OPTION_ReportUnlikelyEqualsArgumentType = "org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType"; //$NON-NLS-1$
public static final String OPTION_ReportDubiousReferenceComparison = "org.eclipse.jdt.core.compiler.problem.dubiousReferenceComparison"; //$NON-NLS-1$

public static final String OPTION_ReportAPILeak = "org.eclipse.jdt.core.compiler.problem.APILeak"; //$NON-NLS-1$
public static final String OPTION_ReportUnstableAutoModuleName = "org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName"; //$NON-NLS-1$
Expand Down Expand Up @@ -377,6 +378,7 @@ public class CompilerOptions {
// group 3
public static final int InsufficientResourceManagement = IrritantSet.GROUP3 | ASTNode.Bit1;
public static final int IncompatibleOwningContract = IrritantSet.GROUP3 | ASTNode.Bit2;
public static final int DubiousReferenceComparison = IrritantSet.GROUP3 | ASTNode.Bit3;


// Severity level for handlers
Expand Down Expand Up @@ -601,6 +603,7 @@ public class CompilerOptions {
"nls", //$NON-NLS-1$
"null", //$NON-NLS-1$
"rawtypes", //$NON-NLS-1$
"reference-comparison", //$NON-NLS-1$
"removal", //$NON-NLS-1$
"resource", //$NON-NLS-1$
"restriction", //$NON-NLS-1$
Expand Down Expand Up @@ -831,6 +834,8 @@ public static String optionKeyFromIrritant(int irritant) {
return OPTION_ReportUnlikelyCollectionMethodArgumentType;
case UnlikelyEqualsArgumentType:
return OPTION_ReportUnlikelyEqualsArgumentType;
case DubiousReferenceComparison :
return OPTION_ReportDubiousReferenceComparison;
case APILeak:
return OPTION_ReportAPILeak;
case UnstableAutoModuleName:
Expand Down Expand Up @@ -982,6 +987,7 @@ public static String[] warningOptionNames() {
OPTION_ReportDeprecationInDeprecatedCode,
OPTION_ReportDeprecationWhenOverridingDeprecatedMethod,
OPTION_ReportDiscouragedReference,
OPTION_ReportDubiousReferenceComparison,
OPTION_ReportEmptyStatement,
OPTION_ReportEnumIdentifier,
OPTION_ReportFallthroughCase,
Expand Down Expand Up @@ -1191,6 +1197,8 @@ public static String warningTokenFromIrritant(int irritant) {
case UnlikelyEqualsArgumentType:
case UnlikelyCollectionMethodArgumentType:
return "unlikely-arg-type"; //$NON-NLS-1$
case DubiousReferenceComparison:
return "reference-comparison"; //$NON-NLS-1$
case APILeak:
return "exports"; //$NON-NLS-1$
case UnstableAutoModuleName:
Expand Down Expand Up @@ -1263,6 +1271,8 @@ public static IrritantSet warningTokenToIrritants(String warningToken) {
case 'r' :
if ("rawtypes".equals(warningToken)) //$NON-NLS-1$
return IrritantSet.RAW;
if ("reference-comparison".equals(warningToken)) //$NON-NLS-1$
return IrritantSet.DUBIOUS_REFERENCE_COMPARISON;
if ("resource".equals(warningToken)) //$NON-NLS-1$
return IrritantSet.RESOURCE;
if ("restriction".equals(warningToken)) //$NON-NLS-1$
Expand Down Expand Up @@ -1409,6 +1419,7 @@ public Map<String, String> getMap() {
optionsMap.put(OPTION_EmulateJavacBug8031744, this.emulateJavacBug8031744 ? ENABLED : DISABLED);
optionsMap.put(OPTION_ReportRedundantSuperinterface, getSeverityString(RedundantSuperinterface));
optionsMap.put(OPTION_ReportComparingIdentical, getSeverityString(ComparingIdentical));
optionsMap.put(OPTION_ReportDubiousReferenceComparison, getSeverityString(DubiousReferenceComparison));
optionsMap.put(OPTION_ReportMissingSynchronizedOnInheritedMethod, getSeverityString(MissingSynchronizedModifierInInheritedMethod));
optionsMap.put(OPTION_ReportMissingHashCodeMethod, getSeverityString(ShouldImplementHashcode));
optionsMap.put(OPTION_ReportDeadCode, getSeverityString(DeadCode));
Expand Down Expand Up @@ -2002,6 +2013,7 @@ && getSeverity(ExplicitlyClosedAutoCloseable) == ProblemSeverities.Ignore) {
this.reportUnlikelyCollectionMethodArgumentTypeStrict = ENABLED.equals(optionValue);
}
if ((optionValue = optionsMap.get(OPTION_ReportUnlikelyEqualsArgumentType)) != null) updateSeverity(UnlikelyEqualsArgumentType, optionValue);
if ((optionValue = optionsMap.get(OPTION_ReportDubiousReferenceComparison)) != null) updateSeverity(DubiousReferenceComparison, optionValue);
if ((optionValue = optionsMap.get(OPTION_ReportAPILeak)) != null) updateSeverity(APILeak, optionValue);
if ((optionValue = optionsMap.get(OPTION_ReportUnstableAutoModuleName)) != null) updateSeverity(UnstableAutoModuleName, optionValue);
if ((optionValue = optionsMap.get(OPTION_AnnotationBasedNullAnalysis)) != null) {
Expand Down Expand Up @@ -2367,6 +2379,7 @@ public String toString() {
buf.append("\n\t- unlikely argument type for collection methods: ").append(getSeverityString(UnlikelyCollectionMethodArgumentType)); //$NON-NLS-1$
buf.append("\n\t- unlikely argument type for collection methods, strict check against expected type: ").append(this.reportUnlikelyCollectionMethodArgumentTypeStrict ? ENABLED : DISABLED); //$NON-NLS-1$
buf.append("\n\t- unlikely argument types for equals(): ").append(getSeverityString(UnlikelyEqualsArgumentType)); //$NON-NLS-1$
buf.append("\n\t- dubious operand type for reference comparison: ").append(getSeverityString(DubiousReferenceComparison)); //$NON-NLS-1$
buf.append("\n\t- API leak: ").append(getSeverityString(APILeak)); //$NON-NLS-1$
buf.append("\n\t- unstable auto module name: ").append(getSeverityString(UnstableAutoModuleName)); //$NON-NLS-1$
buf.append("\n\t- SuppressWarnings not fully analysed: ").append(getSeverityString(SuppressWarningsNotAnalysed)); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public class IrritantSet {
public static final IrritantSet UNQUALIFIED_FIELD_ACCESS = new IrritantSet(CompilerOptions.UnqualifiedFieldAccess);
public static final IrritantSet RESOURCE = new IrritantSet(CompilerOptions.UnclosedCloseable);
public static final IrritantSet UNLIKELY_ARGUMENT_TYPE = new IrritantSet(CompilerOptions.UnlikelyCollectionMethodArgumentType);
public static final IrritantSet DUBIOUS_REFERENCE_COMPARISON = new IrritantSet(CompilerOptions.DubiousReferenceComparison);
public static final IrritantSet API_LEAK = new IrritantSet(CompilerOptions.APILeak);
public static final IrritantSet MODULE = new IrritantSet(CompilerOptions.UnstableAutoModuleName);

Expand All @@ -87,7 +88,10 @@ public class IrritantSet {
.set(
CompilerOptions.UnlikelyEqualsArgumentType
| CompilerOptions.SuppressWarningsNotAnalysed
| CompilerOptions.AnnotatedTypeArgumentToUnannotated);
| CompilerOptions.AnnotatedTypeArgumentToUnannotated)
// group-3 infos enabled by default
.set(CompilerOptions.DubiousReferenceComparison)
;

COMPILER_DEFAULT_WARNINGS
// group-0 warnings enabled by default
Expand Down Expand Up @@ -140,7 +144,8 @@ public class IrritantSet {
|CompilerOptions.UnstableAutoModuleName
|CompilerOptions.PreviewFeatureUsed)
.set(CompilerOptions.InsufficientResourceManagement
|CompilerOptions.IncompatibleOwningContract);
|CompilerOptions.IncompatibleOwningContract)
;
// default errors IF AnnotationBasedNullAnalysis is enabled:
COMPILER_DEFAULT_ERRORS.set(
CompilerOptions.NullSpecViolation
Expand Down Expand Up @@ -196,6 +201,9 @@ public class IrritantSet {

UNLIKELY_ARGUMENT_TYPE
.set(CompilerOptions.UnlikelyEqualsArgumentType);

DUBIOUS_REFERENCE_COMPARISON
.set(CompilerOptions.DubiousReferenceComparison);
}
// Internal state

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,8 @@
return CompilerOptions.UnlikelyCollectionMethodArgumentType;
case IProblem.UnlikelyEqualsArgumentType:
return CompilerOptions.UnlikelyEqualsArgumentType;
case IProblem.DubiousReferenceComparison:
return CompilerOptions.DubiousReferenceComparison;

case IProblem.NonPublicTypeInAPI:
case IProblem.NotExportedTypeInAPI:
Expand Down Expand Up @@ -793,6 +795,7 @@
case CompilerOptions.NonNullTypeVariableFromLegacyInvocation :
case CompilerOptions.UnlikelyCollectionMethodArgumentType :
case CompilerOptions.UnlikelyEqualsArgumentType:
case CompilerOptions.DubiousReferenceComparison:
case CompilerOptions.APILeak:
case CompilerOptions.UnstableAutoModuleName:
return CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM;
Expand Down Expand Up @@ -4047,7 +4050,7 @@
case ProblemReasons.TypeParameterArityMismatch :
problemConstructor = (ProblemMethodBinding) targetConstructor;
shownConstructor = problemConstructor.closestMatch;
if (shownConstructor.typeVariables == Binding.NO_TYPE_VARIABLES) {

Check warning on line 4053 in org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java

View check run for this annotation

Jenkins - Eclipse JDT / Compiler and API Tools

Potential Programming Problem

LOW: Dubious operand types for '==': org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding[] and org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding[] are references
this.handle(
IProblem.NonGenericConstructor,
new String[] {
Expand Down Expand Up @@ -4627,7 +4630,7 @@
case ProblemReasons.TypeParameterArityMismatch :
problemMethod = (ProblemMethodBinding) method;
shownMethod = problemMethod.closestMatch;
if (shownMethod.typeVariables == Binding.NO_TYPE_VARIABLES) {

Check warning on line 4633 in org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java

View check run for this annotation

Jenkins - Eclipse JDT / Compiler and API Tools

Potential Programming Problem

LOW: Dubious operand types for '==': org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding[] and org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding[] are references
this.handle(
IProblem.NonGenericMethod ,
new String[] {
Expand Down Expand Up @@ -5293,13 +5296,13 @@
}

private boolean isRecoveredName(char[] simpleName) {
return simpleName == RecoveryScanner.FAKE_IDENTIFIER;

Check warning on line 5299 in org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java

View check run for this annotation

Jenkins - Eclipse JDT / Compiler and API Tools

Potential Programming Problem

LOW: Dubious operand types for '==': char[] and char[] are references
}

private boolean isRecoveredName(char[][] qualifiedName) {
if(qualifiedName == null) return false;
for (char[] segment : qualifiedName) {
if(segment == RecoveryScanner.FAKE_IDENTIFIER) return true;

Check warning on line 5305 in org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java

View check run for this annotation

Jenkins - Eclipse JDT / Compiler and API Tools

Potential Programming Problem

LOW: Dubious operand types for '==': char[] and char[] are references
}
return false;
}
Expand Down Expand Up @@ -5533,7 +5536,7 @@
case ProblemReasons.TypeParameterArityMismatch :
problemConstructor = (ProblemMethodBinding) targetConstructor;
shownConstructor = problemConstructor.closestMatch;
boolean noTypeVariables = shownConstructor.typeVariables == Binding.NO_TYPE_VARIABLES;

Check warning on line 5539 in org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java

View check run for this annotation

Jenkins - Eclipse JDT / Compiler and API Tools

Potential Programming Problem

LOW: Dubious operand types for '==': org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding[] and org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding[] are references
severity = computeSeverity(noTypeVariables ? IProblem.JavadocNonGenericConstructor : IProblem.JavadocIncorrectArityForParameterizedConstructor);
if (severity == ProblemSeverities.Ignore) return;
if (noTypeVariables) {
Expand Down Expand Up @@ -5774,7 +5777,7 @@
case ProblemReasons.TypeParameterArityMismatch :
problemMethod = (ProblemMethodBinding) method;
shownMethod = problemMethod.closestMatch;
boolean noTypeVariables = shownMethod.typeVariables == Binding.NO_TYPE_VARIABLES;

Check warning on line 5780 in org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java

View check run for this annotation

Jenkins - Eclipse JDT / Compiler and API Tools

Potential Programming Problem

LOW: Dubious operand types for '==': org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding[] and org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding[] are references
severity = computeSeverity(noTypeVariables ? IProblem.JavadocNonGenericMethod : IProblem.JavadocIncorrectArityForParameterizedMethod);
if (severity == ProblemSeverities.Ignore) return;
if (noTypeVariables) {
Expand Down Expand Up @@ -11644,6 +11647,15 @@
argument.sourceEnd);
}

public void dubiousComparison(EqualExpression comparison, String operator, TypeBinding leftType, TypeBinding rightType) {
this.handle(
IProblem.DubiousReferenceComparison,
new String[] {operator, new String(leftType.shortReadableName()), new String(rightType.shortReadableName())},
new String[] {operator, new String(leftType.readableName()), new String(rightType.readableName())},
Comment on lines +11676 to +11677
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ups, these lines should be swapped. This way the default rendering of the problem will use short names, which is friendlier to the eye :)
Frankly, I don't know off-hand where the long version will be used, but let's just play by that convention.

comparison.sourceStart,
comparison.sourceEnd);
}

public void nonPublicTypeInAPI(TypeBinding type, int sourceStart, int sourceEnd) {
handle(IProblem.NonPublicTypeInAPI,
new String[] { new String(type.readableName()) },
Expand Down Expand Up @@ -12237,7 +12249,7 @@
public void sealedSuperTypeInDifferentPackage(int problem, SourceTypeBinding type, TypeReference curType, TypeBinding superTypeBinding, PackageBinding superPackageBinding) {
String typeName = new String(type.sourceName);
String name = new String(superTypeBinding.sourceName());
String packageName = superPackageBinding.compoundName == CharOperation.NO_CHAR_CHAR ? "default" : //$NON-NLS-1$

Check warning on line 12252 in org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java

View check run for this annotation

Jenkins - Eclipse JDT / Compiler and API Tools

Potential Programming Problem

LOW: Dubious operand types for '==': char[][] and char[][] are references
CharOperation.toString(superPackageBinding.compoundName);
String[] arguments = new String[] {typeName, packageName, name};
this.handle(problem,
Expand Down Expand Up @@ -12343,7 +12355,7 @@
public void sealedPermittedTypeOutsideOfPackage(ReferenceBinding permType, SourceTypeBinding type, ASTNode node, PackageBinding packageBinding) {
String permTypeName = new String(permType.sourceName);
String name = new String(type.sourceName());
String packageName = packageBinding.compoundName == CharOperation.NO_CHAR_CHAR ? "default" : //$NON-NLS-1$

Check warning on line 12358 in org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java

View check run for this annotation

Jenkins - Eclipse JDT / Compiler and API Tools

Potential Programming Problem

LOW: Dubious operand types for '==': char[][] and char[][] are references
CharOperation.toString(packageBinding.compoundName);
String[] arguments = new String[] {permTypeName, packageName, name};
this.handle(IProblem.SealedPermittedTypeOutsideOfPackage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@
210 = Syntax error on keyword "{0}", no accurate correction available
211 = Comparing identical expressions
212 = Type {0} cannot be safely cast to {1}

220 = Unmatched bracket
221 = The primitive type {0} of {1} does not have a field {2}
222 = Invalid expression as statement
Expand Down Expand Up @@ -908,6 +907,7 @@
# more programming problems:
1200 = Unlikely argument type {0} for {1} on a {2}
1201 = Unlikely argument type for equals(): {0} seems to be unrelated to {2}
1202 = Dubious operand types for '{0}': {1} and {2} are references

### Autoclosable try
1251 = Duplicate resource reference {0}
Expand Down Expand Up @@ -1179,8 +1179,7 @@
# Statements before Super
2022 = Cannot use {0} in a pre-construction context
2023 = {0} statement not allowed in prologue



### ELABORATIONS
## Access restrictions
78592 = The type ''{1}'' is not API (restriction on classpath entry ''{0}'')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
*/
public static boolean isJREVersionEqualTo(String compilerVersion) {
String specVersion = System.getProperty("java.specification.version");
return specVersion != null && Integer.valueOf(specVersion) == Integer.valueOf(compilerVersion);

Check warning on line 47 in org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractBatchCompilerTest.java

View check run for this annotation

Jenkins - Eclipse JDT / Compiler and API Tools

Potential Programming Problem

LOW: Dubious operand types for '==': java.lang.Integer and java.lang.Integer are references
}
/**
* Abstract normalizer for output comparison. This class merely embodies a
Expand Down Expand Up @@ -658,14 +658,16 @@
"Unexpected standard output for invocation with arguments ["
+ extraArguments + "]",
expectedOutOutputString,
outOutputString);
outputDirNormalizer
.normalized(outOutputString));
}
if (!errCompareOK) {
assertEquals(
"Unexpected error output for invocation with arguments ["
+ extraArguments + "]",
expectedErrOutputString,
errOutputString);
outputDirNormalizer
.normalized(errOutputString));
}
}

Expand Down Expand Up @@ -855,8 +857,8 @@
expected = expectedClasspathEntries[j++];
if (expected == null) {
assertNull(result.destinationPath);
} else if (expected == Main.NONE &&

Check warning on line 860 in org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractBatchCompilerTest.java

View check run for this annotation

Jenkins - Eclipse JDT / Compiler and API Tools

Potential Programming Problem

LOW: Dubious operand types for '==': java.lang.String and java.lang.String are references
result.destinationPath != Main.NONE) {

Check warning on line 861 in org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractBatchCompilerTest.java

View check run for this annotation

Jenkins - Eclipse JDT / Compiler and API Tools

Potential Programming Problem

LOW: Dubious operand types for '!=': java.lang.String and java.lang.String are references
fail("expected 'none' output directory");
} else if (! expected.equals(result.destinationPath)) {
System.out.println("\"" + result.destinationPath + "\"");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public AssignmentTest(String name) {
protected Map getCompilerOptions() {
Map options = super.getCompilerOptions();
options.put(CompilerOptions.OPTION_ReportDeadCode, CompilerOptions.IGNORE);
options.put(CompilerOptions.OPTION_ReportDubiousReferenceComparison, CompilerOptions.IGNORE);
options.put(CompilerOptions.OPTION_ReportNullReference, CompilerOptions.ERROR);
options.put(CompilerOptions.OPTION_ReportPotentialNullReference, CompilerOptions.ERROR);
options.put(CompilerOptions.OPTION_ReportRedundantNullCheck, CompilerOptions.ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public AutoBoxingTest(String name) {
protected Map getCompilerOptions() {
Map defaultOptions = super.getCompilerOptions();
defaultOptions.put(CompilerOptions.OPTION_ReportAutoboxing, CompilerOptions.WARNING);
defaultOptions.put(CompilerOptions.OPTION_ReportDubiousReferenceComparison, CompilerOptions.IGNORE);
return defaultOptions;
}

Expand Down
Loading
Loading