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

Renaming throw type and exception parameter err msg to incompatible #618

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions checker/tests/fenum/CatchFenumUnqualified.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ public class CatchFenumUnqualified {
void method() {
try {
} catch (
// :: error: (exception.parameter.invalid)
// :: error: (exception.parameter.incompatible)
@Fenum("A") RuntimeException e) {

}
try {
// :: error: (exception.parameter.invalid)
// :: error: (exception.parameter.incompatible)
} catch (@Fenum("A") NullPointerException | @Fenum("A") ArrayIndexOutOfBoundsException e) {

}
Expand Down
10 changes: 5 additions & 5 deletions checker/tests/guieffect/ThrowCatchTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ class Inner {}
// Type var test
<E extends @UI PolyUIException> void throwTypeVarUI1(E ex1, @UI E ex2) throws PolyUIException {
if (flag) {
// :: error: (throw.type.invalid)
// :: error: (throw.type.incompatible)
throw ex1;
}
// :: error: (throw.type.invalid)
// :: error: (throw.type.incompatible)
throw ex2;
}

<@UI E extends @UI PolyUIException> void throwTypeVarUI2(E ex1) throws PolyUIException {
// :: error: (throw.type.invalid)
// :: error: (throw.type.incompatible)
throw ex1;
}

Expand All @@ -48,7 +48,7 @@ class Inner {}
<@AlwaysSafe E extends @UI PolyUIException> void throwTypeVarMixed(E ex1, @AlwaysSafe E ex2)
throws PolyUIException {
if (flag) {
// :: error: (throw.type.invalid)
// :: error: (throw.type.incompatible)
throw ex1;
}
throw ex2;
Expand All @@ -75,7 +75,7 @@ void throwNull() {

void throwDeclared() {
try {
// :: error: (throw.type.invalid)
// :: error: (throw.type.incompatible)
throw ui;
} catch (@UI PolyUIException UIParam) {

Expand Down
2 changes: 1 addition & 1 deletion checker/tests/lock/TestTreeKinds.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ void testTreeTypes() {
// throwing a guarded object - when throwing an exception, it must be @GuardedBy({}). Even
// @GuardedByUnknown is not allowed.
try {
// :: error: (throw.type.invalid)
// :: error: (throw.type.incompatible)
throw exception;
} catch (Exception e) {
}
Expand Down
8 changes: 7 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ Version 3.42.0-eisop4 (April ?, 2024)

**User-visible changes:**

Replace two error message keys(current still supported in @suppressionwarning):
* `exception.parameter.invalid`
* `throw.type.invalid`
by new message keys:
* `exception.parameter.incompatible`
* `throw.type.incompatible`

**Implementation details:**

Improvements in `framework-test` to more consistently handle tests that do not use
Expand Down Expand Up @@ -115,7 +122,6 @@ in a future release.)

#1497, #3345, #6037, #6204, #6276, #6282, #6290, #6296, #6319, #6327.


Version 3.40.0-eisop2 (November 24, 2023)
-----------------------------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3068,7 +3068,8 @@ protected void checkExceptionParameter(CatchTree tree) {
AnnotationMirror found = excParamType.getAnnotationInHierarchy(required);
assert found != null;
if (!typeHierarchy.isSubtypeShallowEffective(required, excParamType)) {
checker.reportError(excParamTree, "exception.parameter.invalid", found, required);
checker.reportError(
excParamTree, "exception.parameter.incompatible", found, required);
}

if (excParamType.getKind() == TypeKind.UNION) {
Expand All @@ -3079,7 +3080,7 @@ protected void checkExceptionParameter(CatchTree tree) {
alternativeType.getAnnotationInHierarchy(required);
checker.reportError(
excParamTree,
"exception.parameter.invalid",
"exception.parameter.incompatible",
alternativeAnno,
required);
}
Expand Down Expand Up @@ -3131,7 +3132,7 @@ protected void checkThrownExpression(ThrowTree tree) {
if (!typeHierarchy.isSubtypeShallowEffective(throwType, required)) {
AnnotationMirrorSet found = throwType.getEffectiveAnnotations();
checker.reportError(
tree.getExpression(), "throw.type.invalid", found, required);
tree.getExpression(), "throw.type.incompatible", found, required);
}
break;

Expand All @@ -3140,15 +3141,18 @@ protected void checkThrownExpression(ThrowTree tree) {
AnnotationMirrorSet foundPrimary = unionType.getAnnotations();
if (!qualHierarchy.isSubtypeShallow(foundPrimary, required, throwTM)) {
checker.reportError(
tree.getExpression(), "throw.type.invalid", foundPrimary, required);
tree.getExpression(),
"throw.type.incompatible",
foundPrimary,
required);
}
for (AnnotatedTypeMirror altern : unionType.getAlternatives()) {
TypeMirror alternTM = altern.getUnderlyingType();
if (!qualHierarchy.isSubtypeShallow(
altern.getAnnotations(), required, alternTM)) {
checker.reportError(
tree.getExpression(),
"throw.type.invalid",
"throw.type.incompatible",
altern.getAnnotations(),
required);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ type.invalid.super.wildcard=bounds must have the same annotations.%nextends boun
cast.unsafe=cast from "%s" to "%s" cannot be statically verified
invariant.cast.unsafe=cannot cast from "%s" to "%s"
cast.unsafe.constructor.invocation=constructor invocation cast from "%s" to "%s" cannot be statically verified
exception.parameter.invalid=invalid type in catch argument.%nfound : %s%nrequired: %s
throw.type.invalid=invalid type thrown.%nfound : %s%nrequired: %s
exception.parameter.incompatible=incompatible type in catch argument.%nfound : %s%nrequired: %s
throw.type.incompatible=incompatible type thrown.%nfound : %s%nrequired: %s
expression.unparsable.type.invalid=Expression invalid in dependent type annotation: %s
explicit.annotation.ignored=The qualifier %s is ignored in favor of %s. Either delete %s or change it to %s.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2454,6 +2454,10 @@ private boolean shouldSuppress(

for (String currentSuppressWarningsInEffect : suppressWarningsInEffect) {
int colonPos = currentSuppressWarningsInEffect.indexOf(":");
if (currentSuppressWarningsInEffect.equals("throw.type.invalid"))
currentSuppressWarningsInEffect = "throw.type.incompatible";
if (currentSuppressWarningsInEffect.equals("exception.parameter.invalid"))
currentSuppressWarningsInEffect = "exception.parameter.incompatible";
String messageKeyInSuppressWarningsString;
if (colonPos == -1) {
// The SuppressWarnings string has no colon, so it is not of the form
Expand Down
2 changes: 1 addition & 1 deletion framework/tests/aliasing/CatchTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ void foo() {
// :: error: (unique.leaked)
throw exVar;

// :: error: (exception.parameter.invalid)
// :: error: (exception.parameter.incompatible)
} catch (@Unique Exception e) {
// exVar and e points to the same object, therefore catch clauses
// are not allowed to have a @Unique parameter.
Expand Down
2 changes: 1 addition & 1 deletion framework/tests/flowexpression/Standardize.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void variableDecls(@FlowExp("field") Standardize this, @FlowExp("field") Object
@FlowExp("field") Object o7 = in;
@FlowExp("this.field") Object o8 = in;
} catch (
@SuppressWarnings("exception.parameter.invalid")
@SuppressWarnings("exception.parameter.incompatible")
@FlowExp("field") Exception ex) {
@FlowExp("field") Object o9 = ex;
@FlowExp("this.field") Object o10 = ex;
Expand Down
4 changes: 2 additions & 2 deletions framework/tests/h1h2checker/Catch.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void explictlyTopUnionType() throws Throwable {
void explictlyNotTopUnionType() throws Throwable {
try {
throw new Throwable();
// :: error: (exception.parameter.invalid)
// :: error: (exception.parameter.incompatible)
} catch (@H1S1 @H2Top IndexOutOfBoundsException | @H1S1 @H2Top NullPointerException ex) {

}
Expand All @@ -45,7 +45,7 @@ void explictlyTopDeclaredType() throws Throwable {
void explictlyNotTopDeclaredType() throws Throwable {
try {
throw new Throwable();
// :: error: (exception.parameter.invalid)
// :: error: (exception.parameter.incompatible)
} catch (@H1S1 @H2Top RuntimeException ex) {

}
Expand Down
Loading