Merge
This commit is contained in:
commit
e6875c9bac
@ -2907,10 +2907,9 @@ public class Check {
|
||||
*/
|
||||
private void validateAnnotation(JCAnnotation a, JCTree declarationTree, Symbol s) {
|
||||
validateAnnotationTree(a);
|
||||
boolean isRecordMember = (s.flags_field & RECORD) != 0 || s.enclClass() != null && s.enclClass().isRecord();
|
||||
boolean isRecordMember = ((s.flags_field & RECORD) != 0 || s.enclClass() != null && s.enclClass().isRecord());
|
||||
|
||||
boolean isRecordField = isRecordMember &&
|
||||
(s.flags_field & (Flags.PRIVATE | Flags.FINAL | Flags.GENERATED_MEMBER | Flags.RECORD)) != 0 &&
|
||||
boolean isRecordField = (s.flags_field & RECORD) != 0 &&
|
||||
declarationTree.hasTag(VARDEF) &&
|
||||
s.owner.kind == TYP;
|
||||
|
||||
|
@ -1563,4 +1563,37 @@ public class RecordCompilationTests extends CompilationTestCase {
|
||||
"""
|
||||
);
|
||||
}
|
||||
|
||||
public void testNoNPEStaticAnnotatedFields() {
|
||||
assertOK(
|
||||
"""
|
||||
import java.lang.annotation.Native;
|
||||
record R() {
|
||||
@Native public static final int i = 0;
|
||||
}
|
||||
"""
|
||||
);
|
||||
assertOK(
|
||||
"""
|
||||
import java.lang.annotation.Native;
|
||||
class Outer {
|
||||
record R() {
|
||||
@Native public static final int i = 0;
|
||||
}
|
||||
}
|
||||
"""
|
||||
);
|
||||
assertOK(
|
||||
"""
|
||||
import java.lang.annotation.Native;
|
||||
class Outer {
|
||||
void m() {
|
||||
record R () {
|
||||
@Native public static final int i = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user