Skip to content
Permalink
Browse files

Automatic merge of jdk:master into master

  • Loading branch information
duke committed Jul 24, 2020
2 parents 1e6d4c4 + 75d642a commit 599cc076d068b9616b874b55fc5b0462e17f9c05
@@ -2907,10 +2907,9 @@ public void validateTypeAnnotations(List<JCAnnotation> annotations, boolean isTy
*/
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 @@ record R(int i) {
"""
);
}

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;
}
}
}
"""
);
}
}

0 comments on commit 599cc07

Please sign in to comment.