Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManoj Palat2020-08-14 06:50:37 +0000
committerManoj Palat2020-08-14 06:50:37 +0000
commit7a1b357d9a108bbb81939ab1fab7ec689a126c9f (patch)
treead546abf9114ca5d6da377f6b8a8c68f215c9e9b
parent2718f4861eb3702ce5f77ac30c337e89b1d86efa (diff)
parente5e0eecd92d4e497573f4df8043c4ac92e394ad1 (diff)
downloadeclipse.jdt.core-Y20200814-0650.tar.gz
eclipse.jdt.core-Y20200814-0650.tar.xz
eclipse.jdt.core-Y20200814-0650.zip
Merge branch 'master' into BETA_JAVA15Y20200814-0650Y20200814-0630
# Conflicts: # org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordsRestrictedClassTest.java Change-Id: I5831b25dfd4bbeedd8ab04576daf6c0f219a6dc6
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordsRestrictedClassTest.java24
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/NestedTypeBinding.java5
2 files changed, 29 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordsRestrictedClassTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordsRestrictedClassTest.java
index 077785c9a0..9e77fc5888 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordsRestrictedClassTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordsRestrictedClassTest.java
@@ -7597,4 +7597,28 @@ public void testBug563182_07() {
},
"java.lang.Record");
}
+public void testBug565830_01() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " void bar() throws Exception {\n"+
+ " record Bar(int x) implements java.io.Serializable {\n"+
+ " void printMyFields() {\n"+
+ " for (var field : this.getClass().getDeclaredFields()) {\n"+
+ " System.out.println(field);\n"+
+ " }\n"+
+ " }\n"+
+ " }\n"+
+ " var bar = new Bar(1);\n"+
+ " bar.printMyFields();\n"+
+ " new java.io.ObjectOutputStream(java.io.OutputStream.nullOutputStream()).writeObject(bar);\n"+
+ " }\n"+
+ " public static void main(String[] args) throws Exception {\n"+
+ " new X().bar();\n"+
+ " }\n"+
+ "}",
+ },
+ "private final int X$1Bar.x");
}
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/NestedTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/NestedTypeBinding.java
index 529574f0d0..90f7a9beef 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/NestedTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/NestedTypeBinding.java
@@ -77,9 +77,14 @@ public SyntheticArgumentBinding addSyntheticArgument(LocalVariableBinding actual
/* Add a new synthetic argument for <enclosingType>.
* Answer the new argument or the existing argument if one already existed.
+* Do not add if this is static (eg. nested records)
*/
public SyntheticArgumentBinding addSyntheticArgument(ReferenceBinding targetEnclosingType) {
if (!isPrototype()) throw new IllegalStateException();
+ if (isStatic()) {
+ assert this.isRecord();// a local record is implicitly static; no other local type can be static
+ return null;
+ }
SyntheticArgumentBinding synthLocal = null;
if (this.enclosingInstances == null) {
synthLocal = new SyntheticArgumentBinding(targetEnclosingType);

Back to the top