changeset 49712:90609e9cd9f4 datum

records must be final
author vromero
date Fri, 06 Apr 2018 14:50:20 -0400
parents e454ab8936ba
children 81ce218e677e
files src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java test/langtools/tools/javac/datum/RecordsMustBeStaticTest.java
diffstat 2 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Fri Apr 06 14:34:19 2018 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java	Fri Apr 06 14:50:20 2018 -0400
@@ -3521,7 +3521,7 @@
     protected JCClassDecl recordDeclaration(JCModifiers mods, Comment dc) {
         int pos = token.pos;
         nextToken();
-        mods.flags |= Flags.RECORD | Flags.STATIC;
+        mods.flags |= Flags.RECORD | Flags.STATIC | Flags.FINAL;
         Name name = typeName();
 
         List<JCTypeParameter> typarams = typeParametersOpt();
--- a/test/langtools/tools/javac/datum/RecordsMustBeStaticTest.java	Fri Apr 06 14:34:19 2018 -0400
+++ b/test/langtools/tools/javac/datum/RecordsMustBeStaticTest.java	Fri Apr 06 14:50:20 2018 -0400
@@ -84,7 +84,7 @@
         Assert.check(elements.iterator().hasNext());
         dprinter.treeTypes(true).printTree("", (JCTree)elements.iterator().next());
         String output = strOut.toString();
-        Assert.check(output.contains("flags: [static, record]"), "nested records should be static");
+        Assert.check(output.contains("flags: [static, final, record]"), "nested records should be static and final");
     }
 
     static final String source1 =