Skip to content
Permalink
Browse files

8236841: compact constructor parameters are always final

Reviewed-by: mcimadamore
  • Loading branch information
Vicente Romero
Vicente Romero committed Jan 10, 2020
1 parent 2c7c802 commit 4692bc58eb05112c121b2fa697e08b3c3e1df02b
@@ -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 {}");

0 comments on commit 4692bc5

Please sign in to comment.