Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
8236841: compact constructor parameters are always final
- Loading branch information
|
|
@@ -1,5 +1,5 @@ |
|
|
/* |
|
|
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. |
|
|
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. |
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
|
* |
|
|
* This code is free software; you can redistribute it and/or modify it |
|
@@ -3746,7 +3746,7 @@ protected JCClassDecl recordDeclaration(JCModifiers mods, Comment dc) { |
|
|
ListBuffer<JCVariableDecl> tmpParams = new ListBuffer<>(); |
|
|
for (JCVariableDecl param : headerFields) { |
|
|
tmpParams.add(F.at(param) |
|
|
.VarDef(F.Modifiers(Flags.PARAMETER | param.mods.flags & Flags.VARARGS | param.mods.flags & Flags.FINAL), |
|
|
.VarDef(F.Modifiers(Flags.PARAMETER | param.mods.flags & Flags.VARARGS), |
|
|
param.name, param.vartype, null)); |
|
|
} |
|
|
methDef.params = tmpParams.toList(); |
|
|
|
@@ -429,6 +429,17 @@ public void testReturnInCanonical_Compact() { |
|
|
assertOK("record R(int x) { public R { Runnable r = () -> { return; };} }"); |
|
|
} |
|
|
|
|
|
public void testArgumentsAreNotFinalInCompact() { |
|
|
assertOK( |
|
|
""" |
|
|
record R(int x) { |
|
|
public R { |
|
|
x++; |
|
|
} |
|
|
} |
|
|
"""); |
|
|
} |
|
|
|
|
|
public void testNoNativeMethods() { |
|
|
assertFail("compiler.err.mod.not.allowed.here", "record R(int x) { # }", |
|
|
"public native R {}"); |
|
|