Skip to content

Only clean when the annotated type mirror is type variable#787

Closed
aosen-xiong wants to merge 4 commits into
eisop:masterfrom
aosen-xiong:clearAnnotation-only-typevar
Closed

Only clean when the annotated type mirror is type variable#787
aosen-xiong wants to merge 4 commits into
eisop:masterfrom
aosen-xiong:clearAnnotation-only-typevar

Conversation

@aosen-xiong

Copy link
Copy Markdown
Collaborator

Fixes #786

@wmdietl wmdietl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add the test case from the issue?
Can you make that test case self-contained, so that it doesn't depend on the CF classes?

NoExplicitAnnotationsSub2 sub2,
NoExplicitAnnotationsSub3 sub3) {
nble = sub1.method1();
// :: error: (assignment.type.incompatible)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you provide a reason why this new error is desirable? Why is this change in behavior an improvement?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also note that a wilcard jtreg test fails.

@aosen-xiong aosen-xiong Jun 21, 2024

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Can you provide a reason why this new error is desirable? Why is this change in behavior an improvement?

Because nn is @Nonnull and method1() is @Nullable. So there should be an assignment incompatiable error.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

But method1 is in the stub file without annotations.
Shouldn't the logic be that, if something appears in the stub-file, those annotations are used. If there are no annotations in the stub-file, the usual defaults are used.
That's at least what the current behavior seems to be. This makes the stub-files readable and understandable without looking at what the corresponding source says.

@aosen-xiong

aosen-xiong commented Jun 21, 2024

Copy link
Copy Markdown
Collaborator Author

Can you add the test case from the issue? Can you make that test case self-contained, so that it doesn't depend on the CF classes?

Simplified version. Also updated in the issue.

import javax.lang.model.element.TypeElement;

public class Test {
    void test(TypeElement element) {
        element.asType();
    }
}

@aosen-xiong

Copy link
Copy Markdown
Collaborator Author

Interesting. This crash does not happen under java 17 and happens under Java 8 and Java 11.

@wmdietl

wmdietl commented Jun 21, 2024

Copy link
Copy Markdown
Member

Simplified version. Also updated in the issue.

It would be nicer if you just had a class in the test case instead of depending on TypeElement#asType. Now to understand the test, one has to look at the annotated JDK and try to see what annotations are on that method.

@wmdietl

wmdietl commented Jun 21, 2024

Copy link
Copy Markdown
Member

Simplified version. Also updated in the issue.

It would be nicer if you just had a class in the test case instead of depending on TypeElement#asType. Now to understand the test, one has to look at the annotated JDK and try to see what annotations are on that method.

You only updated the test in the issue. You should add test cases to this PR to ensure the issue is actually fixed.

@aosen-xiong

Copy link
Copy Markdown
Collaborator Author

Simplified version. Also updated in the issue.

It would be nicer if you just had a class in the test case instead of depending on TypeElement#asType. Now to understand the test, one has to look at the annotated JDK and try to see what annotations are on that method.

You only updated the test in the issue. You should add test cases to this PR to ensure the issue is actually fixed.

Okay, I will add it as I find the minial test case without TypeElement#asType dependency.

@aosen-xiong

Copy link
Copy Markdown
Collaborator Author

Superseded by PR #1810, I did not realize this draft PR when I opened the new one; closing this PR.

@aosen-xiong aosen-xiong deleted the clearAnnotation-only-typevar branch June 16, 2026 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unexpected null argument when doing VPA

2 participants