< prev index next > test/langtools/tools/javac/classfiles/attributes/innerclasses/InnerClassesTestBase.java
Print this page
/*
- * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2025, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
StringBuilder sb = new StringBuilder();
sb.append("public class InnerClassesSrc {")
.append(toString(outerMod)).append(' ')
.append(outerClassType).append(' ')
.append(prefix).append(' ').append('\n');
+ if (outerClassType == ClassType.CLASS && outerMod.contains(Modifier.ABSTRACT))
+ sb.append("int f;\n"); // impose identity to make testing predicatable
int count = 0;
Map<String, Set<String>> class2Flags = new HashMap<>();
List<String> syntheticClasses = new ArrayList<>();
for (List<Modifier> innerMod : innerMods) {
++count;
String privateConstructor = "";
if (hasSyntheticClass && !innerMod.contains(Modifier.ABSTRACT)) {
privateConstructor = "private A" + count + "() {}";
syntheticClasses.add("new A" + count + "();");
}
+ String instField = innerClassType == ClassType.CLASS && innerMod.contains(Modifier.ABSTRACT) ?
+ "int f; " : ""; // impose identity to make testing predicatable
sb.append(toString(innerMod)).append(' ');
- sb.append(String.format("%s A%d {%s}\n", innerClassType, count, privateConstructor));
+ sb.append(String.format("%s A%d { %s %s}\n", innerClassType, count, instField, privateConstructor));
Set<String> flags = getFlags(innerClassType, innerMod);
class2Flags.put("A" + count, flags);
}
if (hasSyntheticClass) {
// Source to generate synthetic classes
type.addSpecificFlags(flags);
return flags;
}
protected List<String> getCompileOptions() {
- return Collections.emptyList();
+ // Use a release before value classes for now.
+ return List.of("--release", "25");
}
private List<List<Modifier>> getAllCombinations(Modifier[] accessModifiers, Modifier[] otherModifiers) {
List<List<Modifier>> list = new ArrayList<>();
for (Modifier access : accessModifiers) {
public enum Modifier {
PUBLIC("public"), PRIVATE("private"),
PROTECTED("protected"), DEFAULT("default"),
FINAL("final"), ABSTRACT("abstract"),
- STATIC("static"), EMPTY("");
+ STATIC("static"), EMPTY(""),
+ IDENTITY("identity");
private final String str;
Modifier(String str) {
this.str = str;
< prev index next >