From 6359ee656167bba25dfc632d004bc018082259cf Mon Sep 17 00:00:00 2001 From: Alexander Weigl Date: Wed, 11 Mar 2026 20:06:53 +0100 Subject: [PATCH 1/8] support for java records by code transformation --- .../java/transformations/KeYJavaPipeline.java | 1 + .../pipeline/RecordClassBuilder.java | 150 ++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/RecordClassBuilder.java diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/KeYJavaPipeline.java b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/KeYJavaPipeline.java index da9dff5027..c2555a315d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/KeYJavaPipeline.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/KeYJavaPipeline.java @@ -39,6 +39,7 @@ public List getSteps() { public static KeYJavaPipeline createDefault(TransformationPipelineServices pipelineServices) { KeYJavaPipeline p = new KeYJavaPipeline(pipelineServices); p.add(new EnumClassBuilder(pipelineServices)); + p.add(new RecordClassBuilder(pipelineServices)); p.add(new JMLTransformer(pipelineServices)); p.add(new JmlDocRemoval(pipelineServices)); p.add(new ImplicitFieldAdder(pipelineServices)); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/RecordClassBuilder.java b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/RecordClassBuilder.java new file mode 100644 index 0000000000..cf485ea5b0 --- /dev/null +++ b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/RecordClassBuilder.java @@ -0,0 +1,150 @@ +/* This file is part of KeY - https://key-project.org + * KeY is licensed under the GNU General Public License Version 2 + * SPDX-License-Identifier: GPL-2.0-only */ +package de.uka.ilkd.key.java.transformations.pipeline; + +import com.github.javaparser.StaticJavaParser; +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.NodeList; +import com.github.javaparser.ast.body.*; +import com.github.javaparser.ast.expr.*; +import com.github.javaparser.ast.nodeTypes.NodeWithSimpleName; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.stmt.ReturnStmt; +import com.github.javaparser.ast.type.Type; + +import javax.annotation.processing.Generated; + +import java.util.Arrays; +import java.util.List; + +import static com.github.javaparser.ast.Modifier.DefaultKeyword.*; + +/// This transformation is made to transform any found [RecordDeclaration] into a corresponding +/// [ClassOrInterfaceDeclaration]. +/// +/// @author weigl +/// @since 2026-03-11 +public class RecordClassBuilder extends JavaTransformer { + public RecordClassBuilder(TransformationPipelineServices pipelineServices) { + super(pipelineServices); + } + + @Override + public void apply(CompilationUnit cu) { + System.out.println(cu); + cu.walk(RecordDeclaration.class, it -> { + ClassOrInterfaceDeclaration clazz = transform(it); + it.replace(clazz); + }); + } + + private ClassOrInterfaceDeclaration transform(RecordDeclaration recordDeclaration) { + ClassOrInterfaceDeclaration clazz = new ClassOrInterfaceDeclaration(); + clazz.setModifiers(recordDeclaration.getModifiers()); + clazz.addModifier(FINAL); + clazz.setName(recordDeclaration.getName()); + + clazz.addExtendedType(java.lang.Record.class); + + clazz.addAnnotation(Generated.class); + + for (Parameter parameter : recordDeclaration.getParameters()) { + FieldDeclaration field = clazz.addField(parameter.type(), parameter.getNameAsString(), PRIVATE, FINAL); + field.getModifiers().addAll(parameter.getModifiers()); + + MethodDeclaration getter = clazz.addMethod(parameter.getNameAsString()); + getter.setType(parameter.type()); + getter.addModifier(PUBLIC, FINAL); + } + + // TODO generate equals and hashcode + boolean hasNoEquals = recordDeclaration.getMethodsBySignature("equals", "java.lang.Object").isEmpty(); + boolean hasNoHashcode = recordDeclaration.getMethodsBySignature("hashCode").isEmpty(); + + if (hasNoEquals) { + MethodDeclaration equals = clazz.addMethod("hashCode", PUBLIC, FINAL); + equals.addAnnotation(Override.class); + equals.setType(Boolean.TYPE); + Type tObject = StaticJavaParser.parseType("java.lang.Object"); + equals.getParameters().add(new Parameter(tObject, "o")); + BlockStmt body = equals.getBody().get(); + body.addStatement("if(this == other) return true;"); + body.addStatement("if(!(o instanceof %s that)) return false;".formatted(clazz.getNameAsString())); + + Expression equalFields = recordDeclaration.getParameters().stream() + .map(it -> callObjects("equals", it.getNameAsExpression(), + new FieldAccessExpr(new NameExpr("o"), it.getNameAsString()))) + .reduce((a, b) -> new BinaryExpr(a, b, BinaryExpr.Operator.AND)) + .orElse(new BooleanLiteralExpr(true)); + body.addStatement(new ReturnStmt(equalFields)); + + body.addStatement("return true"); + } + + if (hasNoHashcode) { + MethodDeclaration hashCode = clazz.addMethod("hashCode", PUBLIC, FINAL); + hashCode.addAnnotation(Override.class); + hashCode.setType(Integer.TYPE); + List args = recordDeclaration.getParameters() + .stream().map(NodeWithSimpleName::getNameAsExpression) + .map(it -> (Expression) it) + .toList(); + final Expression call = callObjects("hash", args); + hashCode.getBody().get() + .addStatement(new ReturnStmt(call)); + } + + // TODO generate to String + boolean hasNoToString = recordDeclaration.getMethodsBySignature("toString").isEmpty(); + if (hasNoToString) { + MethodDeclaration toString = clazz.addMethod("toString", PUBLIC, FINAL, JML_NON_NULL); + toString.addAnnotation(Override.class); + toString.setType(String.class); + ConcatBuilder concatBuilder = new ConcatBuilder(); + concatBuilder.addStr(clazz.getNameAsString() + "["); + for (Parameter parameter : recordDeclaration.getParameters()) { + concatBuilder.addStr(parameter.getNameAsString() + "="); + concatBuilder.addVar(parameter.getNameAsString()); + concatBuilder.addStr(","); + } + concatBuilder.addStr("]"); + toString.getBody().get().addStatement(new ReturnStmt(concatBuilder.expr)); + } + + + clazz.getMembers().addAll(recordDeclaration.getMembers()); + return clazz; + } + + private Expression callObjects(String method, Expression... exprs) { + return callObjects(method, Arrays.stream(exprs).toList()); + } + + private Expression callObjects(String method, List exprs) { + var objects = new FieldAccessExpr(new FieldAccessExpr(new NameExpr("java"), "lang"), "Objects"); + return new MethodCallExpr(objects, method, new NodeList<>(exprs)); + } + + private static final class ConcatBuilder { + public Expression expr = null; + + + public ConcatBuilder addStr(String s) { + return concat(new StringLiteralExpr(s)); + } + + private ConcatBuilder concat(com.github.javaparser.ast.expr.Expression expr) { + if (this.expr == null) { + this.expr = expr; + } else { + this.expr = new BinaryExpr(this.expr, expr, BinaryExpr.Operator.PLUS); + } + return this; + } + + public ConcatBuilder addVar(String s) { + return concat(new NameExpr(s)); + } + } +} From 5c6e1190f4cd6afe98b4cd6c40b65c30886a6659 Mon Sep 17 00:00:00 2001 From: Alexander Weigl Date: Thu, 19 Mar 2026 09:04:53 +0100 Subject: [PATCH 2/8] adding tests --- .../CompactConstructor.java | 8 + .../01_EnumClassBuilder/InnerRecord.java | 5 + .../01_EnumClassBuilder/NotAllowed.java | 36 +++ .../RecordOverwriting.java | 14 + .../01_EnumClassBuilder/SimpleRecord.java | 6 + .../CompactConstructor.java | 41 +++ .../02_RecordClassBuilder/InnerRecord.java | 32 ++ .../02_RecordClassBuilder/NotAllowed.java | 93 ++++++ .../RecordOverwriting.java | 36 +++ .../02_RecordClassBuilder/SimpleRecord.java | 33 ++ .../03_JMLTransformer/CompactConstructor.java | 41 +++ .../03_JMLTransformer/InnerRecord.java | 32 ++ .../03_JMLTransformer/NotAllowed.java | 93 ++++++ .../03_JMLTransformer/RecordOverwriting.java | 36 +++ .../03_JMLTransformer/SimpleRecord.java | 33 ++ .../04_JmlDocRemoval/CompactConstructor.java | 41 +++ .../04_JmlDocRemoval/InnerRecord.java | 32 ++ .../expected/04_JmlDocRemoval/NotAllowed.java | 93 ++++++ .../04_JmlDocRemoval/RecordOverwriting.java | 36 +++ .../04_JmlDocRemoval/SimpleRecord.java | 33 ++ .../CompactConstructor.java | 59 ++++ .../05_ImplicitFieldAdder/InnerRecord.java | 70 ++++ .../05_ImplicitFieldAdder/NotAllowed.java | 129 ++++++++ .../RecordOverwriting.java | 54 ++++ .../05_ImplicitFieldAdder/SimpleRecord.java | 51 +++ .../CompactConstructor.java | 61 ++++ .../InnerRecord.java | 74 +++++ .../NotAllowed.java | 134 ++++++++ .../RecordOverwriting.java | 56 ++++ .../SimpleRecord.java | 53 ++++ .../CompactConstructor.java | 69 ++++ .../InnerRecord.java | 91 ++++++ .../NotAllowed.java | 154 +++++++++ .../RecordOverwriting.java | 64 ++++ .../SimpleRecord.java | 58 ++++ .../CompactConstructor.java | 72 +++++ .../InnerRecord.java | 97 ++++++ .../NotAllowed.java | 160 ++++++++++ .../RecordOverwriting.java | 67 ++++ .../SimpleRecord.java | 61 ++++ .../CompactConstructor.java | 110 +++++++ .../InnerRecord.java | 173 ++++++++++ .../NotAllowed.java | 236 ++++++++++++++ .../RecordOverwriting.java | 105 ++++++ .../SimpleRecord.java | 99 ++++++ .../CompactConstructor.java | 126 ++++++++ .../10_PrepareObjectBuilder/InnerRecord.java | 197 ++++++++++++ .../10_PrepareObjectBuilder/NotAllowed.java | 264 ++++++++++++++++ .../RecordOverwriting.java | 117 +++++++ .../10_PrepareObjectBuilder/SimpleRecord.java | 111 +++++++ .../11_CreateBuilder/CompactConstructor.java | 133 ++++++++ .../11_CreateBuilder/InnerRecord.java | 211 +++++++++++++ .../expected/11_CreateBuilder/NotAllowed.java | 278 ++++++++++++++++ .../11_CreateBuilder/RecordOverwriting.java | 124 ++++++++ .../11_CreateBuilder/SimpleRecord.java | 118 +++++++ .../CompactConstructor.java | 141 +++++++++ .../12_CreateObjectBuilder/InnerRecord.java | 227 +++++++++++++ .../12_CreateObjectBuilder/NotAllowed.java | 298 ++++++++++++++++++ .../RecordOverwriting.java | 132 ++++++++ .../12_CreateObjectBuilder/SimpleRecord.java | 126 ++++++++ .../CompactConstructor.java | 141 +++++++++ .../InnerRecord.java | 227 +++++++++++++ .../NotAllowed.java | 298 ++++++++++++++++++ .../RecordOverwriting.java | 132 ++++++++ .../SimpleRecord.java | 126 ++++++++ .../CompactConstructor.java | 141 +++++++++ .../InnerRecord.java | 227 +++++++++++++ .../NotAllowed.java | 298 ++++++++++++++++++ .../RecordOverwriting.java | 132 ++++++++ .../SimpleRecord.java | 126 ++++++++ .../records/input/CompactConstructor.java | 7 + .../records/input/InnerRecord.java | 3 + .../records/input/NotAllowed.java | 33 ++ .../records/input/RecordOverwriting.java | 13 + .../records/input/SimpleRecord.java | 7 + .../java/de/uka/ilkd/key/java/Position.java | 5 +- .../key/java/loader/JavaParserFactory.java | 1 - .../pipeline/RecordClassBuilder.java | 20 +- .../TransformationPipelineServices.java | 4 + .../java/de/uka/ilkd/key/parser/Location.java | 3 +- .../uka/ilkd/key/parser/ParserException.java | 2 +- .../key/java/JavaRedux/java/lang/Objects.java | 11 + .../key/java/JavaRedux/java/lang/Record.java | 177 +++++++++++ .../src/test/java/KeyJavaPipelineTest.java | 73 +++-- 84 files changed, 7892 insertions(+), 49 deletions(-) create mode 100644 key.core/pipelineTests/records/expected/01_EnumClassBuilder/CompactConstructor.java create mode 100644 key.core/pipelineTests/records/expected/01_EnumClassBuilder/InnerRecord.java create mode 100644 key.core/pipelineTests/records/expected/01_EnumClassBuilder/NotAllowed.java create mode 100644 key.core/pipelineTests/records/expected/01_EnumClassBuilder/RecordOverwriting.java create mode 100644 key.core/pipelineTests/records/expected/01_EnumClassBuilder/SimpleRecord.java create mode 100644 key.core/pipelineTests/records/expected/02_RecordClassBuilder/CompactConstructor.java create mode 100644 key.core/pipelineTests/records/expected/02_RecordClassBuilder/InnerRecord.java create mode 100644 key.core/pipelineTests/records/expected/02_RecordClassBuilder/NotAllowed.java create mode 100644 key.core/pipelineTests/records/expected/02_RecordClassBuilder/RecordOverwriting.java create mode 100644 key.core/pipelineTests/records/expected/02_RecordClassBuilder/SimpleRecord.java create mode 100644 key.core/pipelineTests/records/expected/03_JMLTransformer/CompactConstructor.java create mode 100644 key.core/pipelineTests/records/expected/03_JMLTransformer/InnerRecord.java create mode 100644 key.core/pipelineTests/records/expected/03_JMLTransformer/NotAllowed.java create mode 100644 key.core/pipelineTests/records/expected/03_JMLTransformer/RecordOverwriting.java create mode 100644 key.core/pipelineTests/records/expected/03_JMLTransformer/SimpleRecord.java create mode 100644 key.core/pipelineTests/records/expected/04_JmlDocRemoval/CompactConstructor.java create mode 100644 key.core/pipelineTests/records/expected/04_JmlDocRemoval/InnerRecord.java create mode 100644 key.core/pipelineTests/records/expected/04_JmlDocRemoval/NotAllowed.java create mode 100644 key.core/pipelineTests/records/expected/04_JmlDocRemoval/RecordOverwriting.java create mode 100644 key.core/pipelineTests/records/expected/04_JmlDocRemoval/SimpleRecord.java create mode 100644 key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/CompactConstructor.java create mode 100644 key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/InnerRecord.java create mode 100644 key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/NotAllowed.java create mode 100644 key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/RecordOverwriting.java create mode 100644 key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/SimpleRecord.java create mode 100644 key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/CompactConstructor.java create mode 100644 key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/InnerRecord.java create mode 100644 key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/NotAllowed.java create mode 100644 key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/RecordOverwriting.java create mode 100644 key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/SimpleRecord.java create mode 100644 key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/CompactConstructor.java create mode 100644 key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/InnerRecord.java create mode 100644 key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/NotAllowed.java create mode 100644 key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/RecordOverwriting.java create mode 100644 key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/SimpleRecord.java create mode 100644 key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/CompactConstructor.java create mode 100644 key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/InnerRecord.java create mode 100644 key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/NotAllowed.java create mode 100644 key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/RecordOverwriting.java create mode 100644 key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/SimpleRecord.java create mode 100644 key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/CompactConstructor.java create mode 100644 key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/InnerRecord.java create mode 100644 key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/NotAllowed.java create mode 100644 key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/RecordOverwriting.java create mode 100644 key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/SimpleRecord.java create mode 100644 key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/CompactConstructor.java create mode 100644 key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/InnerRecord.java create mode 100644 key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/NotAllowed.java create mode 100644 key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/RecordOverwriting.java create mode 100644 key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/SimpleRecord.java create mode 100644 key.core/pipelineTests/records/expected/11_CreateBuilder/CompactConstructor.java create mode 100644 key.core/pipelineTests/records/expected/11_CreateBuilder/InnerRecord.java create mode 100644 key.core/pipelineTests/records/expected/11_CreateBuilder/NotAllowed.java create mode 100644 key.core/pipelineTests/records/expected/11_CreateBuilder/RecordOverwriting.java create mode 100644 key.core/pipelineTests/records/expected/11_CreateBuilder/SimpleRecord.java create mode 100644 key.core/pipelineTests/records/expected/12_CreateObjectBuilder/CompactConstructor.java create mode 100644 key.core/pipelineTests/records/expected/12_CreateObjectBuilder/InnerRecord.java create mode 100644 key.core/pipelineTests/records/expected/12_CreateObjectBuilder/NotAllowed.java create mode 100644 key.core/pipelineTests/records/expected/12_CreateObjectBuilder/RecordOverwriting.java create mode 100644 key.core/pipelineTests/records/expected/12_CreateObjectBuilder/SimpleRecord.java create mode 100644 key.core/pipelineTests/records/expected/13_LocalClassTransformation/CompactConstructor.java create mode 100644 key.core/pipelineTests/records/expected/13_LocalClassTransformation/InnerRecord.java create mode 100644 key.core/pipelineTests/records/expected/13_LocalClassTransformation/NotAllowed.java create mode 100644 key.core/pipelineTests/records/expected/13_LocalClassTransformation/RecordOverwriting.java create mode 100644 key.core/pipelineTests/records/expected/13_LocalClassTransformation/SimpleRecord.java create mode 100644 key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/CompactConstructor.java create mode 100644 key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/InnerRecord.java create mode 100644 key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/NotAllowed.java create mode 100644 key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/RecordOverwriting.java create mode 100644 key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/SimpleRecord.java create mode 100644 key.core/pipelineTests/records/input/CompactConstructor.java create mode 100644 key.core/pipelineTests/records/input/InnerRecord.java create mode 100644 key.core/pipelineTests/records/input/NotAllowed.java create mode 100644 key.core/pipelineTests/records/input/RecordOverwriting.java create mode 100644 key.core/pipelineTests/records/input/SimpleRecord.java create mode 100644 key.core/src/main/resources/de/uka/ilkd/key/java/JavaRedux/java/lang/Objects.java create mode 100644 key.core/src/main/resources/de/uka/ilkd/key/java/JavaRedux/java/lang/Record.java diff --git a/key.core/pipelineTests/records/expected/01_EnumClassBuilder/CompactConstructor.java b/key.core/pipelineTests/records/expected/01_EnumClassBuilder/CompactConstructor.java new file mode 100644 index 0000000000..7875031d11 --- /dev/null +++ b/key.core/pipelineTests/records/expected/01_EnumClassBuilder/CompactConstructor.java @@ -0,0 +1,8 @@ +record Mapping(String from, String to) { + + Mapping { + // compact constructor! + from = "abc"; + to = "def"; + } +} diff --git a/key.core/pipelineTests/records/expected/01_EnumClassBuilder/InnerRecord.java b/key.core/pipelineTests/records/expected/01_EnumClassBuilder/InnerRecord.java new file mode 100644 index 0000000000..b610cfc529 --- /dev/null +++ b/key.core/pipelineTests/records/expected/01_EnumClassBuilder/InnerRecord.java @@ -0,0 +1,5 @@ +class OuterClass { + + final record MyRecord(String test) { + } +} diff --git a/key.core/pipelineTests/records/expected/01_EnumClassBuilder/NotAllowed.java b/key.core/pipelineTests/records/expected/01_EnumClassBuilder/NotAllowed.java new file mode 100644 index 0000000000..5941911ccf --- /dev/null +++ b/key.core/pipelineTests/records/expected/01_EnumClassBuilder/NotAllowed.java @@ -0,0 +1,36 @@ +//https://mikemybytes.com/2022/02/16/java-records-and-compact-constructors/ +record // package-private +Name(// package-private +String name) { + + // fails with: 'invalid canonical constructor in record Name + // (attempting to assign stronger access privileges; + // was package)' + private Name(String name) { + this.name = name; + } + + static Name of(String name) { + return new Name(name); + } +} + +record Point(int x, int y) { + + Point(int x, int y) { + // boring! + this.x = x; + this.y = y; + } + + Point(int x) { + // a bit weird... + // ... but perfectly fine for the compiler + this(x, 0); + } + + Point() { + // fails with: 'constructor is not canonical, so its first + // statement must invoke another constructor' + } +} diff --git a/key.core/pipelineTests/records/expected/01_EnumClassBuilder/RecordOverwriting.java b/key.core/pipelineTests/records/expected/01_EnumClassBuilder/RecordOverwriting.java new file mode 100644 index 0000000000..4cffbb2198 --- /dev/null +++ b/key.core/pipelineTests/records/expected/01_EnumClassBuilder/RecordOverwriting.java @@ -0,0 +1,14 @@ +record MyRecord(String test) { + + public int hashCode() { + return 0; + } + + public boolean equals(Object obj) { + return obj instanceof MyRecord; + } + + public String test() { + return ""; + } +} diff --git a/key.core/pipelineTests/records/expected/01_EnumClassBuilder/SimpleRecord.java b/key.core/pipelineTests/records/expected/01_EnumClassBuilder/SimpleRecord.java new file mode 100644 index 0000000000..72c63026da --- /dev/null +++ b/key.core/pipelineTests/records/expected/01_EnumClassBuilder/SimpleRecord.java @@ -0,0 +1,6 @@ +public record SimpleRecord(/*@ nullable */ String name) implements Serializable { + + SimpleRecord(String name) { + this.name = name; + } +} diff --git a/key.core/pipelineTests/records/expected/02_RecordClassBuilder/CompactConstructor.java b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/CompactConstructor.java new file mode 100644 index 0000000000..74cb97ebc0 --- /dev/null +++ b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/CompactConstructor.java @@ -0,0 +1,41 @@ +@Generated() +final class Mapping extends Record { + + private final String from; + + public final String from() { + return from; + } + + private final String to; + + public final String to() { + return to; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Mapping that)) + return false; + return java.lang.Objects.equals(from, o.from) && java.lang.Objects.equals(to, o.to); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(from, to); + } + + @Override() + public final non_null String toString() { + return "Mapping[" + "from=" + from + "," + "to=" + to + "," + "]"; + } + + Mapping { + // compact constructor! + from = "abc"; + to = "def"; + } +} diff --git a/key.core/pipelineTests/records/expected/02_RecordClassBuilder/InnerRecord.java b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/InnerRecord.java new file mode 100644 index 0000000000..89ef5cf296 --- /dev/null +++ b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/InnerRecord.java @@ -0,0 +1,32 @@ +class OuterClass { + + @Generated() + final class MyRecord extends Record { + + private final String test; + + public final String test() { + return test; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof MyRecord that)) + return false; + return java.lang.Objects.equals(test, o.test); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(test); + } + + @Override() + public final non_null String toString() { + return "MyRecord[" + "test=" + test + "," + "]"; + } + } +} diff --git a/key.core/pipelineTests/records/expected/02_RecordClassBuilder/NotAllowed.java b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/NotAllowed.java new file mode 100644 index 0000000000..37ed87d5e1 --- /dev/null +++ b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/NotAllowed.java @@ -0,0 +1,93 @@ +//https://mikemybytes.com/2022/02/16/java-records-and-compact-constructors/ +@Generated() +final class // package-private +Name extends Record { + + private final String name; + + public final String name() { + return name; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Name that)) + return false; + return java.lang.Objects.equals(name, o.name); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(name); + } + + @Override() + public final non_null String toString() { + return "Name[" + "name=" + name + "," + "]"; + } + + // was package)' + private Name(String name) { + this.name = name; + } + + static Name of(String name) { + return new Name(name); + } +} + +@Generated() +final class Point extends Record { + + private final int x; + + public final int x() { + return x; + } + + private final int y; + + public final int y() { + return y; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Point that)) + return false; + return java.lang.Objects.equals(x, o.x) && java.lang.Objects.equals(y, o.y); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(x, y); + } + + @Override() + public final non_null String toString() { + return "Point[" + "x=" + x + "," + "y=" + y + "," + "]"; + } + + Point(int x, int y) { + // boring! + this.x = x; + this.y = y; + } + + Point(int x) { + // a bit weird... + // ... but perfectly fine for the compiler + this(x, 0); + } + + Point() { + // fails with: 'constructor is not canonical, so its first + // statement must invoke another constructor' + } +} diff --git a/key.core/pipelineTests/records/expected/02_RecordClassBuilder/RecordOverwriting.java b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/RecordOverwriting.java new file mode 100644 index 0000000000..3a3143172f --- /dev/null +++ b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/RecordOverwriting.java @@ -0,0 +1,36 @@ +@Generated() +final class MyRecord extends Record { + + private final String test; + + public final String test() { + return test; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof MyRecord that)) + return false; + return java.lang.Objects.equals(test, o.test); + return true; + } + + @Override() + public final non_null String toString() { + return "MyRecord[" + "test=" + test + "," + "]"; + } + + public int hashCode() { + return 0; + } + + public boolean equals(Object obj) { + return obj instanceof MyRecord; + } + + public String test() { + return ""; + } +} diff --git a/key.core/pipelineTests/records/expected/02_RecordClassBuilder/SimpleRecord.java b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/SimpleRecord.java new file mode 100644 index 0000000000..06bbeb96c5 --- /dev/null +++ b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/SimpleRecord.java @@ -0,0 +1,33 @@ +@Generated() +public final class SimpleRecord extends Record { + + private final /*@ nullable */ String name; + + public final /*@ nullable */ String name() { + return name; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof SimpleRecord that)) + return false; + return java.lang.Objects.equals(name, o.name); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(name); + } + + @Override() + public final non_null String toString() { + return "SimpleRecord[" + "name=" + name + "," + "]"; + } + + SimpleRecord(String name) { + this.name = name; + } +} diff --git a/key.core/pipelineTests/records/expected/03_JMLTransformer/CompactConstructor.java b/key.core/pipelineTests/records/expected/03_JMLTransformer/CompactConstructor.java new file mode 100644 index 0000000000..74cb97ebc0 --- /dev/null +++ b/key.core/pipelineTests/records/expected/03_JMLTransformer/CompactConstructor.java @@ -0,0 +1,41 @@ +@Generated() +final class Mapping extends Record { + + private final String from; + + public final String from() { + return from; + } + + private final String to; + + public final String to() { + return to; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Mapping that)) + return false; + return java.lang.Objects.equals(from, o.from) && java.lang.Objects.equals(to, o.to); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(from, to); + } + + @Override() + public final non_null String toString() { + return "Mapping[" + "from=" + from + "," + "to=" + to + "," + "]"; + } + + Mapping { + // compact constructor! + from = "abc"; + to = "def"; + } +} diff --git a/key.core/pipelineTests/records/expected/03_JMLTransformer/InnerRecord.java b/key.core/pipelineTests/records/expected/03_JMLTransformer/InnerRecord.java new file mode 100644 index 0000000000..89ef5cf296 --- /dev/null +++ b/key.core/pipelineTests/records/expected/03_JMLTransformer/InnerRecord.java @@ -0,0 +1,32 @@ +class OuterClass { + + @Generated() + final class MyRecord extends Record { + + private final String test; + + public final String test() { + return test; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof MyRecord that)) + return false; + return java.lang.Objects.equals(test, o.test); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(test); + } + + @Override() + public final non_null String toString() { + return "MyRecord[" + "test=" + test + "," + "]"; + } + } +} diff --git a/key.core/pipelineTests/records/expected/03_JMLTransformer/NotAllowed.java b/key.core/pipelineTests/records/expected/03_JMLTransformer/NotAllowed.java new file mode 100644 index 0000000000..37ed87d5e1 --- /dev/null +++ b/key.core/pipelineTests/records/expected/03_JMLTransformer/NotAllowed.java @@ -0,0 +1,93 @@ +//https://mikemybytes.com/2022/02/16/java-records-and-compact-constructors/ +@Generated() +final class // package-private +Name extends Record { + + private final String name; + + public final String name() { + return name; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Name that)) + return false; + return java.lang.Objects.equals(name, o.name); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(name); + } + + @Override() + public final non_null String toString() { + return "Name[" + "name=" + name + "," + "]"; + } + + // was package)' + private Name(String name) { + this.name = name; + } + + static Name of(String name) { + return new Name(name); + } +} + +@Generated() +final class Point extends Record { + + private final int x; + + public final int x() { + return x; + } + + private final int y; + + public final int y() { + return y; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Point that)) + return false; + return java.lang.Objects.equals(x, o.x) && java.lang.Objects.equals(y, o.y); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(x, y); + } + + @Override() + public final non_null String toString() { + return "Point[" + "x=" + x + "," + "y=" + y + "," + "]"; + } + + Point(int x, int y) { + // boring! + this.x = x; + this.y = y; + } + + Point(int x) { + // a bit weird... + // ... but perfectly fine for the compiler + this(x, 0); + } + + Point() { + // fails with: 'constructor is not canonical, so its first + // statement must invoke another constructor' + } +} diff --git a/key.core/pipelineTests/records/expected/03_JMLTransformer/RecordOverwriting.java b/key.core/pipelineTests/records/expected/03_JMLTransformer/RecordOverwriting.java new file mode 100644 index 0000000000..3a3143172f --- /dev/null +++ b/key.core/pipelineTests/records/expected/03_JMLTransformer/RecordOverwriting.java @@ -0,0 +1,36 @@ +@Generated() +final class MyRecord extends Record { + + private final String test; + + public final String test() { + return test; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof MyRecord that)) + return false; + return java.lang.Objects.equals(test, o.test); + return true; + } + + @Override() + public final non_null String toString() { + return "MyRecord[" + "test=" + test + "," + "]"; + } + + public int hashCode() { + return 0; + } + + public boolean equals(Object obj) { + return obj instanceof MyRecord; + } + + public String test() { + return ""; + } +} diff --git a/key.core/pipelineTests/records/expected/03_JMLTransformer/SimpleRecord.java b/key.core/pipelineTests/records/expected/03_JMLTransformer/SimpleRecord.java new file mode 100644 index 0000000000..faa5353e03 --- /dev/null +++ b/key.core/pipelineTests/records/expected/03_JMLTransformer/SimpleRecord.java @@ -0,0 +1,33 @@ +@Generated() +public final class SimpleRecord extends Record { + + private final /*@ nullable */ nullable String name; + + public final /*@ nullable */ nullable String name() { + return name; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof SimpleRecord that)) + return false; + return java.lang.Objects.equals(name, o.name); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(name); + } + + @Override() + public final non_null String toString() { + return "SimpleRecord[" + "name=" + name + "," + "]"; + } + + SimpleRecord(String name) { + this.name = name; + } +} diff --git a/key.core/pipelineTests/records/expected/04_JmlDocRemoval/CompactConstructor.java b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/CompactConstructor.java new file mode 100644 index 0000000000..74cb97ebc0 --- /dev/null +++ b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/CompactConstructor.java @@ -0,0 +1,41 @@ +@Generated() +final class Mapping extends Record { + + private final String from; + + public final String from() { + return from; + } + + private final String to; + + public final String to() { + return to; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Mapping that)) + return false; + return java.lang.Objects.equals(from, o.from) && java.lang.Objects.equals(to, o.to); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(from, to); + } + + @Override() + public final non_null String toString() { + return "Mapping[" + "from=" + from + "," + "to=" + to + "," + "]"; + } + + Mapping { + // compact constructor! + from = "abc"; + to = "def"; + } +} diff --git a/key.core/pipelineTests/records/expected/04_JmlDocRemoval/InnerRecord.java b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/InnerRecord.java new file mode 100644 index 0000000000..89ef5cf296 --- /dev/null +++ b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/InnerRecord.java @@ -0,0 +1,32 @@ +class OuterClass { + + @Generated() + final class MyRecord extends Record { + + private final String test; + + public final String test() { + return test; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof MyRecord that)) + return false; + return java.lang.Objects.equals(test, o.test); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(test); + } + + @Override() + public final non_null String toString() { + return "MyRecord[" + "test=" + test + "," + "]"; + } + } +} diff --git a/key.core/pipelineTests/records/expected/04_JmlDocRemoval/NotAllowed.java b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/NotAllowed.java new file mode 100644 index 0000000000..37ed87d5e1 --- /dev/null +++ b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/NotAllowed.java @@ -0,0 +1,93 @@ +//https://mikemybytes.com/2022/02/16/java-records-and-compact-constructors/ +@Generated() +final class // package-private +Name extends Record { + + private final String name; + + public final String name() { + return name; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Name that)) + return false; + return java.lang.Objects.equals(name, o.name); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(name); + } + + @Override() + public final non_null String toString() { + return "Name[" + "name=" + name + "," + "]"; + } + + // was package)' + private Name(String name) { + this.name = name; + } + + static Name of(String name) { + return new Name(name); + } +} + +@Generated() +final class Point extends Record { + + private final int x; + + public final int x() { + return x; + } + + private final int y; + + public final int y() { + return y; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Point that)) + return false; + return java.lang.Objects.equals(x, o.x) && java.lang.Objects.equals(y, o.y); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(x, y); + } + + @Override() + public final non_null String toString() { + return "Point[" + "x=" + x + "," + "y=" + y + "," + "]"; + } + + Point(int x, int y) { + // boring! + this.x = x; + this.y = y; + } + + Point(int x) { + // a bit weird... + // ... but perfectly fine for the compiler + this(x, 0); + } + + Point() { + // fails with: 'constructor is not canonical, so its first + // statement must invoke another constructor' + } +} diff --git a/key.core/pipelineTests/records/expected/04_JmlDocRemoval/RecordOverwriting.java b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/RecordOverwriting.java new file mode 100644 index 0000000000..3a3143172f --- /dev/null +++ b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/RecordOverwriting.java @@ -0,0 +1,36 @@ +@Generated() +final class MyRecord extends Record { + + private final String test; + + public final String test() { + return test; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof MyRecord that)) + return false; + return java.lang.Objects.equals(test, o.test); + return true; + } + + @Override() + public final non_null String toString() { + return "MyRecord[" + "test=" + test + "," + "]"; + } + + public int hashCode() { + return 0; + } + + public boolean equals(Object obj) { + return obj instanceof MyRecord; + } + + public String test() { + return ""; + } +} diff --git a/key.core/pipelineTests/records/expected/04_JmlDocRemoval/SimpleRecord.java b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/SimpleRecord.java new file mode 100644 index 0000000000..5094807995 --- /dev/null +++ b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/SimpleRecord.java @@ -0,0 +1,33 @@ +@Generated() +public final class SimpleRecord extends Record { + + private final nullable String name; + + public final nullable String name() { + return name; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof SimpleRecord that)) + return false; + return java.lang.Objects.equals(name, o.name); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(name); + } + + @Override() + public final non_null String toString() { + return "SimpleRecord[" + "name=" + name + "," + "]"; + } + + SimpleRecord(String name) { + this.name = name; + } +} diff --git a/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/CompactConstructor.java b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/CompactConstructor.java new file mode 100644 index 0000000000..a43a3ab0b3 --- /dev/null +++ b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/CompactConstructor.java @@ -0,0 +1,59 @@ +@Generated() +final class Mapping extends Record { + + private final String from; + + public final String from() { + return from; + } + + private final String to; + + public final String to() { + return to; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Mapping that)) + return false; + return java.lang.Objects.equals(from, o.from) && java.lang.Objects.equals(to, o.to); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(from, to); + } + + @Override() + public final non_null String toString() { + return "Mapping[" + "from=" + from + "," + "to=" + to + "," + "]"; + } + + Mapping { + // compact constructor! + from = "abc"; + to = "def"; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; +} diff --git a/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/InnerRecord.java b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/InnerRecord.java new file mode 100644 index 0000000000..405a53dbc7 --- /dev/null +++ b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/InnerRecord.java @@ -0,0 +1,70 @@ +class OuterClass { + + @Generated() + final class MyRecord extends Record { + + private final String test; + + public final String test() { + return test; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof MyRecord that)) + return false; + return java.lang.Objects.equals(test, o.test); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(test); + } + + @Override() + public final non_null String toString() { + return "MyRecord[" + "test=" + test + "," + "]"; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + private OuterClass $enclosingThis; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; +} diff --git a/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/NotAllowed.java b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/NotAllowed.java new file mode 100644 index 0000000000..141b747113 --- /dev/null +++ b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/NotAllowed.java @@ -0,0 +1,129 @@ +//https://mikemybytes.com/2022/02/16/java-records-and-compact-constructors/ +@Generated() +final class // package-private +Name extends Record { + + private final String name; + + public final String name() { + return name; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Name that)) + return false; + return java.lang.Objects.equals(name, o.name); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(name); + } + + @Override() + public final non_null String toString() { + return "Name[" + "name=" + name + "," + "]"; + } + + // was package)' + private Name(String name) { + this.name = name; + } + + static Name of(String name) { + return new Name(name); + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; +} + +@Generated() +final class Point extends Record { + + private final int x; + + public final int x() { + return x; + } + + private final int y; + + public final int y() { + return y; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Point that)) + return false; + return java.lang.Objects.equals(x, o.x) && java.lang.Objects.equals(y, o.y); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(x, y); + } + + @Override() + public final non_null String toString() { + return "Point[" + "x=" + x + "," + "y=" + y + "," + "]"; + } + + Point(int x, int y) { + // boring! + this.x = x; + this.y = y; + } + + Point(int x) { + // a bit weird... + // ... but perfectly fine for the compiler + this(x, 0); + } + + Point() { + // fails with: 'constructor is not canonical, so its first + // statement must invoke another constructor' + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; +} diff --git a/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/RecordOverwriting.java b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/RecordOverwriting.java new file mode 100644 index 0000000000..10a01baedd --- /dev/null +++ b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/RecordOverwriting.java @@ -0,0 +1,54 @@ +@Generated() +final class MyRecord extends Record { + + private final String test; + + public final String test() { + return test; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof MyRecord that)) + return false; + return java.lang.Objects.equals(test, o.test); + return true; + } + + @Override() + public final non_null String toString() { + return "MyRecord[" + "test=" + test + "," + "]"; + } + + public int hashCode() { + return 0; + } + + public boolean equals(Object obj) { + return obj instanceof MyRecord; + } + + public String test() { + return ""; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; +} diff --git a/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/SimpleRecord.java b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/SimpleRecord.java new file mode 100644 index 0000000000..6149ba3613 --- /dev/null +++ b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/SimpleRecord.java @@ -0,0 +1,51 @@ +@Generated() +public final class SimpleRecord extends Record { + + private final nullable String name; + + public final nullable String name() { + return name; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof SimpleRecord that)) + return false; + return java.lang.Objects.equals(name, o.name); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(name); + } + + @Override() + public final non_null String toString() { + return "SimpleRecord[" + "name=" + name + "," + "]"; + } + + SimpleRecord(String name) { + this.name = name; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; +} diff --git a/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/CompactConstructor.java b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/CompactConstructor.java new file mode 100644 index 0000000000..92e6621118 --- /dev/null +++ b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/CompactConstructor.java @@ -0,0 +1,61 @@ +@Generated() +final class Mapping extends Record { + + private final String from; + + public final String from() { + return from; + } + + private final String to; + + public final String to() { + return to; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Mapping that)) + return false; + return java.lang.Objects.equals(from, o.from) && java.lang.Objects.equals(to, o.to); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(from, to); + } + + @Override() + public final non_null String toString() { + return "Mapping[" + "from=" + from + "," + "to=" + to + "," + "]"; + } + + Mapping { + // compact constructor! + from = "abc"; + to = "def"; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static Mapping $allocate(); +} diff --git a/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/InnerRecord.java b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/InnerRecord.java new file mode 100644 index 0000000000..15fd856b3d --- /dev/null +++ b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/InnerRecord.java @@ -0,0 +1,74 @@ +class OuterClass { + + @Generated() + final class MyRecord extends Record { + + private final String test; + + public final String test() { + return test; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof MyRecord that)) + return false; + return java.lang.Objects.equals(test, o.test); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(test); + } + + @Override() + public final non_null String toString() { + return "MyRecord[" + "test=" + test + "," + "]"; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + private OuterClass $enclosingThis; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static MyRecord $allocate(); + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static OuterClass $allocate(); +} diff --git a/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/NotAllowed.java b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/NotAllowed.java new file mode 100644 index 0000000000..2f4de3cf02 --- /dev/null +++ b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/NotAllowed.java @@ -0,0 +1,134 @@ +//https://mikemybytes.com/2022/02/16/java-records-and-compact-constructors/ +@Generated() +final class // package-private +Name extends Record { + + private final String name; + + public final String name() { + return name; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Name that)) + return false; + return java.lang.Objects.equals(name, o.name); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(name); + } + + @Override() + public final non_null String toString() { + return "Name[" + "name=" + name + "," + "]"; + } + + // was package)' + private Name(String name) { + this.name = name; + } + + static Name of(String name) { + return new Name(name); + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static // package-private + Name $allocate(); +} + +@Generated() +final class Point extends Record { + + private final int x; + + public final int x() { + return x; + } + + private final int y; + + public final int y() { + return y; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Point that)) + return false; + return java.lang.Objects.equals(x, o.x) && java.lang.Objects.equals(y, o.y); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(x, y); + } + + @Override() + public final non_null String toString() { + return "Point[" + "x=" + x + "," + "y=" + y + "," + "]"; + } + + Point(int x, int y) { + // boring! + this.x = x; + this.y = y; + } + + Point(int x) { + // a bit weird... + // ... but perfectly fine for the compiler + this(x, 0); + } + + Point() { + // fails with: 'constructor is not canonical, so its first + // statement must invoke another constructor' + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static Point $allocate(); +} diff --git a/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/RecordOverwriting.java b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/RecordOverwriting.java new file mode 100644 index 0000000000..007940f8f8 --- /dev/null +++ b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/RecordOverwriting.java @@ -0,0 +1,56 @@ +@Generated() +final class MyRecord extends Record { + + private final String test; + + public final String test() { + return test; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof MyRecord that)) + return false; + return java.lang.Objects.equals(test, o.test); + return true; + } + + @Override() + public final non_null String toString() { + return "MyRecord[" + "test=" + test + "," + "]"; + } + + public int hashCode() { + return 0; + } + + public boolean equals(Object obj) { + return obj instanceof MyRecord; + } + + public String test() { + return ""; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static MyRecord $allocate(); +} diff --git a/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/SimpleRecord.java b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/SimpleRecord.java new file mode 100644 index 0000000000..8b86aa6388 --- /dev/null +++ b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/SimpleRecord.java @@ -0,0 +1,53 @@ +@Generated() +public final class SimpleRecord extends Record { + + private final nullable String name; + + public final nullable String name() { + return name; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof SimpleRecord that)) + return false; + return java.lang.Objects.equals(name, o.name); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(name); + } + + @Override() + public final non_null String toString() { + return "SimpleRecord[" + "name=" + name + "," + "]"; + } + + SimpleRecord(String name) { + this.name = name; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static SimpleRecord $allocate(); +} diff --git a/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/CompactConstructor.java b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/CompactConstructor.java new file mode 100644 index 0000000000..5599542e28 --- /dev/null +++ b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/CompactConstructor.java @@ -0,0 +1,69 @@ +@Generated() +final class Mapping extends Record { + + private final String from; + + public final String from() { + return from; + } + + private final String to; + + public final String to() { + return to; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Mapping that)) + return false; + return java.lang.Objects.equals(from, o.from) && java.lang.Objects.equals(to, o.to); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(from, to); + } + + @Override() + public final non_null String toString() { + return "Mapping[" + "from=" + from + "," + "to=" + to + "," + "]"; + } + + Mapping { + // compact constructor! + from = "abc"; + to = "def"; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static Mapping $allocate(); + + public Mapping() { + } + + public void $init() { + super.$init(); + super.$init(); + } +} diff --git a/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/InnerRecord.java b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/InnerRecord.java new file mode 100644 index 0000000000..0dca0f8d0e --- /dev/null +++ b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/InnerRecord.java @@ -0,0 +1,91 @@ +class OuterClass { + + @Generated() + final class MyRecord extends Record { + + private final String test; + + public final String test() { + return test; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof MyRecord that)) + return false; + return java.lang.Objects.equals(test, o.test); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(test); + } + + @Override() + public final non_null String toString() { + return "MyRecord[" + "test=" + test + "," + "]"; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + private OuterClass $enclosingThis; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static MyRecord $allocate(); + + public MyRecord() { + } + + public void $init(OuterClass $ENCLOSING_THIS) { + super.$init(); + this.$enclosingThis = $ENCLOSING_THIS; + super.$init(); + } + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static OuterClass $allocate(); + + public OuterClass() { + } + + public void $init() { + super.$init(); + super.$init(); + } +} diff --git a/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/NotAllowed.java b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/NotAllowed.java new file mode 100644 index 0000000000..0f1aee7ab0 --- /dev/null +++ b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/NotAllowed.java @@ -0,0 +1,154 @@ +//https://mikemybytes.com/2022/02/16/java-records-and-compact-constructors/ +@Generated() +final class // package-private +Name extends Record { + + private final String name; + + public final String name() { + return name; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Name that)) + return false; + return java.lang.Objects.equals(name, o.name); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(name); + } + + @Override() + public final non_null String toString() { + return "Name[" + "name=" + name + "," + "]"; + } + + // was package)' + private Name(String name) { + this.name = name; + } + + static Name of(String name) { + return new Name(name); + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static // package-private + Name $allocate(); + + private void $init(String name) { + super.$init(); + this.name = name; + } +} + +@Generated() +final class Point extends Record { + + private final int x; + + public final int x() { + return x; + } + + private final int y; + + public final int y() { + return y; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Point that)) + return false; + return java.lang.Objects.equals(x, o.x) && java.lang.Objects.equals(y, o.y); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(x, y); + } + + @Override() + public final non_null String toString() { + return "Point[" + "x=" + x + "," + "y=" + y + "," + "]"; + } + + Point(int x, int y) { + // boring! + this.x = x; + this.y = y; + } + + Point(int x) { + // a bit weird... + // ... but perfectly fine for the compiler + this(x, 0); + } + + Point() { + // fails with: 'constructor is not canonical, so its first + // statement must invoke another constructor' + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static Point $allocate(); + + void $init(int x, int y) { + super.$init(); + // boring! + this.x = x; + this.y = y; + } + + void $init(int x) { + this.$init(x, 0); + } + + void $init() { + super.$init(); + } +} diff --git a/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/RecordOverwriting.java b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/RecordOverwriting.java new file mode 100644 index 0000000000..b1f3d2be93 --- /dev/null +++ b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/RecordOverwriting.java @@ -0,0 +1,64 @@ +@Generated() +final class MyRecord extends Record { + + private final String test; + + public final String test() { + return test; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof MyRecord that)) + return false; + return java.lang.Objects.equals(test, o.test); + return true; + } + + @Override() + public final non_null String toString() { + return "MyRecord[" + "test=" + test + "," + "]"; + } + + public int hashCode() { + return 0; + } + + public boolean equals(Object obj) { + return obj instanceof MyRecord; + } + + public String test() { + return ""; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static MyRecord $allocate(); + + public MyRecord() { + } + + public void $init() { + super.$init(); + super.$init(); + } +} diff --git a/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/SimpleRecord.java b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/SimpleRecord.java new file mode 100644 index 0000000000..17b287d241 --- /dev/null +++ b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/SimpleRecord.java @@ -0,0 +1,58 @@ +@Generated() +public final class SimpleRecord extends Record { + + private final nullable String name; + + public final nullable String name() { + return name; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof SimpleRecord that)) + return false; + return java.lang.Objects.equals(name, o.name); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(name); + } + + @Override() + public final non_null String toString() { + return "SimpleRecord[" + "name=" + name + "," + "]"; + } + + SimpleRecord(String name) { + this.name = name; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static SimpleRecord $allocate(); + + void $init(String name) { + super.$init(); + this.name = name; + } +} diff --git a/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/CompactConstructor.java b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/CompactConstructor.java new file mode 100644 index 0000000000..00ca1412e9 --- /dev/null +++ b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/CompactConstructor.java @@ -0,0 +1,72 @@ +@Generated() +final class Mapping extends Record { + + private final String from; + + public final String from() { + return from; + } + + private final String to; + + public final String to() { + return to; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Mapping that)) + return false; + return java.lang.Objects.equals(from, o.from) && java.lang.Objects.equals(to, o.to); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(from, to); + } + + @Override() + public final non_null String toString() { + return "Mapping[" + "from=" + from + "," + "to=" + to + "," + "]"; + } + + Mapping { + // compact constructor! + from = "abc"; + to = "def"; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static Mapping $allocate(); + + public Mapping() { + } + + public void $init() { + super.$init(); + super.$init(); + } + + static private void $clprepare() { + } +} diff --git a/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/InnerRecord.java b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/InnerRecord.java new file mode 100644 index 0000000000..e6c54db9a3 --- /dev/null +++ b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/InnerRecord.java @@ -0,0 +1,97 @@ +class OuterClass { + + @Generated() + final class MyRecord extends Record { + + private final String test; + + public final String test() { + return test; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof MyRecord that)) + return false; + return java.lang.Objects.equals(test, o.test); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(test); + } + + @Override() + public final non_null String toString() { + return "MyRecord[" + "test=" + test + "," + "]"; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + private OuterClass $enclosingThis; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static MyRecord $allocate(); + + public MyRecord() { + } + + public void $init(OuterClass $ENCLOSING_THIS) { + super.$init(); + this.$enclosingThis = $ENCLOSING_THIS; + super.$init(); + } + + static private void $clprepare() { + } + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static OuterClass $allocate(); + + public OuterClass() { + } + + public void $init() { + super.$init(); + super.$init(); + } + + static private void $clprepare() { + } +} diff --git a/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/NotAllowed.java b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/NotAllowed.java new file mode 100644 index 0000000000..063f3dbe81 --- /dev/null +++ b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/NotAllowed.java @@ -0,0 +1,160 @@ +//https://mikemybytes.com/2022/02/16/java-records-and-compact-constructors/ +@Generated() +final class // package-private +Name extends Record { + + private final String name; + + public final String name() { + return name; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Name that)) + return false; + return java.lang.Objects.equals(name, o.name); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(name); + } + + @Override() + public final non_null String toString() { + return "Name[" + "name=" + name + "," + "]"; + } + + // was package)' + private Name(String name) { + this.name = name; + } + + static Name of(String name) { + return new Name(name); + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static // package-private + Name $allocate(); + + private void $init(String name) { + super.$init(); + this.name = name; + } + + static private void $clprepare() { + } +} + +@Generated() +final class Point extends Record { + + private final int x; + + public final int x() { + return x; + } + + private final int y; + + public final int y() { + return y; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Point that)) + return false; + return java.lang.Objects.equals(x, o.x) && java.lang.Objects.equals(y, o.y); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(x, y); + } + + @Override() + public final non_null String toString() { + return "Point[" + "x=" + x + "," + "y=" + y + "," + "]"; + } + + Point(int x, int y) { + // boring! + this.x = x; + this.y = y; + } + + Point(int x) { + // a bit weird... + // ... but perfectly fine for the compiler + this(x, 0); + } + + Point() { + // fails with: 'constructor is not canonical, so its first + // statement must invoke another constructor' + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static Point $allocate(); + + void $init(int x, int y) { + super.$init(); + // boring! + this.x = x; + this.y = y; + } + + void $init(int x) { + this.$init(x, 0); + } + + void $init() { + super.$init(); + } + + static private void $clprepare() { + } +} diff --git a/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/RecordOverwriting.java b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/RecordOverwriting.java new file mode 100644 index 0000000000..1f7037f222 --- /dev/null +++ b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/RecordOverwriting.java @@ -0,0 +1,67 @@ +@Generated() +final class MyRecord extends Record { + + private final String test; + + public final String test() { + return test; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof MyRecord that)) + return false; + return java.lang.Objects.equals(test, o.test); + return true; + } + + @Override() + public final non_null String toString() { + return "MyRecord[" + "test=" + test + "," + "]"; + } + + public int hashCode() { + return 0; + } + + public boolean equals(Object obj) { + return obj instanceof MyRecord; + } + + public String test() { + return ""; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static MyRecord $allocate(); + + public MyRecord() { + } + + public void $init() { + super.$init(); + super.$init(); + } + + static private void $clprepare() { + } +} diff --git a/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/SimpleRecord.java b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/SimpleRecord.java new file mode 100644 index 0000000000..0ca3959164 --- /dev/null +++ b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/SimpleRecord.java @@ -0,0 +1,61 @@ +@Generated() +public final class SimpleRecord extends Record { + + private final nullable String name; + + public final nullable String name() { + return name; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof SimpleRecord that)) + return false; + return java.lang.Objects.equals(name, o.name); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(name); + } + + @Override() + public final non_null String toString() { + return "SimpleRecord[" + "name=" + name + "," + "]"; + } + + SimpleRecord(String name) { + this.name = name; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static SimpleRecord $allocate(); + + void $init(String name) { + super.$init(); + this.name = name; + } + + static private void $clprepare() { + } +} diff --git a/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/CompactConstructor.java b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/CompactConstructor.java new file mode 100644 index 0000000000..f0e8d8a1d4 --- /dev/null +++ b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/CompactConstructor.java @@ -0,0 +1,110 @@ +@Generated() +final class Mapping extends Record { + + private final String from; + + public final String from() { + return from; + } + + private final String to; + + public final String to() { + return to; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Mapping that)) + return false; + return java.lang.Objects.equals(from, o.from) && java.lang.Objects.equals(to, o.to); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(from, to); + } + + @Override() + public final non_null String toString() { + return "Mapping[" + "from=" + from + "," + "to=" + to + "," + "]"; + } + + Mapping { + // compact constructor! + from = "abc"; + to = "def"; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static Mapping $allocate(); + + public Mapping() { + } + + public void $init() { + super.$init(); + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } +} diff --git a/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/InnerRecord.java b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/InnerRecord.java new file mode 100644 index 0000000000..520d25f60a --- /dev/null +++ b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/InnerRecord.java @@ -0,0 +1,173 @@ +class OuterClass { + + @Generated() + final class MyRecord extends Record { + + private final String test; + + public final String test() { + return test; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof MyRecord that)) + return false; + return java.lang.Objects.equals(test, o.test); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(test); + } + + @Override() + public final non_null String toString() { + return "MyRecord[" + "test=" + test + "," + "]"; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + private OuterClass $enclosingThis; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static MyRecord $allocate(); + + public MyRecord() { + } + + public void $init(OuterClass $ENCLOSING_THIS) { + super.$init(); + this.$enclosingThis = $ENCLOSING_THIS; + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static OuterClass $allocate(); + + public OuterClass() { + } + + public void $init() { + super.$init(); + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Object.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } +} diff --git a/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/NotAllowed.java b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/NotAllowed.java new file mode 100644 index 0000000000..4db7885fa3 --- /dev/null +++ b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/NotAllowed.java @@ -0,0 +1,236 @@ +//https://mikemybytes.com/2022/02/16/java-records-and-compact-constructors/ +@Generated() +final class // package-private +Name extends Record { + + private final String name; + + public final String name() { + return name; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Name that)) + return false; + return java.lang.Objects.equals(name, o.name); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(name); + } + + @Override() + public final non_null String toString() { + return "Name[" + "name=" + name + "," + "]"; + } + + // was package)' + private Name(String name) { + this.name = name; + } + + static Name of(String name) { + return new Name(name); + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static // package-private + Name $allocate(); + + private void $init(String name) { + super.$init(); + this.name = name; + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } +} + +@Generated() +final class Point extends Record { + + private final int x; + + public final int x() { + return x; + } + + private final int y; + + public final int y() { + return y; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Point that)) + return false; + return java.lang.Objects.equals(x, o.x) && java.lang.Objects.equals(y, o.y); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(x, y); + } + + @Override() + public final non_null String toString() { + return "Point[" + "x=" + x + "," + "y=" + y + "," + "]"; + } + + Point(int x, int y) { + // boring! + this.x = x; + this.y = y; + } + + Point(int x) { + // a bit weird... + // ... but perfectly fine for the compiler + this(x, 0); + } + + Point() { + // fails with: 'constructor is not canonical, so its first + // statement must invoke another constructor' + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static Point $allocate(); + + void $init(int x, int y) { + super.$init(); + // boring! + this.x = x; + this.y = y; + } + + void $init(int x) { + this.$init(x, 0); + } + + void $init() { + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } +} diff --git a/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/RecordOverwriting.java b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/RecordOverwriting.java new file mode 100644 index 0000000000..11636ee59a --- /dev/null +++ b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/RecordOverwriting.java @@ -0,0 +1,105 @@ +@Generated() +final class MyRecord extends Record { + + private final String test; + + public final String test() { + return test; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof MyRecord that)) + return false; + return java.lang.Objects.equals(test, o.test); + return true; + } + + @Override() + public final non_null String toString() { + return "MyRecord[" + "test=" + test + "," + "]"; + } + + public int hashCode() { + return 0; + } + + public boolean equals(Object obj) { + return obj instanceof MyRecord; + } + + public String test() { + return ""; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static MyRecord $allocate(); + + public MyRecord() { + } + + public void $init() { + super.$init(); + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } +} diff --git a/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/SimpleRecord.java b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/SimpleRecord.java new file mode 100644 index 0000000000..3176e3baa5 --- /dev/null +++ b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/SimpleRecord.java @@ -0,0 +1,99 @@ +@Generated() +public final class SimpleRecord extends Record { + + private final nullable String name; + + public final nullable String name() { + return name; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof SimpleRecord that)) + return false; + return java.lang.Objects.equals(name, o.name); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(name); + } + + @Override() + public final non_null String toString() { + return "SimpleRecord[" + "name=" + name + "," + "]"; + } + + SimpleRecord(String name) { + this.name = name; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static SimpleRecord $allocate(); + + void $init(String name) { + super.$init(); + this.name = name; + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } +} diff --git a/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/CompactConstructor.java b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/CompactConstructor.java new file mode 100644 index 0000000000..ff3e3c8858 --- /dev/null +++ b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/CompactConstructor.java @@ -0,0 +1,126 @@ +@Generated() +final class Mapping extends Record { + + private final String from; + + public final String from() { + return from; + } + + private final String to; + + public final String to() { + return to; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Mapping that)) + return false; + return java.lang.Objects.equals(from, o.from) && java.lang.Objects.equals(to, o.to); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(from, to); + } + + @Override() + public final non_null String toString() { + return "Mapping[" + "from=" + from + "," + "to=" + to + "," + "]"; + } + + Mapping { + // compact constructor! + from = "abc"; + to = "def"; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static Mapping $allocate(); + + public Mapping() { + } + + public void $init() { + super.$init(); + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.from = null; + //Created by PrepareObjectBuilder.java:94 + this.to = null; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.from = null; + //Created by PrepareObjectBuilder.java:94 + this.to = null; + } +} diff --git a/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/InnerRecord.java b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/InnerRecord.java new file mode 100644 index 0000000000..fc5c3a3948 --- /dev/null +++ b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/InnerRecord.java @@ -0,0 +1,197 @@ +class OuterClass { + + @Generated() + final class MyRecord extends Record { + + private final String test; + + public final String test() { + return test; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof MyRecord that)) + return false; + return java.lang.Objects.equals(test, o.test); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(test); + } + + @Override() + public final non_null String toString() { + return "MyRecord[" + "test=" + test + "," + "]"; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + private OuterClass $enclosingThis; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static MyRecord $allocate(); + + public MyRecord() { + } + + public void $init(OuterClass $ENCLOSING_THIS) { + super.$init(); + this.$enclosingThis = $ENCLOSING_THIS; + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.test = null; + //Created by PrepareObjectBuilder.java:94 + this.$enclosingThis = null; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.test = null; + //Created by PrepareObjectBuilder.java:94 + this.$enclosingThis = null; + } + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static OuterClass $allocate(); + + public OuterClass() { + } + + public void $init() { + super.$init(); + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Object.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + } + + private void $prepareEnter() { + super.$prepare(); + } +} diff --git a/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/NotAllowed.java b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/NotAllowed.java new file mode 100644 index 0000000000..37fbc596cb --- /dev/null +++ b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/NotAllowed.java @@ -0,0 +1,264 @@ +//https://mikemybytes.com/2022/02/16/java-records-and-compact-constructors/ +@Generated() +final class // package-private +Name extends Record { + + private final String name; + + public final String name() { + return name; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Name that)) + return false; + return java.lang.Objects.equals(name, o.name); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(name); + } + + @Override() + public final non_null String toString() { + return "Name[" + "name=" + name + "," + "]"; + } + + // was package)' + private Name(String name) { + this.name = name; + } + + static Name of(String name) { + return new Name(name); + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static // package-private + Name $allocate(); + + private void $init(String name) { + super.$init(); + this.name = name; + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.name = null; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.name = null; + } +} + +@Generated() +final class Point extends Record { + + private final int x; + + public final int x() { + return x; + } + + private final int y; + + public final int y() { + return y; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Point that)) + return false; + return java.lang.Objects.equals(x, o.x) && java.lang.Objects.equals(y, o.y); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(x, y); + } + + @Override() + public final non_null String toString() { + return "Point[" + "x=" + x + "," + "y=" + y + "," + "]"; + } + + Point(int x, int y) { + // boring! + this.x = x; + this.y = y; + } + + Point(int x) { + // a bit weird... + // ... but perfectly fine for the compiler + this(x, 0); + } + + Point() { + // fails with: 'constructor is not canonical, so its first + // statement must invoke another constructor' + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static Point $allocate(); + + void $init(int x, int y) { + super.$init(); + // boring! + this.x = x; + this.y = y; + } + + void $init(int x) { + this.$init(x, 0); + } + + void $init() { + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.x = 0; + //Created by PrepareObjectBuilder.java:94 + this.y = 0; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.x = 0; + //Created by PrepareObjectBuilder.java:94 + this.y = 0; + } +} diff --git a/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/RecordOverwriting.java b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/RecordOverwriting.java new file mode 100644 index 0000000000..fe750ad8f4 --- /dev/null +++ b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/RecordOverwriting.java @@ -0,0 +1,117 @@ +@Generated() +final class MyRecord extends Record { + + private final String test; + + public final String test() { + return test; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof MyRecord that)) + return false; + return java.lang.Objects.equals(test, o.test); + return true; + } + + @Override() + public final non_null String toString() { + return "MyRecord[" + "test=" + test + "," + "]"; + } + + public int hashCode() { + return 0; + } + + public boolean equals(Object obj) { + return obj instanceof MyRecord; + } + + public String test() { + return ""; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static MyRecord $allocate(); + + public MyRecord() { + } + + public void $init() { + super.$init(); + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.test = null; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.test = null; + } +} diff --git a/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/SimpleRecord.java b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/SimpleRecord.java new file mode 100644 index 0000000000..e2d6c6ca1f --- /dev/null +++ b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/SimpleRecord.java @@ -0,0 +1,111 @@ +@Generated() +public final class SimpleRecord extends Record { + + private final nullable String name; + + public final nullable String name() { + return name; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof SimpleRecord that)) + return false; + return java.lang.Objects.equals(name, o.name); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(name); + } + + @Override() + public final non_null String toString() { + return "SimpleRecord[" + "name=" + name + "," + "]"; + } + + SimpleRecord(String name) { + this.name = name; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static SimpleRecord $allocate(); + + void $init(String name) { + super.$init(); + this.name = name; + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.name = null; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.name = null; + } +} diff --git a/key.core/pipelineTests/records/expected/11_CreateBuilder/CompactConstructor.java b/key.core/pipelineTests/records/expected/11_CreateBuilder/CompactConstructor.java new file mode 100644 index 0000000000..b29d777b9a --- /dev/null +++ b/key.core/pipelineTests/records/expected/11_CreateBuilder/CompactConstructor.java @@ -0,0 +1,133 @@ +@Generated() +final class Mapping extends Record { + + private final String from; + + public final String from() { + return from; + } + + private final String to; + + public final String to() { + return to; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Mapping that)) + return false; + return java.lang.Objects.equals(from, o.from) && java.lang.Objects.equals(to, o.to); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(from, to); + } + + @Override() + public final non_null String toString() { + return "Mapping[" + "from=" + from + "," + "to=" + to + "," + "]"; + } + + Mapping { + // compact constructor! + from = "abc"; + to = "def"; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static Mapping $allocate(); + + public Mapping() { + } + + public void $init() { + super.$init(); + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.from = null; + //Created by PrepareObjectBuilder.java:94 + this.to = null; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.from = null; + //Created by PrepareObjectBuilder.java:94 + this.to = null; + } + + public Mapping $create() { + //Created by CreateBuilder.java:57 + this.$initialized = false; + $prepareEnter(); + return this; + } +} diff --git a/key.core/pipelineTests/records/expected/11_CreateBuilder/InnerRecord.java b/key.core/pipelineTests/records/expected/11_CreateBuilder/InnerRecord.java new file mode 100644 index 0000000000..03abe4e62d --- /dev/null +++ b/key.core/pipelineTests/records/expected/11_CreateBuilder/InnerRecord.java @@ -0,0 +1,211 @@ +class OuterClass { + + @Generated() + final class MyRecord extends Record { + + private final String test; + + public final String test() { + return test; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof MyRecord that)) + return false; + return java.lang.Objects.equals(test, o.test); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(test); + } + + @Override() + public final non_null String toString() { + return "MyRecord[" + "test=" + test + "," + "]"; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + private OuterClass $enclosingThis; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static MyRecord $allocate(); + + public MyRecord() { + } + + public void $init(OuterClass $ENCLOSING_THIS) { + super.$init(); + this.$enclosingThis = $ENCLOSING_THIS; + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.test = null; + //Created by PrepareObjectBuilder.java:94 + this.$enclosingThis = null; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.test = null; + //Created by PrepareObjectBuilder.java:94 + this.$enclosingThis = null; + } + + public MyRecord $create() { + //Created by CreateBuilder.java:57 + this.$initialized = false; + $prepareEnter(); + return this; + } + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static OuterClass $allocate(); + + public OuterClass() { + } + + public void $init() { + super.$init(); + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Object.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + } + + private void $prepareEnter() { + super.$prepare(); + } + + public OuterClass $create() { + //Created by CreateBuilder.java:57 + this.$initialized = false; + $prepareEnter(); + return this; + } +} diff --git a/key.core/pipelineTests/records/expected/11_CreateBuilder/NotAllowed.java b/key.core/pipelineTests/records/expected/11_CreateBuilder/NotAllowed.java new file mode 100644 index 0000000000..3c71e8e4a9 --- /dev/null +++ b/key.core/pipelineTests/records/expected/11_CreateBuilder/NotAllowed.java @@ -0,0 +1,278 @@ +//https://mikemybytes.com/2022/02/16/java-records-and-compact-constructors/ +@Generated() +final class // package-private +Name extends Record { + + private final String name; + + public final String name() { + return name; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Name that)) + return false; + return java.lang.Objects.equals(name, o.name); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(name); + } + + @Override() + public final non_null String toString() { + return "Name[" + "name=" + name + "," + "]"; + } + + // was package)' + private Name(String name) { + this.name = name; + } + + static Name of(String name) { + return new Name(name); + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static // package-private + Name $allocate(); + + private void $init(String name) { + super.$init(); + this.name = name; + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.name = null; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.name = null; + } + + public Name $create() { + //Created by CreateBuilder.java:57 + this.$initialized = false; + $prepareEnter(); + return this; + } +} + +@Generated() +final class Point extends Record { + + private final int x; + + public final int x() { + return x; + } + + private final int y; + + public final int y() { + return y; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Point that)) + return false; + return java.lang.Objects.equals(x, o.x) && java.lang.Objects.equals(y, o.y); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(x, y); + } + + @Override() + public final non_null String toString() { + return "Point[" + "x=" + x + "," + "y=" + y + "," + "]"; + } + + Point(int x, int y) { + // boring! + this.x = x; + this.y = y; + } + + Point(int x) { + // a bit weird... + // ... but perfectly fine for the compiler + this(x, 0); + } + + Point() { + // fails with: 'constructor is not canonical, so its first + // statement must invoke another constructor' + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static Point $allocate(); + + void $init(int x, int y) { + super.$init(); + // boring! + this.x = x; + this.y = y; + } + + void $init(int x) { + this.$init(x, 0); + } + + void $init() { + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.x = 0; + //Created by PrepareObjectBuilder.java:94 + this.y = 0; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.x = 0; + //Created by PrepareObjectBuilder.java:94 + this.y = 0; + } + + public Point $create() { + //Created by CreateBuilder.java:57 + this.$initialized = false; + $prepareEnter(); + return this; + } +} diff --git a/key.core/pipelineTests/records/expected/11_CreateBuilder/RecordOverwriting.java b/key.core/pipelineTests/records/expected/11_CreateBuilder/RecordOverwriting.java new file mode 100644 index 0000000000..f2a0a5ad01 --- /dev/null +++ b/key.core/pipelineTests/records/expected/11_CreateBuilder/RecordOverwriting.java @@ -0,0 +1,124 @@ +@Generated() +final class MyRecord extends Record { + + private final String test; + + public final String test() { + return test; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof MyRecord that)) + return false; + return java.lang.Objects.equals(test, o.test); + return true; + } + + @Override() + public final non_null String toString() { + return "MyRecord[" + "test=" + test + "," + "]"; + } + + public int hashCode() { + return 0; + } + + public boolean equals(Object obj) { + return obj instanceof MyRecord; + } + + public String test() { + return ""; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static MyRecord $allocate(); + + public MyRecord() { + } + + public void $init() { + super.$init(); + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.test = null; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.test = null; + } + + public MyRecord $create() { + //Created by CreateBuilder.java:57 + this.$initialized = false; + $prepareEnter(); + return this; + } +} diff --git a/key.core/pipelineTests/records/expected/11_CreateBuilder/SimpleRecord.java b/key.core/pipelineTests/records/expected/11_CreateBuilder/SimpleRecord.java new file mode 100644 index 0000000000..3b19c572ee --- /dev/null +++ b/key.core/pipelineTests/records/expected/11_CreateBuilder/SimpleRecord.java @@ -0,0 +1,118 @@ +@Generated() +public final class SimpleRecord extends Record { + + private final nullable String name; + + public final nullable String name() { + return name; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof SimpleRecord that)) + return false; + return java.lang.Objects.equals(name, o.name); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(name); + } + + @Override() + public final non_null String toString() { + return "SimpleRecord[" + "name=" + name + "," + "]"; + } + + SimpleRecord(String name) { + this.name = name; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static SimpleRecord $allocate(); + + void $init(String name) { + super.$init(); + this.name = name; + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.name = null; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.name = null; + } + + public SimpleRecord $create() { + //Created by CreateBuilder.java:57 + this.$initialized = false; + $prepareEnter(); + return this; + } +} diff --git a/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/CompactConstructor.java b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/CompactConstructor.java new file mode 100644 index 0000000000..1c6c12a2d4 --- /dev/null +++ b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/CompactConstructor.java @@ -0,0 +1,141 @@ +@Generated() +final class Mapping extends Record { + + private final String from; + + public final String from() { + return from; + } + + private final String to; + + public final String to() { + return to; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Mapping that)) + return false; + return java.lang.Objects.equals(from, o.from) && java.lang.Objects.equals(to, o.to); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(from, to); + } + + @Override() + public final non_null String toString() { + return "Mapping[" + "from=" + from + "," + "to=" + to + "," + "]"; + } + + Mapping { + // compact constructor! + from = "abc"; + to = "def"; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static Mapping $allocate(); + + public Mapping() { + } + + public void $init() { + super.$init(); + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.from = null; + //Created by PrepareObjectBuilder.java:94 + this.to = null; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.from = null; + //Created by PrepareObjectBuilder.java:94 + this.to = null; + } + + public Mapping $create() { + //Created by CreateBuilder.java:57 + this.$initialized = false; + $prepareEnter(); + return this; + } + + public static Mapping $createObject() { + Mapping __NEW__; + //Created by CreateObjectBuilder.java:70 + __NEW__ = Mapping.$allocate(); + __NEW__.$create()@Mapping + return __NEW__; + } +} diff --git a/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/InnerRecord.java b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/InnerRecord.java new file mode 100644 index 0000000000..198cf32dd6 --- /dev/null +++ b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/InnerRecord.java @@ -0,0 +1,227 @@ +class OuterClass { + + @Generated() + final class MyRecord extends Record { + + private final String test; + + public final String test() { + return test; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof MyRecord that)) + return false; + return java.lang.Objects.equals(test, o.test); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(test); + } + + @Override() + public final non_null String toString() { + return "MyRecord[" + "test=" + test + "," + "]"; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + private OuterClass $enclosingThis; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static MyRecord $allocate(); + + public MyRecord() { + } + + public void $init(OuterClass $ENCLOSING_THIS) { + super.$init(); + this.$enclosingThis = $ENCLOSING_THIS; + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.test = null; + //Created by PrepareObjectBuilder.java:94 + this.$enclosingThis = null; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.test = null; + //Created by PrepareObjectBuilder.java:94 + this.$enclosingThis = null; + } + + public MyRecord $create() { + //Created by CreateBuilder.java:57 + this.$initialized = false; + $prepareEnter(); + return this; + } + + public static MyRecord $createObject() { + MyRecord __NEW__; + //Created by CreateObjectBuilder.java:70 + __NEW__ = MyRecord.$allocate(); + __NEW__.$create()@MyRecord + return __NEW__; + } + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static OuterClass $allocate(); + + public OuterClass() { + } + + public void $init() { + super.$init(); + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Object.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + } + + private void $prepareEnter() { + super.$prepare(); + } + + public OuterClass $create() { + //Created by CreateBuilder.java:57 + this.$initialized = false; + $prepareEnter(); + return this; + } + + public static OuterClass $createObject() { + OuterClass __NEW__; + //Created by CreateObjectBuilder.java:70 + __NEW__ = OuterClass.$allocate(); + __NEW__.$create()@OuterClass + return __NEW__; + } +} diff --git a/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/NotAllowed.java b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/NotAllowed.java new file mode 100644 index 0000000000..06cbba6c07 --- /dev/null +++ b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/NotAllowed.java @@ -0,0 +1,298 @@ +//https://mikemybytes.com/2022/02/16/java-records-and-compact-constructors/ +@Generated() +final class // package-private +Name extends Record { + + private final String name; + + public final String name() { + return name; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Name that)) + return false; + return java.lang.Objects.equals(name, o.name); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(name); + } + + @Override() + public final non_null String toString() { + return "Name[" + "name=" + name + "," + "]"; + } + + // was package)' + private Name(String name) { + this.name = name; + } + + static Name of(String name) { + return new Name(name); + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static // package-private + Name $allocate(); + + private void $init(String name) { + super.$init(); + this.name = name; + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.name = null; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.name = null; + } + + public Name $create() { + //Created by CreateBuilder.java:57 + this.$initialized = false; + $prepareEnter(); + return this; + } + + public static // package-private + Name $createObject() { + // package-private + Name __NEW__; + //Created by CreateObjectBuilder.java:70 + __NEW__ = // package-private + Name.$allocate(); + __NEW__.$create()@// package-private + Name + return __NEW__; + } +} + +@Generated() +final class Point extends Record { + + private final int x; + + public final int x() { + return x; + } + + private final int y; + + public final int y() { + return y; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Point that)) + return false; + return java.lang.Objects.equals(x, o.x) && java.lang.Objects.equals(y, o.y); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(x, y); + } + + @Override() + public final non_null String toString() { + return "Point[" + "x=" + x + "," + "y=" + y + "," + "]"; + } + + Point(int x, int y) { + // boring! + this.x = x; + this.y = y; + } + + Point(int x) { + // a bit weird... + // ... but perfectly fine for the compiler + this(x, 0); + } + + Point() { + // fails with: 'constructor is not canonical, so its first + // statement must invoke another constructor' + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static Point $allocate(); + + void $init(int x, int y) { + super.$init(); + // boring! + this.x = x; + this.y = y; + } + + void $init(int x) { + this.$init(x, 0); + } + + void $init() { + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.x = 0; + //Created by PrepareObjectBuilder.java:94 + this.y = 0; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.x = 0; + //Created by PrepareObjectBuilder.java:94 + this.y = 0; + } + + public Point $create() { + //Created by CreateBuilder.java:57 + this.$initialized = false; + $prepareEnter(); + return this; + } + + public static Point $createObject() { + Point __NEW__; + //Created by CreateObjectBuilder.java:70 + __NEW__ = Point.$allocate(); + __NEW__.$create()@Point + return __NEW__; + } +} diff --git a/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/RecordOverwriting.java b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/RecordOverwriting.java new file mode 100644 index 0000000000..ed8b4b08af --- /dev/null +++ b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/RecordOverwriting.java @@ -0,0 +1,132 @@ +@Generated() +final class MyRecord extends Record { + + private final String test; + + public final String test() { + return test; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof MyRecord that)) + return false; + return java.lang.Objects.equals(test, o.test); + return true; + } + + @Override() + public final non_null String toString() { + return "MyRecord[" + "test=" + test + "," + "]"; + } + + public int hashCode() { + return 0; + } + + public boolean equals(Object obj) { + return obj instanceof MyRecord; + } + + public String test() { + return ""; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static MyRecord $allocate(); + + public MyRecord() { + } + + public void $init() { + super.$init(); + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.test = null; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.test = null; + } + + public MyRecord $create() { + //Created by CreateBuilder.java:57 + this.$initialized = false; + $prepareEnter(); + return this; + } + + public static MyRecord $createObject() { + MyRecord __NEW__; + //Created by CreateObjectBuilder.java:70 + __NEW__ = MyRecord.$allocate(); + __NEW__.$create()@MyRecord + return __NEW__; + } +} diff --git a/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/SimpleRecord.java b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/SimpleRecord.java new file mode 100644 index 0000000000..8891eca833 --- /dev/null +++ b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/SimpleRecord.java @@ -0,0 +1,126 @@ +@Generated() +public final class SimpleRecord extends Record { + + private final nullable String name; + + public final nullable String name() { + return name; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof SimpleRecord that)) + return false; + return java.lang.Objects.equals(name, o.name); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(name); + } + + @Override() + public final non_null String toString() { + return "SimpleRecord[" + "name=" + name + "," + "]"; + } + + SimpleRecord(String name) { + this.name = name; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static SimpleRecord $allocate(); + + void $init(String name) { + super.$init(); + this.name = name; + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.name = null; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.name = null; + } + + public SimpleRecord $create() { + //Created by CreateBuilder.java:57 + this.$initialized = false; + $prepareEnter(); + return this; + } + + public static SimpleRecord $createObject() { + SimpleRecord __NEW__; + //Created by CreateObjectBuilder.java:70 + __NEW__ = SimpleRecord.$allocate(); + __NEW__.$create()@SimpleRecord + return __NEW__; + } +} diff --git a/key.core/pipelineTests/records/expected/13_LocalClassTransformation/CompactConstructor.java b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/CompactConstructor.java new file mode 100644 index 0000000000..1c6c12a2d4 --- /dev/null +++ b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/CompactConstructor.java @@ -0,0 +1,141 @@ +@Generated() +final class Mapping extends Record { + + private final String from; + + public final String from() { + return from; + } + + private final String to; + + public final String to() { + return to; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Mapping that)) + return false; + return java.lang.Objects.equals(from, o.from) && java.lang.Objects.equals(to, o.to); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(from, to); + } + + @Override() + public final non_null String toString() { + return "Mapping[" + "from=" + from + "," + "to=" + to + "," + "]"; + } + + Mapping { + // compact constructor! + from = "abc"; + to = "def"; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static Mapping $allocate(); + + public Mapping() { + } + + public void $init() { + super.$init(); + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.from = null; + //Created by PrepareObjectBuilder.java:94 + this.to = null; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.from = null; + //Created by PrepareObjectBuilder.java:94 + this.to = null; + } + + public Mapping $create() { + //Created by CreateBuilder.java:57 + this.$initialized = false; + $prepareEnter(); + return this; + } + + public static Mapping $createObject() { + Mapping __NEW__; + //Created by CreateObjectBuilder.java:70 + __NEW__ = Mapping.$allocate(); + __NEW__.$create()@Mapping + return __NEW__; + } +} diff --git a/key.core/pipelineTests/records/expected/13_LocalClassTransformation/InnerRecord.java b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/InnerRecord.java new file mode 100644 index 0000000000..198cf32dd6 --- /dev/null +++ b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/InnerRecord.java @@ -0,0 +1,227 @@ +class OuterClass { + + @Generated() + final class MyRecord extends Record { + + private final String test; + + public final String test() { + return test; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof MyRecord that)) + return false; + return java.lang.Objects.equals(test, o.test); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(test); + } + + @Override() + public final non_null String toString() { + return "MyRecord[" + "test=" + test + "," + "]"; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + private OuterClass $enclosingThis; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static MyRecord $allocate(); + + public MyRecord() { + } + + public void $init(OuterClass $ENCLOSING_THIS) { + super.$init(); + this.$enclosingThis = $ENCLOSING_THIS; + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.test = null; + //Created by PrepareObjectBuilder.java:94 + this.$enclosingThis = null; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.test = null; + //Created by PrepareObjectBuilder.java:94 + this.$enclosingThis = null; + } + + public MyRecord $create() { + //Created by CreateBuilder.java:57 + this.$initialized = false; + $prepareEnter(); + return this; + } + + public static MyRecord $createObject() { + MyRecord __NEW__; + //Created by CreateObjectBuilder.java:70 + __NEW__ = MyRecord.$allocate(); + __NEW__.$create()@MyRecord + return __NEW__; + } + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static OuterClass $allocate(); + + public OuterClass() { + } + + public void $init() { + super.$init(); + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Object.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + } + + private void $prepareEnter() { + super.$prepare(); + } + + public OuterClass $create() { + //Created by CreateBuilder.java:57 + this.$initialized = false; + $prepareEnter(); + return this; + } + + public static OuterClass $createObject() { + OuterClass __NEW__; + //Created by CreateObjectBuilder.java:70 + __NEW__ = OuterClass.$allocate(); + __NEW__.$create()@OuterClass + return __NEW__; + } +} diff --git a/key.core/pipelineTests/records/expected/13_LocalClassTransformation/NotAllowed.java b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/NotAllowed.java new file mode 100644 index 0000000000..06cbba6c07 --- /dev/null +++ b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/NotAllowed.java @@ -0,0 +1,298 @@ +//https://mikemybytes.com/2022/02/16/java-records-and-compact-constructors/ +@Generated() +final class // package-private +Name extends Record { + + private final String name; + + public final String name() { + return name; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Name that)) + return false; + return java.lang.Objects.equals(name, o.name); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(name); + } + + @Override() + public final non_null String toString() { + return "Name[" + "name=" + name + "," + "]"; + } + + // was package)' + private Name(String name) { + this.name = name; + } + + static Name of(String name) { + return new Name(name); + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static // package-private + Name $allocate(); + + private void $init(String name) { + super.$init(); + this.name = name; + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.name = null; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.name = null; + } + + public Name $create() { + //Created by CreateBuilder.java:57 + this.$initialized = false; + $prepareEnter(); + return this; + } + + public static // package-private + Name $createObject() { + // package-private + Name __NEW__; + //Created by CreateObjectBuilder.java:70 + __NEW__ = // package-private + Name.$allocate(); + __NEW__.$create()@// package-private + Name + return __NEW__; + } +} + +@Generated() +final class Point extends Record { + + private final int x; + + public final int x() { + return x; + } + + private final int y; + + public final int y() { + return y; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Point that)) + return false; + return java.lang.Objects.equals(x, o.x) && java.lang.Objects.equals(y, o.y); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(x, y); + } + + @Override() + public final non_null String toString() { + return "Point[" + "x=" + x + "," + "y=" + y + "," + "]"; + } + + Point(int x, int y) { + // boring! + this.x = x; + this.y = y; + } + + Point(int x) { + // a bit weird... + // ... but perfectly fine for the compiler + this(x, 0); + } + + Point() { + // fails with: 'constructor is not canonical, so its first + // statement must invoke another constructor' + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static Point $allocate(); + + void $init(int x, int y) { + super.$init(); + // boring! + this.x = x; + this.y = y; + } + + void $init(int x) { + this.$init(x, 0); + } + + void $init() { + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.x = 0; + //Created by PrepareObjectBuilder.java:94 + this.y = 0; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.x = 0; + //Created by PrepareObjectBuilder.java:94 + this.y = 0; + } + + public Point $create() { + //Created by CreateBuilder.java:57 + this.$initialized = false; + $prepareEnter(); + return this; + } + + public static Point $createObject() { + Point __NEW__; + //Created by CreateObjectBuilder.java:70 + __NEW__ = Point.$allocate(); + __NEW__.$create()@Point + return __NEW__; + } +} diff --git a/key.core/pipelineTests/records/expected/13_LocalClassTransformation/RecordOverwriting.java b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/RecordOverwriting.java new file mode 100644 index 0000000000..ed8b4b08af --- /dev/null +++ b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/RecordOverwriting.java @@ -0,0 +1,132 @@ +@Generated() +final class MyRecord extends Record { + + private final String test; + + public final String test() { + return test; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof MyRecord that)) + return false; + return java.lang.Objects.equals(test, o.test); + return true; + } + + @Override() + public final non_null String toString() { + return "MyRecord[" + "test=" + test + "," + "]"; + } + + public int hashCode() { + return 0; + } + + public boolean equals(Object obj) { + return obj instanceof MyRecord; + } + + public String test() { + return ""; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static MyRecord $allocate(); + + public MyRecord() { + } + + public void $init() { + super.$init(); + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.test = null; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.test = null; + } + + public MyRecord $create() { + //Created by CreateBuilder.java:57 + this.$initialized = false; + $prepareEnter(); + return this; + } + + public static MyRecord $createObject() { + MyRecord __NEW__; + //Created by CreateObjectBuilder.java:70 + __NEW__ = MyRecord.$allocate(); + __NEW__.$create()@MyRecord + return __NEW__; + } +} diff --git a/key.core/pipelineTests/records/expected/13_LocalClassTransformation/SimpleRecord.java b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/SimpleRecord.java new file mode 100644 index 0000000000..8891eca833 --- /dev/null +++ b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/SimpleRecord.java @@ -0,0 +1,126 @@ +@Generated() +public final class SimpleRecord extends Record { + + private final nullable String name; + + public final nullable String name() { + return name; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof SimpleRecord that)) + return false; + return java.lang.Objects.equals(name, o.name); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(name); + } + + @Override() + public final non_null String toString() { + return "SimpleRecord[" + "name=" + name + "," + "]"; + } + + SimpleRecord(String name) { + this.name = name; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static SimpleRecord $allocate(); + + void $init(String name) { + super.$init(); + this.name = name; + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.name = null; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.name = null; + } + + public SimpleRecord $create() { + //Created by CreateBuilder.java:57 + this.$initialized = false; + $prepareEnter(); + return this; + } + + public static SimpleRecord $createObject() { + SimpleRecord __NEW__; + //Created by CreateObjectBuilder.java:70 + __NEW__ = SimpleRecord.$allocate(); + __NEW__.$create()@SimpleRecord + return __NEW__; + } +} diff --git a/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/CompactConstructor.java b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/CompactConstructor.java new file mode 100644 index 0000000000..1c6c12a2d4 --- /dev/null +++ b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/CompactConstructor.java @@ -0,0 +1,141 @@ +@Generated() +final class Mapping extends Record { + + private final String from; + + public final String from() { + return from; + } + + private final String to; + + public final String to() { + return to; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Mapping that)) + return false; + return java.lang.Objects.equals(from, o.from) && java.lang.Objects.equals(to, o.to); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(from, to); + } + + @Override() + public final non_null String toString() { + return "Mapping[" + "from=" + from + "," + "to=" + to + "," + "]"; + } + + Mapping { + // compact constructor! + from = "abc"; + to = "def"; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static Mapping $allocate(); + + public Mapping() { + } + + public void $init() { + super.$init(); + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.from = null; + //Created by PrepareObjectBuilder.java:94 + this.to = null; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.from = null; + //Created by PrepareObjectBuilder.java:94 + this.to = null; + } + + public Mapping $create() { + //Created by CreateBuilder.java:57 + this.$initialized = false; + $prepareEnter(); + return this; + } + + public static Mapping $createObject() { + Mapping __NEW__; + //Created by CreateObjectBuilder.java:70 + __NEW__ = Mapping.$allocate(); + __NEW__.$create()@Mapping + return __NEW__; + } +} diff --git a/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/InnerRecord.java b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/InnerRecord.java new file mode 100644 index 0000000000..198cf32dd6 --- /dev/null +++ b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/InnerRecord.java @@ -0,0 +1,227 @@ +class OuterClass { + + @Generated() + final class MyRecord extends Record { + + private final String test; + + public final String test() { + return test; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof MyRecord that)) + return false; + return java.lang.Objects.equals(test, o.test); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(test); + } + + @Override() + public final non_null String toString() { + return "MyRecord[" + "test=" + test + "," + "]"; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + private OuterClass $enclosingThis; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static MyRecord $allocate(); + + public MyRecord() { + } + + public void $init(OuterClass $ENCLOSING_THIS) { + super.$init(); + this.$enclosingThis = $ENCLOSING_THIS; + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.test = null; + //Created by PrepareObjectBuilder.java:94 + this.$enclosingThis = null; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.test = null; + //Created by PrepareObjectBuilder.java:94 + this.$enclosingThis = null; + } + + public MyRecord $create() { + //Created by CreateBuilder.java:57 + this.$initialized = false; + $prepareEnter(); + return this; + } + + public static MyRecord $createObject() { + MyRecord __NEW__; + //Created by CreateObjectBuilder.java:70 + __NEW__ = MyRecord.$allocate(); + __NEW__.$create()@MyRecord + return __NEW__; + } + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static OuterClass $allocate(); + + public OuterClass() { + } + + public void $init() { + super.$init(); + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Object.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + } + + private void $prepareEnter() { + super.$prepare(); + } + + public OuterClass $create() { + //Created by CreateBuilder.java:57 + this.$initialized = false; + $prepareEnter(); + return this; + } + + public static OuterClass $createObject() { + OuterClass __NEW__; + //Created by CreateObjectBuilder.java:70 + __NEW__ = OuterClass.$allocate(); + __NEW__.$create()@OuterClass + return __NEW__; + } +} diff --git a/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/NotAllowed.java b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/NotAllowed.java new file mode 100644 index 0000000000..06cbba6c07 --- /dev/null +++ b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/NotAllowed.java @@ -0,0 +1,298 @@ +//https://mikemybytes.com/2022/02/16/java-records-and-compact-constructors/ +@Generated() +final class // package-private +Name extends Record { + + private final String name; + + public final String name() { + return name; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Name that)) + return false; + return java.lang.Objects.equals(name, o.name); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(name); + } + + @Override() + public final non_null String toString() { + return "Name[" + "name=" + name + "," + "]"; + } + + // was package)' + private Name(String name) { + this.name = name; + } + + static Name of(String name) { + return new Name(name); + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static // package-private + Name $allocate(); + + private void $init(String name) { + super.$init(); + this.name = name; + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.name = null; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.name = null; + } + + public Name $create() { + //Created by CreateBuilder.java:57 + this.$initialized = false; + $prepareEnter(); + return this; + } + + public static // package-private + Name $createObject() { + // package-private + Name __NEW__; + //Created by CreateObjectBuilder.java:70 + __NEW__ = // package-private + Name.$allocate(); + __NEW__.$create()@// package-private + Name + return __NEW__; + } +} + +@Generated() +final class Point extends Record { + + private final int x; + + public final int x() { + return x; + } + + private final int y; + + public final int y() { + return y; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof Point that)) + return false; + return java.lang.Objects.equals(x, o.x) && java.lang.Objects.equals(y, o.y); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(x, y); + } + + @Override() + public final non_null String toString() { + return "Point[" + "x=" + x + "," + "y=" + y + "," + "]"; + } + + Point(int x, int y) { + // boring! + this.x = x; + this.y = y; + } + + Point(int x) { + // a bit weird... + // ... but perfectly fine for the compiler + this(x, 0); + } + + Point() { + // fails with: 'constructor is not canonical, so its first + // statement must invoke another constructor' + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static Point $allocate(); + + void $init(int x, int y) { + super.$init(); + // boring! + this.x = x; + this.y = y; + } + + void $init(int x) { + this.$init(x, 0); + } + + void $init() { + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.x = 0; + //Created by PrepareObjectBuilder.java:94 + this.y = 0; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.x = 0; + //Created by PrepareObjectBuilder.java:94 + this.y = 0; + } + + public Point $create() { + //Created by CreateBuilder.java:57 + this.$initialized = false; + $prepareEnter(); + return this; + } + + public static Point $createObject() { + Point __NEW__; + //Created by CreateObjectBuilder.java:70 + __NEW__ = Point.$allocate(); + __NEW__.$create()@Point + return __NEW__; + } +} diff --git a/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/RecordOverwriting.java b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/RecordOverwriting.java new file mode 100644 index 0000000000..ed8b4b08af --- /dev/null +++ b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/RecordOverwriting.java @@ -0,0 +1,132 @@ +@Generated() +final class MyRecord extends Record { + + private final String test; + + public final String test() { + return test; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof MyRecord that)) + return false; + return java.lang.Objects.equals(test, o.test); + return true; + } + + @Override() + public final non_null String toString() { + return "MyRecord[" + "test=" + test + "," + "]"; + } + + public int hashCode() { + return 0; + } + + public boolean equals(Object obj) { + return obj instanceof MyRecord; + } + + public String test() { + return ""; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static MyRecord $allocate(); + + public MyRecord() { + } + + public void $init() { + super.$init(); + super.$init(); + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.test = null; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.test = null; + } + + public MyRecord $create() { + //Created by CreateBuilder.java:57 + this.$initialized = false; + $prepareEnter(); + return this; + } + + public static MyRecord $createObject() { + MyRecord __NEW__; + //Created by CreateObjectBuilder.java:70 + __NEW__ = MyRecord.$allocate(); + __NEW__.$create()@MyRecord + return __NEW__; + } +} diff --git a/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/SimpleRecord.java b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/SimpleRecord.java new file mode 100644 index 0000000000..8891eca833 --- /dev/null +++ b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/SimpleRecord.java @@ -0,0 +1,126 @@ +@Generated() +public final class SimpleRecord extends Record { + + private final nullable String name; + + public final nullable String name() { + return name; + } + + @Override() + public final boolean hashCode(java.lang.Object o) { + if (this == o) + return true; + if (!(o instanceof SimpleRecord that)) + return false; + return java.lang.Objects.equals(name, o.name); + return true; + } + + @Override() + public final int hashCode() { + return java.lang.Objects.hash(name); + } + + @Override() + public final non_null String toString() { + return "SimpleRecord[" + "name=" + name + "," + "]"; + } + + SimpleRecord(String name) { + this.name = name; + } + + @javax.annotation.processing.Generated() + static private boolean $classInitializationInProgress; + + @javax.annotation.processing.Generated() + static private boolean $classErroneous; + + @javax.annotation.processing.Generated() + static private boolean $classInitialized; + + @javax.annotation.processing.Generated() + static private boolean $classPrepared; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv>; + + @javax.annotation.processing.Generated() + static public model boolean <$staticInv_free>; + + public static SimpleRecord $allocate(); + + void $init(String name) { + super.$init(); + this.name = name; + } + + static private void $clprepare() { + } + + static public void $clinit() { + if (!@($classInitialized)) { + if (!@($classInitializationInProgress)) { + if (!@($classPrepared)) { + //Created by ClassInitializeMethodBuilder.java:219 + @($clprepare()); + } + if (@($classErroneous)) { + throw new java.lang.NoClassDefFoundError(); + } + //Created by ClassInitializeMethodBuilder.java:243 + @($classInitializationInProgress) = true; + try { + @(java.lang.Record.$clinit()); + }//Created by ClassInitializeMethodBuilder.java:194 + catch (java.lang.Error err) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw err; + } catch (java.lang.Throwable twa) { + //Created by ClassInitializeMethodBuilder.java:154 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:155 + @($classErroneous) = true; + throw new java.lang.ExceptionInInitializerError(twa); + } + //Created by ClassInitializeMethodBuilder.java:249 + @($classInitializationInProgress) = false; + //Created by ClassInitializeMethodBuilder.java:251 + @($classErroneous) = false; + //Created by ClassInitializeMethodBuilder.java:253 + @($classInitialized) = true; + } + } + } + + protected void $prepare() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.name = null; + } + + private void $prepareEnter() { + super.$prepare(); + //Created by PrepareObjectBuilder.java:94 + this.name = null; + } + + public SimpleRecord $create() { + //Created by CreateBuilder.java:57 + this.$initialized = false; + $prepareEnter(); + return this; + } + + public static SimpleRecord $createObject() { + SimpleRecord __NEW__; + //Created by CreateObjectBuilder.java:70 + __NEW__ = SimpleRecord.$allocate(); + __NEW__.$create()@SimpleRecord + return __NEW__; + } +} diff --git a/key.core/pipelineTests/records/input/CompactConstructor.java b/key.core/pipelineTests/records/input/CompactConstructor.java new file mode 100644 index 0000000000..5c4df39be5 --- /dev/null +++ b/key.core/pipelineTests/records/input/CompactConstructor.java @@ -0,0 +1,7 @@ +record Mapping(String from, String to) { + Mapping { + // compact constructor! + from = "abc"; + to = "def"; + } +} diff --git a/key.core/pipelineTests/records/input/InnerRecord.java b/key.core/pipelineTests/records/input/InnerRecord.java new file mode 100644 index 0000000000..81e05b650c --- /dev/null +++ b/key.core/pipelineTests/records/input/InnerRecord.java @@ -0,0 +1,3 @@ +class OuterClass { + final record MyRecord(String test) {} +} \ No newline at end of file diff --git a/key.core/pipelineTests/records/input/NotAllowed.java b/key.core/pipelineTests/records/input/NotAllowed.java new file mode 100644 index 0000000000..dd847278cc --- /dev/null +++ b/key.core/pipelineTests/records/input/NotAllowed.java @@ -0,0 +1,33 @@ +//https://mikemybytes.com/2022/02/16/java-records-and-compact-constructors/ + + +record Name(String name) { // package-private + + // fails with: 'invalid canonical constructor in record Name + // (attempting to assign stronger access privileges; + // was package)' + private Name(String name) { + this.name = name; + } + + static Name of(String name) { + return new Name(name); + } +} + + +record Point(int x, int y) { + Point(int x, int y) { // boring! + this.x = x; + this.y = y; + } + + Point(int x) { // a bit weird... + this(x, 0); // ... but perfectly fine for the compiler + } + + Point() { + // fails with: 'constructor is not canonical, so its first + // statement must invoke another constructor' + } +} diff --git a/key.core/pipelineTests/records/input/RecordOverwriting.java b/key.core/pipelineTests/records/input/RecordOverwriting.java new file mode 100644 index 0000000000..4ac5643d25 --- /dev/null +++ b/key.core/pipelineTests/records/input/RecordOverwriting.java @@ -0,0 +1,13 @@ +/*@ nullable */ record MyRecord(String test) { + public int hashCode() { + return 0; + } + + public boolean equals(Object obj) { + return obj instanceof MyRecord; + } + + public String test() { + return ""; + } +} \ No newline at end of file diff --git a/key.core/pipelineTests/records/input/SimpleRecord.java b/key.core/pipelineTests/records/input/SimpleRecord.java new file mode 100644 index 0000000000..f7c693351f --- /dev/null +++ b/key.core/pipelineTests/records/input/SimpleRecord.java @@ -0,0 +1,7 @@ +public record SimpleRecord(/*@ nullable */ String name) implements Serializable +{ + SimpleRecord( String name ) + { + this.name = name; + } +} \ No newline at end of file diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/Position.java b/key.core/src/main/java/de/uka/ilkd/key/java/Position.java index cc9a29a4cb..9163fc5b53 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/Position.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/Position.java @@ -4,6 +4,7 @@ package de.uka.ilkd.key.java; import org.antlr.v4.runtime.Token; +import org.jspecify.annotations.Nullable; /** * The position of a source element, given by its line and column number. Depending on the @@ -87,8 +88,8 @@ public static Position fromToken(Token token) { return fromOneZeroBased(token.getLine(), token.getCharPositionInLine()); } - public static Position fromJPPosition(com.github.javaparser.Position p) { - if (p.invalid() || (p.line == -1 && p.column == -1)) { + public static Position fromJPPosition(com.github.javaparser.@Nullable Position p) { + if (p == null || p.invalid() || (p.line == -1 && p.column == -1)) { return UNDEFINED; } else { return newOneBased(p.line, p.column); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/loader/JavaParserFactory.java b/key.core/src/main/java/de/uka/ilkd/key/java/loader/JavaParserFactory.java index 9b8389596e..09e540a9a3 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/loader/JavaParserFactory.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/loader/JavaParserFactory.java @@ -90,7 +90,6 @@ public void addUserClasses(Collection classes) { typeSolver.lazyRebuild(); } - @NonNull private ParserConfiguration getConfiguration() { if (config == null) { config = new ParserConfiguration(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/RecordClassBuilder.java b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/RecordClassBuilder.java index cf485ea5b0..1dced66194 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/RecordClassBuilder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/RecordClassBuilder.java @@ -5,9 +5,11 @@ import com.github.javaparser.StaticJavaParser; import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.Modifier; import com.github.javaparser.ast.NodeList; import com.github.javaparser.ast.body.*; import com.github.javaparser.ast.expr.*; +import com.github.javaparser.ast.key.JmlDocModifier; import com.github.javaparser.ast.nodeTypes.NodeWithSimpleName; import com.github.javaparser.ast.stmt.BlockStmt; import com.github.javaparser.ast.stmt.ReturnStmt; @@ -17,6 +19,7 @@ import java.util.Arrays; import java.util.List; +import java.util.Objects; import static com.github.javaparser.ast.Modifier.DefaultKeyword.*; @@ -32,7 +35,6 @@ public RecordClassBuilder(TransformationPipelineServices pipelineServices) { @Override public void apply(CompilationUnit cu) { - System.out.println(cu); cu.walk(RecordDeclaration.class, it -> { ClassOrInterfaceDeclaration clazz = transform(it); it.replace(clazz); @@ -56,6 +58,12 @@ private ClassOrInterfaceDeclaration transform(RecordDeclaration recordDeclaratio MethodDeclaration getter = clazz.addMethod(parameter.getNameAsString()); getter.setType(parameter.type()); getter.addModifier(PUBLIC, FINAL); + for(var mod : parameter.getModifiers()) { + if(mod.getKeyword() instanceof JmlDocModifier) { + getter.getModifiers().add(mod.clone()); + } + } + getter.getBody().get().addStatement(new ReturnStmt(parameter.getNameAsExpression())); } // TODO generate equals and hashcode @@ -69,17 +77,17 @@ private ClassOrInterfaceDeclaration transform(RecordDeclaration recordDeclaratio Type tObject = StaticJavaParser.parseType("java.lang.Object"); equals.getParameters().add(new Parameter(tObject, "o")); BlockStmt body = equals.getBody().get(); - body.addStatement("if(this == other) return true;"); - body.addStatement("if(!(o instanceof %s that)) return false;".formatted(clazz.getNameAsString())); + body.addStatement(services.parseStatement("if(this == o) return true;")); + body.addStatement(services.parseStatement("if(!(o instanceof %s that)) return false;".formatted(clazz.getNameAsString()))); Expression equalFields = recordDeclaration.getParameters().stream() .map(it -> callObjects("equals", it.getNameAsExpression(), - new FieldAccessExpr(new NameExpr("o"), it.getNameAsString()))) + new FieldAccessExpr(new NameExpr("that"), it.getNameAsString()))) .reduce((a, b) -> new BinaryExpr(a, b, BinaryExpr.Operator.AND)) .orElse(new BooleanLiteralExpr(true)); body.addStatement(new ReturnStmt(equalFields)); - body.addStatement("return true"); + body.addStatement(new ReturnStmt(new BooleanLiteralExpr(true))); } if (hasNoHashcode) { @@ -95,7 +103,7 @@ private ClassOrInterfaceDeclaration transform(RecordDeclaration recordDeclaratio .addStatement(new ReturnStmt(call)); } - // TODO generate to String + // TODO generate toString boolean hasNoToString = recordDeclaration.getMethodsBySignature("toString").isEmpty(); if (hasNoToString) { MethodDeclaration toString = clazz.addMethod("toString", PUBLIC, FINAL, JML_NON_NULL); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/TransformationPipelineServices.java b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/TransformationPipelineServices.java index c191d4ddfb..6a9fc78154 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/TransformationPipelineServices.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/TransformationPipelineServices.java @@ -283,6 +283,10 @@ public JavaParser getParser() { return javaParserFactory.createJavaParser(); } + public Statement parseStatement(String code) { + return getParser().parseStatement(code).getResult().orElseThrow(); + } + /** * Cache of important data. This is done mainly for performance reasons. diff --git a/key.core/src/main/java/de/uka/ilkd/key/parser/Location.java b/key.core/src/main/java/de/uka/ilkd/key/parser/Location.java index 8d66e083ea..6620e3e08a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/parser/Location.java +++ b/key.core/src/main/java/de/uka/ilkd/key/parser/Location.java @@ -66,8 +66,7 @@ public static Location fromNode(Node n) { .map(it -> it.getPath().toUri()) .orElse(null); - var pos = n.getRange().map(it -> it.begin).orElseThrow(); - + var pos = n.getRange().map(it -> it.begin).orElse(null); return new Location(fileUri, Position.fromJPPosition(pos)); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/parser/ParserException.java b/key.core/src/main/java/de/uka/ilkd/key/parser/ParserException.java index cd13a25630..ec0aed7373 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/parser/ParserException.java +++ b/key.core/src/main/java/de/uka/ilkd/key/parser/ParserException.java @@ -22,7 +22,7 @@ public final class ParserException extends RuntimeException implements HasLocati * location is unknown or the error is independent of a location. */ public ParserException(String message, Location location) { - super(message); + super(message + " at " + location); this.location = location; } diff --git a/key.core/src/main/resources/de/uka/ilkd/key/java/JavaRedux/java/lang/Objects.java b/key.core/src/main/resources/de/uka/ilkd/key/java/JavaRedux/java/lang/Objects.java new file mode 100644 index 0000000000..b54ceebaa6 --- /dev/null +++ b/key.core/src/main/resources/de/uka/ilkd/key/java/JavaRedux/java/lang/Objects.java @@ -0,0 +1,11 @@ +import java.util.Arrays; + +public class Objects { + public static boolean equals(Object a, Object b) { + return (a == b) || (a != null && a.equals(b)); + } + + public static int hash(Object... values) { + return Arrays.hashCode(values); + } +} \ No newline at end of file diff --git a/key.core/src/main/resources/de/uka/ilkd/key/java/JavaRedux/java/lang/Record.java b/key.core/src/main/resources/de/uka/ilkd/key/java/JavaRedux/java/lang/Record.java new file mode 100644 index 0000000000..fcc1dbb925 --- /dev/null +++ b/key.core/src/main/resources/de/uka/ilkd/key/java/JavaRedux/java/lang/Record.java @@ -0,0 +1,177 @@ +package java.lang; + +/** + * This is the common base class of all Java language record classes. + * + *

More information about records, including descriptions of the + * implicitly declared methods synthesized by the compiler, can be + * found in section 8.10 of + * The Java Language Specification. + * + *

A record class is a shallowly immutable, transparent carrier for + * a fixed set of values, called the record components. The Java + * language provides concise syntax for declaring record classes, whereby the + * record components are declared in the record header. The list of record + * components declared in the record header form the record descriptor. + * + *

A record class has the following mandated members: a canonical + * constructor, which must provide at least as much access as the record + * class and whose descriptor is the same as the record descriptor; + * a private final field corresponding to each component, whose name and + * type are the same as that of the component; a public accessor method + * corresponding to each component, whose name and return type are the same as + * that of the component. If not explicitly declared in the body of the record, + * implicit implementations for these members are provided. + * + *

The implicit declaration of the canonical constructor has the same accessibility + * as the record class and initializes the component fields from the corresponding + * constructor arguments. The implicit declaration of the accessor methods returns + * the value of the corresponding component field. The implicit declaration of the + * {@link Object#equals(Object)}, {@link Object#hashCode()}, and {@link Object#toString()} + * methods are derived from all of the component fields. + * + *

The primary reasons to provide an explicit declaration for the + * canonical constructor or accessor methods are to validate constructor + * arguments, perform defensive copies on mutable components, or normalize groups + * of components (such as reducing a rational number to lowest terms.) + * + *

For all record classes, the following invariant must hold: if a record R's + * components are {@code c1, c2, ... cn}, then if a record instance is copied + * as follows: + *

+ *     R copy = new R(r.c1(), r.c2(), ..., r.cn());
+ * 
+ * then it must be the case that {@code r.equals(copy)}. + * + * @apiNote + * A record class that {@code implements} {@link java.io.Serializable} is said + * to be a serializable record. Serializable records are serialized and + * deserialized differently than ordinary serializable objects. During + * deserialization the record's canonical constructor is invoked to construct + * the record object. Certain serialization-related methods, such as readObject + * and writeObject, are ignored for serializable records. More information about + * serializable records can be found in the + * + * Java Object Serialization Specification, Section 1.13, + * "Serialization of Records". + * + * @apiNote + * A record class structure can be obtained at runtime via reflection. + * See {@link Class#isRecord()} and {@link Class#getRecordComponents()} for more details. + * + * @spec serialization/index.html Java Object Serialization Specification + * @jls 8.10 Record Classes + * @since 16 + */ +public abstract class Record { + /** + * Constructor for record classes to call. + */ + protected Record() {} + + /** + * Indicates whether some other object is "equal to" this one. In addition + * to the general contract of {@link Object#equals(Object) Object.equals}, + * record classes must further obey the invariant that when + * a record instance is "copied" by passing the result of the record component + * accessor methods to the canonical constructor, as follows: + *
+     *     R copy = new R(r.c1(), r.c2(), ..., r.cn());
+     * 
+ * then it must be the case that {@code r.equals(copy)}. + * + * @implSpec + * The implicitly provided implementation returns {@code true} if + * and only if the argument is an instance of the same record class + * as this record, and each component of this record is equal to + * the corresponding component of the argument; otherwise, {@code + * false} is returned. Equality of a component {@code c} is + * determined as follows: + *
    + * + *
  • If the component is of a reference type, the component is + * considered equal if and only if {@link + * java.util.Objects#equals(Object,Object) + * Objects.equals(this.c, r.c)} would return {@code true}. + * + *
  • If the component is of a primitive type, using the + * corresponding primitive wrapper class {@code PW} (the + * corresponding wrapper class for {@code int} is {@code + * java.lang.Integer}, and so on), the component is considered + * equal if and only if {@code + * PW.compare(this.c, r.c)} would return {@code 0}. + * + *
+ * + * Apart from the semantics described above, the precise algorithm + * used in the implicitly provided implementation is unspecified + * and is subject to change. The implementation may or may not use + * calls to the particular methods listed, and may or may not + * perform comparisons in the order of component declaration. + * + * @see java.util.Objects#equals(Object,Object) + * + * @param obj the reference object with which to compare. + * @return {@code true} if this record is equal to the + * argument; {@code false} otherwise. + */ + @Override + public abstract boolean equals(Object obj); + + /** + * Returns a hash code value for the record. + * Obeys the general contract of {@link Object#hashCode Object.hashCode}. + * For records, hashing behavior is constrained by the refined contract + * of {@link Record#equals Record.equals}, so that any two records + * created from the same components must have the same hash code. + * + * @implSpec + * The implicitly provided implementation returns a hash code value derived + * by combining appropriate hashes from each component. + * The precise algorithm used in the implicitly provided implementation + * is unspecified and is subject to change within the above limits. + * The resulting integer need not remain consistent from one + * execution of an application to another execution of the same + * application, even if the hashes of the component values were to + * remain consistent in this way. Also, a component of primitive + * type may contribute its bits to the hash code differently than + * the {@code hashCode} of its primitive wrapper class. + * + * @see Object#hashCode() + * + * @return a hash code value for this record. + */ + @Override + public abstract int hashCode(); + + /** + * Returns a string representation of the record. + * In accordance with the general contract of {@link Object#toString()}, + * the {@code toString} method returns a string that + * "textually represents" this record. The result should + * be a concise but informative representation that is easy for a + * person to read. + *

+ * In addition to this general contract, record classes must further + * participate in the invariant that any two records which are + * {@linkplain Record#equals(Object) equal} must produce equal + * strings. This invariant is necessarily relaxed in the rare + * case where corresponding equal component values might fail + * to produce equal strings for themselves. + * + * @implSpec + * The implicitly provided implementation returns a string which + * contains the name of the record class, the names of components + * of the record, and string representations of component values, + * so as to fulfill the contract of this method. + * The precise format produced by this implicitly provided implementation + * is subject to change, so the present syntax should not be parsed + * by applications to recover record component values. + * + * @see Object#toString() + * + * @return a string representation of the object. + */ + @Override + public abstract String toString(); +} diff --git a/key.core/src/test/java/KeyJavaPipelineTest.java b/key.core/src/test/java/KeyJavaPipelineTest.java index 3a65205eda..d808522aef 100644 --- a/key.core/src/test/java/KeyJavaPipelineTest.java +++ b/key.core/src/test/java/KeyJavaPipelineTest.java @@ -1,39 +1,38 @@ /* This file is part of KeY - https://key-project.org * KeY is licensed under the GNU General Public License Version 2 * SPDX-License-Identifier: GPL-2.0-only */ -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; -import java.util.stream.Stream; - -import de.uka.ilkd.key.java.Services; -import de.uka.ilkd.key.java.transformations.KeYJavaPipeline; -import de.uka.ilkd.key.java.transformations.pipeline.JavaTransformer; -import de.uka.ilkd.key.java.transformations.pipeline.TransformationPipelineServices; -import de.uka.ilkd.key.nparser.NamespaceBuilder; -import de.uka.ilkd.key.proof.init.JavaProfile; import com.github.javaparser.ParseResult; import com.github.javaparser.Problem; import com.github.javaparser.ast.CompilationUnit; -import com.github.javaparser.ast.body.TypeDeclaration; import com.github.javaparser.printer.DefaultPrettyPrinter; import com.github.javaparser.printer.DefaultPrettyPrinterVisitor; import com.github.javaparser.printer.Printer; import com.github.javaparser.printer.configuration.DefaultPrinterConfiguration; import com.github.javaparser.printer.configuration.PrinterConfiguration; import com.google.common.truth.Truth; +import de.uka.ilkd.key.java.Services; +import de.uka.ilkd.key.java.transformations.KeYJavaPipeline; +import de.uka.ilkd.key.java.transformations.pipeline.JavaTransformer; +import de.uka.ilkd.key.java.transformations.pipeline.TransformationPipelineServices; +import de.uka.ilkd.key.nparser.NamespaceBuilder; +import de.uka.ilkd.key.proof.init.JavaProfile; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DynamicTest; import org.junit.jupiter.api.TestFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Stream; + import static org.junit.jupiter.api.Assertions.assertNotNull; /** @@ -51,7 +50,7 @@ public KeYJavaPipeline createPipelineTest(Path testFolder) throws IOException { assertNotNull(nss.sorts().lookup("int")); assertNotNull(nss.sorts().lookup("boolean")); var inputFolder = testFolder.resolve("input"); - var js = services.activateJava(null, Collections.singleton(inputFolder), null); + var js = services.activateJava(null, Collections.emptyList(), null); js.parseSpecialClasses(); final var jp = js.getProgramFactory().createJavaParser(); @@ -73,15 +72,15 @@ public KeYJavaPipeline createPipelineTest(Path testFolder) throws IOException { } }); var tservices = - new TransformationPipelineServices(services.getJavaService().getProgramFactory(), - new TransformationPipelineServices.TransformerCache(cu)); + new TransformationPipelineServices(services.getJavaService().getProgramFactory(), + new TransformationPipelineServices.TransformerCache(cu)); var kjp = KeYJavaPipeline.createDefault(tservices); var kjp2 = new KeYJavaPipeline(tservices); var cnt = 0; for (JavaTransformer step : kjp.getSteps()) { kjp2.add(step); final var file = testFolder.resolve("actual").resolve( - String.format("%02d_%s", ++cnt, step.getClass().getSimpleName())); + String.format("%02d_%s", ++cnt, step.getClass().getSimpleName())); kjp2.add(new DebugOutputTransformer(file, tservices)); } return kjp2; @@ -93,6 +92,11 @@ Stream simple() throws IOException { return generatePipelineTests(Paths.get("pipelineTests/simple").toAbsolutePath()); } + @TestFactory + Stream records() throws IOException { + return generatePipelineTests(Paths.get("pipelineTests/records").toAbsolutePath()); + } + @TestFactory Stream innerclass() throws IOException { return generatePipelineTests(Paths.get("pipelineTests/innerclass").toAbsolutePath()); @@ -108,7 +112,7 @@ private Stream generatePipelineTests(Path testFolder) throws IOExce return Files.walk(expected) .filter(Files::isRegularFile) .map(it -> DynamicTest.dynamicTest(it.toString(), - () -> checkEqualFile(it, expected, actual))); + () -> checkEqualFile(it, expected, actual))); } private void checkEqualFile(Path expectedFile, Path expectedFolder, Path actualFolder) @@ -128,8 +132,8 @@ private static class DebugOutputTransformer extends JavaTransformer { final Set alreadyWritten = new HashSet<>(); private static final Logger LOGGER = LoggerFactory.getLogger(DebugOutputTransformer.class); private final Printer myPrinter = new DefaultPrettyPrinter( - MyPrintVisitor::new, - new DefaultPrinterConfiguration()); + MyPrintVisitor::new, + new DefaultPrinterConfiguration()); public DebugOutputTransformer(Path s, TransformationPipelineServices services) { @@ -138,24 +142,19 @@ public DebugOutputTransformer(Path s, TransformationPipelineServices services) { } @Override - public void apply(TypeDeclaration td) { + public void apply(CompilationUnit unit) { try { Files.createDirectories(outputFolder); } catch (IOException e) { e.printStackTrace(); } - for (CompilationUnit unit : services.getCache().getUnits()) { - var name = unit.getPrimaryTypeName().get(); - var file = outputFolder.resolve(name + ".java"); - if (!alreadyWritten.contains(file)) { - alreadyWritten.add(file); - try { - unit.printer(myPrinter); - Files.writeString(file, unit.toString()); - } catch (IOException e) { - LOGGER.error(e.getMessage(), e); - } - } + var name = unit.getStorage().get().getFileName(); + var file = outputFolder.resolve(name); + try { + unit.printer(myPrinter); + Files.writeString(file, unit.toString()); + } catch (IOException e) { + LOGGER.error(e.getMessage(), e); } } } From 7296f513e962783595650d2c7af4d38630ee6cc1 Mon Sep 17 00:00:00 2001 From: Alexander Weigl Date: Sun, 29 Mar 2026 12:16:47 +0200 Subject: [PATCH 3/8] update test oracle pipelineTests --- .../02_JMLTransformer/MostSimpleInner.java | 5 - .../03_JmlDocRemoval/MostSimpleInner.java | 5 - .../MostSimpleInner.java | 41 --- .../MostSimpleInner.java | 45 ---- .../MostSimpleInner.java | 61 ----- .../MostSimpleInner.java | 67 ----- .../MostSimpleInner.java | 143 ----------- .../MostSimpleInner.java | 159 ------------ .../10_CreateBuilder/MostSimpleInner.java | 173 ------------- .../MostSimpleInner.java | 189 -------------- .../MostSimpleInner.java | 189 -------------- .../CompactConstructor.java | 2 +- .../02_RecordClassBuilder/InnerRecord.java | 2 +- .../02_RecordClassBuilder/NotAllowed.java | 4 +- .../RecordOverwriting.java | 2 +- .../02_RecordClassBuilder/SimpleRecord.java | 2 +- .../03_JMLTransformer/CompactConstructor.java | 2 +- .../03_JMLTransformer/InnerRecord.java | 2 +- .../03_JMLTransformer/NotAllowed.java | 4 +- .../03_JMLTransformer/RecordOverwriting.java | 2 +- .../03_JMLTransformer/SimpleRecord.java | 2 +- .../04_JmlDocRemoval/CompactConstructor.java | 2 +- .../04_JmlDocRemoval/InnerRecord.java | 2 +- .../expected/04_JmlDocRemoval/NotAllowed.java | 4 +- .../04_JmlDocRemoval/RecordOverwriting.java | 2 +- .../04_JmlDocRemoval/SimpleRecord.java | 2 +- .../CompactConstructor.java | 6 +- .../05_ImplicitFieldAdder/InnerRecord.java | 10 +- .../05_ImplicitFieldAdder/NotAllowed.java | 12 +- .../RecordOverwriting.java | 6 +- .../05_ImplicitFieldAdder/SimpleRecord.java | 6 +- .../CompactConstructor.java | 6 +- .../InnerRecord.java | 10 +- .../NotAllowed.java | 12 +- .../RecordOverwriting.java | 6 +- .../SimpleRecord.java | 6 +- .../CompactConstructor.java | 6 +- .../InnerRecord.java | 10 +- .../NotAllowed.java | 12 +- .../RecordOverwriting.java | 6 +- .../SimpleRecord.java | 6 +- .../CompactConstructor.java | 6 +- .../InnerRecord.java | 10 +- .../NotAllowed.java | 12 +- .../RecordOverwriting.java | 6 +- .../SimpleRecord.java | 6 +- .../CompactConstructor.java | 6 +- .../InnerRecord.java | 10 +- .../NotAllowed.java | 12 +- .../RecordOverwriting.java | 6 +- .../SimpleRecord.java | 6 +- .../CompactConstructor.java | 6 +- .../10_PrepareObjectBuilder/InnerRecord.java | 10 +- .../10_PrepareObjectBuilder/NotAllowed.java | 12 +- .../RecordOverwriting.java | 6 +- .../10_PrepareObjectBuilder/SimpleRecord.java | 6 +- .../11_CreateBuilder/CompactConstructor.java | 6 +- .../11_CreateBuilder/InnerRecord.java | 10 +- .../expected/11_CreateBuilder/NotAllowed.java | 12 +- .../11_CreateBuilder/RecordOverwriting.java | 6 +- .../11_CreateBuilder/SimpleRecord.java | 6 +- .../CompactConstructor.java | 6 +- .../12_CreateObjectBuilder/InnerRecord.java | 10 +- .../12_CreateObjectBuilder/NotAllowed.java | 12 +- .../RecordOverwriting.java | 6 +- .../12_CreateObjectBuilder/SimpleRecord.java | 6 +- .../CompactConstructor.java | 6 +- .../InnerRecord.java | 10 +- .../NotAllowed.java | 12 +- .../RecordOverwriting.java | 6 +- .../SimpleRecord.java | 6 +- .../CompactConstructor.java | 6 +- .../InnerRecord.java | 10 +- .../NotAllowed.java | 12 +- .../RecordOverwriting.java | 6 +- .../SimpleRecord.java | 6 +- .../expected/02_JMLTransformer/Test.java | 24 -- .../expected/03_JmlDocRemoval/Test.java | 24 -- .../expected/04_ImplicitFieldAdder/Test.java | 60 ----- .../Test.java | 64 ----- .../06_ConstructorNormalformBuilder/Test.java | 100 -------- .../Test.java | 106 -------- .../08_ClassInitializeMethodBuilder/Test.java | 186 -------------- .../09_PrepareObjectBuilder/Test.java | 210 --------------- .../expected/10_CreateBuilder/Test.java | 224 ---------------- .../expected/11_CreateObjectBuilder/Test.java | 240 ------------------ .../12_LocalClassTransformation/Test.java | 240 ------------------ 87 files changed, 218 insertions(+), 2773 deletions(-) delete mode 100644 key.core/pipelineTests/innerclass/expected/02_JMLTransformer/MostSimpleInner.java delete mode 100644 key.core/pipelineTests/innerclass/expected/03_JmlDocRemoval/MostSimpleInner.java delete mode 100644 key.core/pipelineTests/innerclass/expected/04_ImplicitFieldAdder/MostSimpleInner.java delete mode 100644 key.core/pipelineTests/innerclass/expected/05_InstanceAllocationMethodBuilder/MostSimpleInner.java delete mode 100644 key.core/pipelineTests/innerclass/expected/06_ConstructorNormalformBuilder/MostSimpleInner.java delete mode 100644 key.core/pipelineTests/innerclass/expected/07_ClassPreparationMethodBuilder/MostSimpleInner.java delete mode 100644 key.core/pipelineTests/innerclass/expected/08_ClassInitializeMethodBuilder/MostSimpleInner.java delete mode 100644 key.core/pipelineTests/innerclass/expected/09_PrepareObjectBuilder/MostSimpleInner.java delete mode 100644 key.core/pipelineTests/innerclass/expected/10_CreateBuilder/MostSimpleInner.java delete mode 100644 key.core/pipelineTests/innerclass/expected/11_CreateObjectBuilder/MostSimpleInner.java delete mode 100644 key.core/pipelineTests/innerclass/expected/12_LocalClassTransformation/MostSimpleInner.java delete mode 100644 key.core/pipelineTests/simple/expected/02_JMLTransformer/Test.java delete mode 100644 key.core/pipelineTests/simple/expected/03_JmlDocRemoval/Test.java delete mode 100644 key.core/pipelineTests/simple/expected/04_ImplicitFieldAdder/Test.java delete mode 100644 key.core/pipelineTests/simple/expected/05_InstanceAllocationMethodBuilder/Test.java delete mode 100644 key.core/pipelineTests/simple/expected/06_ConstructorNormalformBuilder/Test.java delete mode 100644 key.core/pipelineTests/simple/expected/07_ClassPreparationMethodBuilder/Test.java delete mode 100644 key.core/pipelineTests/simple/expected/08_ClassInitializeMethodBuilder/Test.java delete mode 100644 key.core/pipelineTests/simple/expected/09_PrepareObjectBuilder/Test.java delete mode 100644 key.core/pipelineTests/simple/expected/10_CreateBuilder/Test.java delete mode 100644 key.core/pipelineTests/simple/expected/11_CreateObjectBuilder/Test.java delete mode 100644 key.core/pipelineTests/simple/expected/12_LocalClassTransformation/Test.java diff --git a/key.core/pipelineTests/innerclass/expected/02_JMLTransformer/MostSimpleInner.java b/key.core/pipelineTests/innerclass/expected/02_JMLTransformer/MostSimpleInner.java deleted file mode 100644 index a7764c2a00..0000000000 --- a/key.core/pipelineTests/innerclass/expected/02_JMLTransformer/MostSimpleInner.java +++ /dev/null @@ -1,5 +0,0 @@ -public class MostSimpleInner { - - public static class MyInnerClass { - } -} diff --git a/key.core/pipelineTests/innerclass/expected/03_JmlDocRemoval/MostSimpleInner.java b/key.core/pipelineTests/innerclass/expected/03_JmlDocRemoval/MostSimpleInner.java deleted file mode 100644 index a7764c2a00..0000000000 --- a/key.core/pipelineTests/innerclass/expected/03_JmlDocRemoval/MostSimpleInner.java +++ /dev/null @@ -1,5 +0,0 @@ -public class MostSimpleInner { - - public static class MyInnerClass { - } -} diff --git a/key.core/pipelineTests/innerclass/expected/04_ImplicitFieldAdder/MostSimpleInner.java b/key.core/pipelineTests/innerclass/expected/04_ImplicitFieldAdder/MostSimpleInner.java deleted file mode 100644 index ae893d9a18..0000000000 --- a/key.core/pipelineTests/innerclass/expected/04_ImplicitFieldAdder/MostSimpleInner.java +++ /dev/null @@ -1,41 +0,0 @@ -public class MostSimpleInner { - - public static class MyInnerClass { - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - } - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; -} diff --git a/key.core/pipelineTests/innerclass/expected/05_InstanceAllocationMethodBuilder/MostSimpleInner.java b/key.core/pipelineTests/innerclass/expected/05_InstanceAllocationMethodBuilder/MostSimpleInner.java deleted file mode 100644 index cbb206f257..0000000000 --- a/key.core/pipelineTests/innerclass/expected/05_InstanceAllocationMethodBuilder/MostSimpleInner.java +++ /dev/null @@ -1,45 +0,0 @@ -public class MostSimpleInner { - - public static class MyInnerClass { - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static MyInnerClass $allocate(); - } - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static MostSimpleInner $allocate(); -} diff --git a/key.core/pipelineTests/innerclass/expected/06_ConstructorNormalformBuilder/MostSimpleInner.java b/key.core/pipelineTests/innerclass/expected/06_ConstructorNormalformBuilder/MostSimpleInner.java deleted file mode 100644 index 59fd6e1b31..0000000000 --- a/key.core/pipelineTests/innerclass/expected/06_ConstructorNormalformBuilder/MostSimpleInner.java +++ /dev/null @@ -1,61 +0,0 @@ -public class MostSimpleInner { - - public static class MyInnerClass { - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static MyInnerClass $allocate(); - - public MyInnerClass() { - } - - public void $init() { - super.$init(); - super.$init(); - } - } - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static MostSimpleInner $allocate(); - - public MostSimpleInner() { - } - - public void $init() { - super.$init(); - super.$init(); - } -} diff --git a/key.core/pipelineTests/innerclass/expected/07_ClassPreparationMethodBuilder/MostSimpleInner.java b/key.core/pipelineTests/innerclass/expected/07_ClassPreparationMethodBuilder/MostSimpleInner.java deleted file mode 100644 index 803b9be00b..0000000000 --- a/key.core/pipelineTests/innerclass/expected/07_ClassPreparationMethodBuilder/MostSimpleInner.java +++ /dev/null @@ -1,67 +0,0 @@ -public class MostSimpleInner { - - public static class MyInnerClass { - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static MyInnerClass $allocate(); - - public MyInnerClass() { - } - - public void $init() { - super.$init(); - super.$init(); - } - - static private void $clprepare() { - } - } - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static MostSimpleInner $allocate(); - - public MostSimpleInner() { - } - - public void $init() { - super.$init(); - super.$init(); - } - - static private void $clprepare() { - } -} diff --git a/key.core/pipelineTests/innerclass/expected/08_ClassInitializeMethodBuilder/MostSimpleInner.java b/key.core/pipelineTests/innerclass/expected/08_ClassInitializeMethodBuilder/MostSimpleInner.java deleted file mode 100644 index 3c16037316..0000000000 --- a/key.core/pipelineTests/innerclass/expected/08_ClassInitializeMethodBuilder/MostSimpleInner.java +++ /dev/null @@ -1,143 +0,0 @@ -public class MostSimpleInner { - - public static class MyInnerClass { - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static MyInnerClass $allocate(); - - public MyInnerClass() { - } - - public void $init() { - super.$init(); - super.$init(); - } - - static private void $clprepare() { - } - - static public void $clinit() { - if (!@($classInitialized)) { - if (!@($classInitializationInProgress)) { - if (!@($classPrepared)) { - //Created by ClassInitializeMethodBuilder.java:219 - @($clprepare()); - } - if (@($classErroneous)) { - throw new java.lang.NoClassDefFoundError(); - } - //Created by ClassInitializeMethodBuilder.java:243 - @($classInitializationInProgress) = true; - try { - @(java.lang.Object.$clinit()); - }//Created by ClassInitializeMethodBuilder.java:194 - catch (java.lang.Error err) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw err; - } catch (java.lang.Throwable twa) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw new java.lang.ExceptionInInitializerError(twa); - } - //Created by ClassInitializeMethodBuilder.java:249 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:251 - @($classErroneous) = false; - //Created by ClassInitializeMethodBuilder.java:253 - @($classInitialized) = true; - } - } - } - } - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static MostSimpleInner $allocate(); - - public MostSimpleInner() { - } - - public void $init() { - super.$init(); - super.$init(); - } - - static private void $clprepare() { - } - - static public void $clinit() { - if (!@($classInitialized)) { - if (!@($classInitializationInProgress)) { - if (!@($classPrepared)) { - //Created by ClassInitializeMethodBuilder.java:219 - @($clprepare()); - } - if (@($classErroneous)) { - throw new java.lang.NoClassDefFoundError(); - } - //Created by ClassInitializeMethodBuilder.java:243 - @($classInitializationInProgress) = true; - try { - @(java.lang.Object.$clinit()); - }//Created by ClassInitializeMethodBuilder.java:194 - catch (java.lang.Error err) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw err; - } catch (java.lang.Throwable twa) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw new java.lang.ExceptionInInitializerError(twa); - } - //Created by ClassInitializeMethodBuilder.java:249 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:251 - @($classErroneous) = false; - //Created by ClassInitializeMethodBuilder.java:253 - @($classInitialized) = true; - } - } - } -} diff --git a/key.core/pipelineTests/innerclass/expected/09_PrepareObjectBuilder/MostSimpleInner.java b/key.core/pipelineTests/innerclass/expected/09_PrepareObjectBuilder/MostSimpleInner.java deleted file mode 100644 index b4d0f07a14..0000000000 --- a/key.core/pipelineTests/innerclass/expected/09_PrepareObjectBuilder/MostSimpleInner.java +++ /dev/null @@ -1,159 +0,0 @@ -public class MostSimpleInner { - - public static class MyInnerClass { - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static MyInnerClass $allocate(); - - public MyInnerClass() { - } - - public void $init() { - super.$init(); - super.$init(); - } - - static private void $clprepare() { - } - - static public void $clinit() { - if (!@($classInitialized)) { - if (!@($classInitializationInProgress)) { - if (!@($classPrepared)) { - //Created by ClassInitializeMethodBuilder.java:219 - @($clprepare()); - } - if (@($classErroneous)) { - throw new java.lang.NoClassDefFoundError(); - } - //Created by ClassInitializeMethodBuilder.java:243 - @($classInitializationInProgress) = true; - try { - @(java.lang.Object.$clinit()); - }//Created by ClassInitializeMethodBuilder.java:194 - catch (java.lang.Error err) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw err; - } catch (java.lang.Throwable twa) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw new java.lang.ExceptionInInitializerError(twa); - } - //Created by ClassInitializeMethodBuilder.java:249 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:251 - @($classErroneous) = false; - //Created by ClassInitializeMethodBuilder.java:253 - @($classInitialized) = true; - } - } - } - - protected void $prepare() { - super.$prepare(); - } - - private void $prepareEnter() { - super.$prepare(); - } - } - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static MostSimpleInner $allocate(); - - public MostSimpleInner() { - } - - public void $init() { - super.$init(); - super.$init(); - } - - static private void $clprepare() { - } - - static public void $clinit() { - if (!@($classInitialized)) { - if (!@($classInitializationInProgress)) { - if (!@($classPrepared)) { - //Created by ClassInitializeMethodBuilder.java:219 - @($clprepare()); - } - if (@($classErroneous)) { - throw new java.lang.NoClassDefFoundError(); - } - //Created by ClassInitializeMethodBuilder.java:243 - @($classInitializationInProgress) = true; - try { - @(java.lang.Object.$clinit()); - }//Created by ClassInitializeMethodBuilder.java:194 - catch (java.lang.Error err) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw err; - } catch (java.lang.Throwable twa) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw new java.lang.ExceptionInInitializerError(twa); - } - //Created by ClassInitializeMethodBuilder.java:249 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:251 - @($classErroneous) = false; - //Created by ClassInitializeMethodBuilder.java:253 - @($classInitialized) = true; - } - } - } - - protected void $prepare() { - super.$prepare(); - } - - private void $prepareEnter() { - super.$prepare(); - } -} diff --git a/key.core/pipelineTests/innerclass/expected/10_CreateBuilder/MostSimpleInner.java b/key.core/pipelineTests/innerclass/expected/10_CreateBuilder/MostSimpleInner.java deleted file mode 100644 index 3bc13f1ae1..0000000000 --- a/key.core/pipelineTests/innerclass/expected/10_CreateBuilder/MostSimpleInner.java +++ /dev/null @@ -1,173 +0,0 @@ -public class MostSimpleInner { - - public static class MyInnerClass { - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static MyInnerClass $allocate(); - - public MyInnerClass() { - } - - public void $init() { - super.$init(); - super.$init(); - } - - static private void $clprepare() { - } - - static public void $clinit() { - if (!@($classInitialized)) { - if (!@($classInitializationInProgress)) { - if (!@($classPrepared)) { - //Created by ClassInitializeMethodBuilder.java:219 - @($clprepare()); - } - if (@($classErroneous)) { - throw new java.lang.NoClassDefFoundError(); - } - //Created by ClassInitializeMethodBuilder.java:243 - @($classInitializationInProgress) = true; - try { - @(java.lang.Object.$clinit()); - }//Created by ClassInitializeMethodBuilder.java:194 - catch (java.lang.Error err) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw err; - } catch (java.lang.Throwable twa) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw new java.lang.ExceptionInInitializerError(twa); - } - //Created by ClassInitializeMethodBuilder.java:249 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:251 - @($classErroneous) = false; - //Created by ClassInitializeMethodBuilder.java:253 - @($classInitialized) = true; - } - } - } - - protected void $prepare() { - super.$prepare(); - } - - private void $prepareEnter() { - super.$prepare(); - } - - public MyInnerClass $create() { - //Created by CreateBuilder.java:57 - this.$initialized = false; - $prepareEnter(); - return this; - } - } - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static MostSimpleInner $allocate(); - - public MostSimpleInner() { - } - - public void $init() { - super.$init(); - super.$init(); - } - - static private void $clprepare() { - } - - static public void $clinit() { - if (!@($classInitialized)) { - if (!@($classInitializationInProgress)) { - if (!@($classPrepared)) { - //Created by ClassInitializeMethodBuilder.java:219 - @($clprepare()); - } - if (@($classErroneous)) { - throw new java.lang.NoClassDefFoundError(); - } - //Created by ClassInitializeMethodBuilder.java:243 - @($classInitializationInProgress) = true; - try { - @(java.lang.Object.$clinit()); - }//Created by ClassInitializeMethodBuilder.java:194 - catch (java.lang.Error err) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw err; - } catch (java.lang.Throwable twa) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw new java.lang.ExceptionInInitializerError(twa); - } - //Created by ClassInitializeMethodBuilder.java:249 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:251 - @($classErroneous) = false; - //Created by ClassInitializeMethodBuilder.java:253 - @($classInitialized) = true; - } - } - } - - protected void $prepare() { - super.$prepare(); - } - - private void $prepareEnter() { - super.$prepare(); - } - - public MostSimpleInner $create() { - //Created by CreateBuilder.java:57 - this.$initialized = false; - $prepareEnter(); - return this; - } -} diff --git a/key.core/pipelineTests/innerclass/expected/11_CreateObjectBuilder/MostSimpleInner.java b/key.core/pipelineTests/innerclass/expected/11_CreateObjectBuilder/MostSimpleInner.java deleted file mode 100644 index decd2bad90..0000000000 --- a/key.core/pipelineTests/innerclass/expected/11_CreateObjectBuilder/MostSimpleInner.java +++ /dev/null @@ -1,189 +0,0 @@ -public class MostSimpleInner { - - public static class MyInnerClass { - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static MyInnerClass $allocate(); - - public MyInnerClass() { - } - - public void $init() { - super.$init(); - super.$init(); - } - - static private void $clprepare() { - } - - static public void $clinit() { - if (!@($classInitialized)) { - if (!@($classInitializationInProgress)) { - if (!@($classPrepared)) { - //Created by ClassInitializeMethodBuilder.java:219 - @($clprepare()); - } - if (@($classErroneous)) { - throw new java.lang.NoClassDefFoundError(); - } - //Created by ClassInitializeMethodBuilder.java:243 - @($classInitializationInProgress) = true; - try { - @(java.lang.Object.$clinit()); - }//Created by ClassInitializeMethodBuilder.java:194 - catch (java.lang.Error err) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw err; - } catch (java.lang.Throwable twa) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw new java.lang.ExceptionInInitializerError(twa); - } - //Created by ClassInitializeMethodBuilder.java:249 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:251 - @($classErroneous) = false; - //Created by ClassInitializeMethodBuilder.java:253 - @($classInitialized) = true; - } - } - } - - protected void $prepare() { - super.$prepare(); - } - - private void $prepareEnter() { - super.$prepare(); - } - - public MyInnerClass $create() { - //Created by CreateBuilder.java:57 - this.$initialized = false; - $prepareEnter(); - return this; - } - - public static MyInnerClass $createObject() { - MyInnerClass __NEW__; - //Created by CreateObjectBuilder.java:70 - __NEW__ = MyInnerClass.$allocate(); - __NEW__.$create()@MyInnerClass - return __NEW__; - } - } - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static MostSimpleInner $allocate(); - - public MostSimpleInner() { - } - - public void $init() { - super.$init(); - super.$init(); - } - - static private void $clprepare() { - } - - static public void $clinit() { - if (!@($classInitialized)) { - if (!@($classInitializationInProgress)) { - if (!@($classPrepared)) { - //Created by ClassInitializeMethodBuilder.java:219 - @($clprepare()); - } - if (@($classErroneous)) { - throw new java.lang.NoClassDefFoundError(); - } - //Created by ClassInitializeMethodBuilder.java:243 - @($classInitializationInProgress) = true; - try { - @(java.lang.Object.$clinit()); - }//Created by ClassInitializeMethodBuilder.java:194 - catch (java.lang.Error err) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw err; - } catch (java.lang.Throwable twa) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw new java.lang.ExceptionInInitializerError(twa); - } - //Created by ClassInitializeMethodBuilder.java:249 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:251 - @($classErroneous) = false; - //Created by ClassInitializeMethodBuilder.java:253 - @($classInitialized) = true; - } - } - } - - protected void $prepare() { - super.$prepare(); - } - - private void $prepareEnter() { - super.$prepare(); - } - - public MostSimpleInner $create() { - //Created by CreateBuilder.java:57 - this.$initialized = false; - $prepareEnter(); - return this; - } - - public static MostSimpleInner $createObject() { - MostSimpleInner __NEW__; - //Created by CreateObjectBuilder.java:70 - __NEW__ = MostSimpleInner.$allocate(); - __NEW__.$create()@MostSimpleInner - return __NEW__; - } -} diff --git a/key.core/pipelineTests/innerclass/expected/12_LocalClassTransformation/MostSimpleInner.java b/key.core/pipelineTests/innerclass/expected/12_LocalClassTransformation/MostSimpleInner.java deleted file mode 100644 index decd2bad90..0000000000 --- a/key.core/pipelineTests/innerclass/expected/12_LocalClassTransformation/MostSimpleInner.java +++ /dev/null @@ -1,189 +0,0 @@ -public class MostSimpleInner { - - public static class MyInnerClass { - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static MyInnerClass $allocate(); - - public MyInnerClass() { - } - - public void $init() { - super.$init(); - super.$init(); - } - - static private void $clprepare() { - } - - static public void $clinit() { - if (!@($classInitialized)) { - if (!@($classInitializationInProgress)) { - if (!@($classPrepared)) { - //Created by ClassInitializeMethodBuilder.java:219 - @($clprepare()); - } - if (@($classErroneous)) { - throw new java.lang.NoClassDefFoundError(); - } - //Created by ClassInitializeMethodBuilder.java:243 - @($classInitializationInProgress) = true; - try { - @(java.lang.Object.$clinit()); - }//Created by ClassInitializeMethodBuilder.java:194 - catch (java.lang.Error err) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw err; - } catch (java.lang.Throwable twa) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw new java.lang.ExceptionInInitializerError(twa); - } - //Created by ClassInitializeMethodBuilder.java:249 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:251 - @($classErroneous) = false; - //Created by ClassInitializeMethodBuilder.java:253 - @($classInitialized) = true; - } - } - } - - protected void $prepare() { - super.$prepare(); - } - - private void $prepareEnter() { - super.$prepare(); - } - - public MyInnerClass $create() { - //Created by CreateBuilder.java:57 - this.$initialized = false; - $prepareEnter(); - return this; - } - - public static MyInnerClass $createObject() { - MyInnerClass __NEW__; - //Created by CreateObjectBuilder.java:70 - __NEW__ = MyInnerClass.$allocate(); - __NEW__.$create()@MyInnerClass - return __NEW__; - } - } - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static MostSimpleInner $allocate(); - - public MostSimpleInner() { - } - - public void $init() { - super.$init(); - super.$init(); - } - - static private void $clprepare() { - } - - static public void $clinit() { - if (!@($classInitialized)) { - if (!@($classInitializationInProgress)) { - if (!@($classPrepared)) { - //Created by ClassInitializeMethodBuilder.java:219 - @($clprepare()); - } - if (@($classErroneous)) { - throw new java.lang.NoClassDefFoundError(); - } - //Created by ClassInitializeMethodBuilder.java:243 - @($classInitializationInProgress) = true; - try { - @(java.lang.Object.$clinit()); - }//Created by ClassInitializeMethodBuilder.java:194 - catch (java.lang.Error err) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw err; - } catch (java.lang.Throwable twa) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw new java.lang.ExceptionInInitializerError(twa); - } - //Created by ClassInitializeMethodBuilder.java:249 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:251 - @($classErroneous) = false; - //Created by ClassInitializeMethodBuilder.java:253 - @($classInitialized) = true; - } - } - } - - protected void $prepare() { - super.$prepare(); - } - - private void $prepareEnter() { - super.$prepare(); - } - - public MostSimpleInner $create() { - //Created by CreateBuilder.java:57 - this.$initialized = false; - $prepareEnter(); - return this; - } - - public static MostSimpleInner $createObject() { - MostSimpleInner __NEW__; - //Created by CreateObjectBuilder.java:70 - __NEW__ = MostSimpleInner.$allocate(); - __NEW__.$create()@MostSimpleInner - return __NEW__; - } -} diff --git a/key.core/pipelineTests/records/expected/02_RecordClassBuilder/CompactConstructor.java b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/CompactConstructor.java index 74cb97ebc0..639557a99b 100644 --- a/key.core/pipelineTests/records/expected/02_RecordClassBuilder/CompactConstructor.java +++ b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/CompactConstructor.java @@ -19,7 +19,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Mapping that)) return false; - return java.lang.Objects.equals(from, o.from) && java.lang.Objects.equals(to, o.to); + return java.lang.Objects.equals(from, that.from) && java.lang.Objects.equals(to, that.to); return true; } diff --git a/key.core/pipelineTests/records/expected/02_RecordClassBuilder/InnerRecord.java b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/InnerRecord.java index 89ef5cf296..7c4ad3556a 100644 --- a/key.core/pipelineTests/records/expected/02_RecordClassBuilder/InnerRecord.java +++ b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/InnerRecord.java @@ -15,7 +15,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof MyRecord that)) return false; - return java.lang.Objects.equals(test, o.test); + return java.lang.Objects.equals(test, that.test); return true; } diff --git a/key.core/pipelineTests/records/expected/02_RecordClassBuilder/NotAllowed.java b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/NotAllowed.java index 37ed87d5e1..1fb5d2ed73 100644 --- a/key.core/pipelineTests/records/expected/02_RecordClassBuilder/NotAllowed.java +++ b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/NotAllowed.java @@ -15,7 +15,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Name that)) return false; - return java.lang.Objects.equals(name, o.name); + return java.lang.Objects.equals(name, that.name); return true; } @@ -60,7 +60,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Point that)) return false; - return java.lang.Objects.equals(x, o.x) && java.lang.Objects.equals(y, o.y); + return java.lang.Objects.equals(x, that.x) && java.lang.Objects.equals(y, that.y); return true; } diff --git a/key.core/pipelineTests/records/expected/02_RecordClassBuilder/RecordOverwriting.java b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/RecordOverwriting.java index 3a3143172f..dd06d25703 100644 --- a/key.core/pipelineTests/records/expected/02_RecordClassBuilder/RecordOverwriting.java +++ b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/RecordOverwriting.java @@ -13,7 +13,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof MyRecord that)) return false; - return java.lang.Objects.equals(test, o.test); + return java.lang.Objects.equals(test, that.test); return true; } diff --git a/key.core/pipelineTests/records/expected/02_RecordClassBuilder/SimpleRecord.java b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/SimpleRecord.java index 06bbeb96c5..486dff4fd0 100644 --- a/key.core/pipelineTests/records/expected/02_RecordClassBuilder/SimpleRecord.java +++ b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/SimpleRecord.java @@ -13,7 +13,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof SimpleRecord that)) return false; - return java.lang.Objects.equals(name, o.name); + return java.lang.Objects.equals(name, that.name); return true; } diff --git a/key.core/pipelineTests/records/expected/03_JMLTransformer/CompactConstructor.java b/key.core/pipelineTests/records/expected/03_JMLTransformer/CompactConstructor.java index 74cb97ebc0..639557a99b 100644 --- a/key.core/pipelineTests/records/expected/03_JMLTransformer/CompactConstructor.java +++ b/key.core/pipelineTests/records/expected/03_JMLTransformer/CompactConstructor.java @@ -19,7 +19,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Mapping that)) return false; - return java.lang.Objects.equals(from, o.from) && java.lang.Objects.equals(to, o.to); + return java.lang.Objects.equals(from, that.from) && java.lang.Objects.equals(to, that.to); return true; } diff --git a/key.core/pipelineTests/records/expected/03_JMLTransformer/InnerRecord.java b/key.core/pipelineTests/records/expected/03_JMLTransformer/InnerRecord.java index 89ef5cf296..7c4ad3556a 100644 --- a/key.core/pipelineTests/records/expected/03_JMLTransformer/InnerRecord.java +++ b/key.core/pipelineTests/records/expected/03_JMLTransformer/InnerRecord.java @@ -15,7 +15,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof MyRecord that)) return false; - return java.lang.Objects.equals(test, o.test); + return java.lang.Objects.equals(test, that.test); return true; } diff --git a/key.core/pipelineTests/records/expected/03_JMLTransformer/NotAllowed.java b/key.core/pipelineTests/records/expected/03_JMLTransformer/NotAllowed.java index 37ed87d5e1..1fb5d2ed73 100644 --- a/key.core/pipelineTests/records/expected/03_JMLTransformer/NotAllowed.java +++ b/key.core/pipelineTests/records/expected/03_JMLTransformer/NotAllowed.java @@ -15,7 +15,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Name that)) return false; - return java.lang.Objects.equals(name, o.name); + return java.lang.Objects.equals(name, that.name); return true; } @@ -60,7 +60,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Point that)) return false; - return java.lang.Objects.equals(x, o.x) && java.lang.Objects.equals(y, o.y); + return java.lang.Objects.equals(x, that.x) && java.lang.Objects.equals(y, that.y); return true; } diff --git a/key.core/pipelineTests/records/expected/03_JMLTransformer/RecordOverwriting.java b/key.core/pipelineTests/records/expected/03_JMLTransformer/RecordOverwriting.java index 3a3143172f..dd06d25703 100644 --- a/key.core/pipelineTests/records/expected/03_JMLTransformer/RecordOverwriting.java +++ b/key.core/pipelineTests/records/expected/03_JMLTransformer/RecordOverwriting.java @@ -13,7 +13,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof MyRecord that)) return false; - return java.lang.Objects.equals(test, o.test); + return java.lang.Objects.equals(test, that.test); return true; } diff --git a/key.core/pipelineTests/records/expected/03_JMLTransformer/SimpleRecord.java b/key.core/pipelineTests/records/expected/03_JMLTransformer/SimpleRecord.java index faa5353e03..a321870cb4 100644 --- a/key.core/pipelineTests/records/expected/03_JMLTransformer/SimpleRecord.java +++ b/key.core/pipelineTests/records/expected/03_JMLTransformer/SimpleRecord.java @@ -13,7 +13,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof SimpleRecord that)) return false; - return java.lang.Objects.equals(name, o.name); + return java.lang.Objects.equals(name, that.name); return true; } diff --git a/key.core/pipelineTests/records/expected/04_JmlDocRemoval/CompactConstructor.java b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/CompactConstructor.java index 74cb97ebc0..639557a99b 100644 --- a/key.core/pipelineTests/records/expected/04_JmlDocRemoval/CompactConstructor.java +++ b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/CompactConstructor.java @@ -19,7 +19,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Mapping that)) return false; - return java.lang.Objects.equals(from, o.from) && java.lang.Objects.equals(to, o.to); + return java.lang.Objects.equals(from, that.from) && java.lang.Objects.equals(to, that.to); return true; } diff --git a/key.core/pipelineTests/records/expected/04_JmlDocRemoval/InnerRecord.java b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/InnerRecord.java index 89ef5cf296..7c4ad3556a 100644 --- a/key.core/pipelineTests/records/expected/04_JmlDocRemoval/InnerRecord.java +++ b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/InnerRecord.java @@ -15,7 +15,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof MyRecord that)) return false; - return java.lang.Objects.equals(test, o.test); + return java.lang.Objects.equals(test, that.test); return true; } diff --git a/key.core/pipelineTests/records/expected/04_JmlDocRemoval/NotAllowed.java b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/NotAllowed.java index 37ed87d5e1..1fb5d2ed73 100644 --- a/key.core/pipelineTests/records/expected/04_JmlDocRemoval/NotAllowed.java +++ b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/NotAllowed.java @@ -15,7 +15,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Name that)) return false; - return java.lang.Objects.equals(name, o.name); + return java.lang.Objects.equals(name, that.name); return true; } @@ -60,7 +60,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Point that)) return false; - return java.lang.Objects.equals(x, o.x) && java.lang.Objects.equals(y, o.y); + return java.lang.Objects.equals(x, that.x) && java.lang.Objects.equals(y, that.y); return true; } diff --git a/key.core/pipelineTests/records/expected/04_JmlDocRemoval/RecordOverwriting.java b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/RecordOverwriting.java index 3a3143172f..dd06d25703 100644 --- a/key.core/pipelineTests/records/expected/04_JmlDocRemoval/RecordOverwriting.java +++ b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/RecordOverwriting.java @@ -13,7 +13,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof MyRecord that)) return false; - return java.lang.Objects.equals(test, o.test); + return java.lang.Objects.equals(test, that.test); return true; } diff --git a/key.core/pipelineTests/records/expected/04_JmlDocRemoval/SimpleRecord.java b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/SimpleRecord.java index 5094807995..871598267b 100644 --- a/key.core/pipelineTests/records/expected/04_JmlDocRemoval/SimpleRecord.java +++ b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/SimpleRecord.java @@ -13,7 +13,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof SimpleRecord that)) return false; - return java.lang.Objects.equals(name, o.name); + return java.lang.Objects.equals(name, that.name); return true; } diff --git a/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/CompactConstructor.java b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/CompactConstructor.java index a43a3ab0b3..bffc624f91 100644 --- a/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/CompactConstructor.java +++ b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/CompactConstructor.java @@ -19,7 +19,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Mapping that)) return false; - return java.lang.Objects.equals(from, o.from) && java.lang.Objects.equals(to, o.to); + return java.lang.Objects.equals(from, that.from) && java.lang.Objects.equals(to, that.to); return true; } @@ -52,8 +52,8 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; } diff --git a/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/InnerRecord.java b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/InnerRecord.java index 405a53dbc7..d6f91e3ded 100644 --- a/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/InnerRecord.java +++ b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/InnerRecord.java @@ -15,7 +15,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof MyRecord that)) return false; - return java.lang.Objects.equals(test, o.test); + return java.lang.Objects.equals(test, that.test); return true; } @@ -44,10 +44,10 @@ public final non_null String toString() { private OuterClass $enclosingThis; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; } @javax.annotation.processing.Generated() @@ -63,8 +63,8 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; } diff --git a/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/NotAllowed.java b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/NotAllowed.java index 141b747113..49f7549c37 100644 --- a/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/NotAllowed.java +++ b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/NotAllowed.java @@ -15,7 +15,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Name that)) return false; - return java.lang.Objects.equals(name, o.name); + return java.lang.Objects.equals(name, that.name); return true; } @@ -51,10 +51,10 @@ static Name of(String name) { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; } @Generated() @@ -78,7 +78,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Point that)) return false; - return java.lang.Objects.equals(x, o.x) && java.lang.Objects.equals(y, o.y); + return java.lang.Objects.equals(x, that.x) && java.lang.Objects.equals(y, that.y); return true; } @@ -122,8 +122,8 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; } diff --git a/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/RecordOverwriting.java b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/RecordOverwriting.java index 10a01baedd..b82d97d210 100644 --- a/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/RecordOverwriting.java +++ b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/RecordOverwriting.java @@ -13,7 +13,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof MyRecord that)) return false; - return java.lang.Objects.equals(test, o.test); + return java.lang.Objects.equals(test, that.test); return true; } @@ -47,8 +47,8 @@ public String test() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; } diff --git a/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/SimpleRecord.java b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/SimpleRecord.java index 6149ba3613..f09aa83267 100644 --- a/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/SimpleRecord.java +++ b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/SimpleRecord.java @@ -13,7 +13,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof SimpleRecord that)) return false; - return java.lang.Objects.equals(name, o.name); + return java.lang.Objects.equals(name, that.name); return true; } @@ -44,8 +44,8 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; } diff --git a/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/CompactConstructor.java b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/CompactConstructor.java index 92e6621118..bd195fa7ab 100644 --- a/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/CompactConstructor.java +++ b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/CompactConstructor.java @@ -19,7 +19,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Mapping that)) return false; - return java.lang.Objects.equals(from, o.from) && java.lang.Objects.equals(to, o.to); + return java.lang.Objects.equals(from, that.from) && java.lang.Objects.equals(to, that.to); return true; } @@ -52,10 +52,10 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static Mapping $allocate(); } diff --git a/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/InnerRecord.java b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/InnerRecord.java index 15fd856b3d..795cae4c43 100644 --- a/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/InnerRecord.java +++ b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/InnerRecord.java @@ -15,7 +15,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof MyRecord that)) return false; - return java.lang.Objects.equals(test, o.test); + return java.lang.Objects.equals(test, that.test); return true; } @@ -44,10 +44,10 @@ public final non_null String toString() { private OuterClass $enclosingThis; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static MyRecord $allocate(); } @@ -65,10 +65,10 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static OuterClass $allocate(); } diff --git a/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/NotAllowed.java b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/NotAllowed.java index 2f4de3cf02..7ca3601dd7 100644 --- a/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/NotAllowed.java +++ b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/NotAllowed.java @@ -15,7 +15,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Name that)) return false; - return java.lang.Objects.equals(name, o.name); + return java.lang.Objects.equals(name, that.name); return true; } @@ -51,10 +51,10 @@ static Name of(String name) { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static // package-private Name $allocate(); @@ -81,7 +81,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Point that)) return false; - return java.lang.Objects.equals(x, o.x) && java.lang.Objects.equals(y, o.y); + return java.lang.Objects.equals(x, that.x) && java.lang.Objects.equals(y, that.y); return true; } @@ -125,10 +125,10 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static Point $allocate(); } diff --git a/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/RecordOverwriting.java b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/RecordOverwriting.java index 007940f8f8..91c79505a6 100644 --- a/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/RecordOverwriting.java +++ b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/RecordOverwriting.java @@ -13,7 +13,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof MyRecord that)) return false; - return java.lang.Objects.equals(test, o.test); + return java.lang.Objects.equals(test, that.test); return true; } @@ -47,10 +47,10 @@ public String test() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static MyRecord $allocate(); } diff --git a/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/SimpleRecord.java b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/SimpleRecord.java index 8b86aa6388..46cd08e9b4 100644 --- a/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/SimpleRecord.java +++ b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/SimpleRecord.java @@ -13,7 +13,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof SimpleRecord that)) return false; - return java.lang.Objects.equals(name, o.name); + return java.lang.Objects.equals(name, that.name); return true; } @@ -44,10 +44,10 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static SimpleRecord $allocate(); } diff --git a/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/CompactConstructor.java b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/CompactConstructor.java index 5599542e28..a3d6e7e007 100644 --- a/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/CompactConstructor.java +++ b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/CompactConstructor.java @@ -19,7 +19,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Mapping that)) return false; - return java.lang.Objects.equals(from, o.from) && java.lang.Objects.equals(to, o.to); + return java.lang.Objects.equals(from, that.from) && java.lang.Objects.equals(to, that.to); return true; } @@ -52,10 +52,10 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static Mapping $allocate(); diff --git a/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/InnerRecord.java b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/InnerRecord.java index 0dca0f8d0e..ecb99c982f 100644 --- a/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/InnerRecord.java +++ b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/InnerRecord.java @@ -15,7 +15,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof MyRecord that)) return false; - return java.lang.Objects.equals(test, o.test); + return java.lang.Objects.equals(test, that.test); return true; } @@ -44,10 +44,10 @@ public final non_null String toString() { private OuterClass $enclosingThis; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static MyRecord $allocate(); @@ -74,10 +74,10 @@ public MyRecord() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static OuterClass $allocate(); diff --git a/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/NotAllowed.java b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/NotAllowed.java index 0f1aee7ab0..6f34a562ac 100644 --- a/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/NotAllowed.java +++ b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/NotAllowed.java @@ -15,7 +15,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Name that)) return false; - return java.lang.Objects.equals(name, o.name); + return java.lang.Objects.equals(name, that.name); return true; } @@ -51,10 +51,10 @@ static Name of(String name) { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static // package-private Name $allocate(); @@ -86,7 +86,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Point that)) return false; - return java.lang.Objects.equals(x, o.x) && java.lang.Objects.equals(y, o.y); + return java.lang.Objects.equals(x, that.x) && java.lang.Objects.equals(y, that.y); return true; } @@ -130,10 +130,10 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static Point $allocate(); diff --git a/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/RecordOverwriting.java b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/RecordOverwriting.java index b1f3d2be93..9fcbcb36fa 100644 --- a/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/RecordOverwriting.java +++ b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/RecordOverwriting.java @@ -13,7 +13,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof MyRecord that)) return false; - return java.lang.Objects.equals(test, o.test); + return java.lang.Objects.equals(test, that.test); return true; } @@ -47,10 +47,10 @@ public String test() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static MyRecord $allocate(); diff --git a/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/SimpleRecord.java b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/SimpleRecord.java index 17b287d241..4b2bbd1fc1 100644 --- a/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/SimpleRecord.java +++ b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/SimpleRecord.java @@ -13,7 +13,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof SimpleRecord that)) return false; - return java.lang.Objects.equals(name, o.name); + return java.lang.Objects.equals(name, that.name); return true; } @@ -44,10 +44,10 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static SimpleRecord $allocate(); diff --git a/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/CompactConstructor.java b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/CompactConstructor.java index 00ca1412e9..3e0c8022d1 100644 --- a/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/CompactConstructor.java +++ b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/CompactConstructor.java @@ -19,7 +19,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Mapping that)) return false; - return java.lang.Objects.equals(from, o.from) && java.lang.Objects.equals(to, o.to); + return java.lang.Objects.equals(from, that.from) && java.lang.Objects.equals(to, that.to); return true; } @@ -52,10 +52,10 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static Mapping $allocate(); diff --git a/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/InnerRecord.java b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/InnerRecord.java index e6c54db9a3..b821bcf9d0 100644 --- a/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/InnerRecord.java +++ b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/InnerRecord.java @@ -15,7 +15,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof MyRecord that)) return false; - return java.lang.Objects.equals(test, o.test); + return java.lang.Objects.equals(test, that.test); return true; } @@ -44,10 +44,10 @@ public final non_null String toString() { private OuterClass $enclosingThis; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static MyRecord $allocate(); @@ -77,10 +77,10 @@ public MyRecord() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static OuterClass $allocate(); diff --git a/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/NotAllowed.java b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/NotAllowed.java index 063f3dbe81..29f81df084 100644 --- a/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/NotAllowed.java +++ b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/NotAllowed.java @@ -15,7 +15,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Name that)) return false; - return java.lang.Objects.equals(name, o.name); + return java.lang.Objects.equals(name, that.name); return true; } @@ -51,10 +51,10 @@ static Name of(String name) { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static // package-private Name $allocate(); @@ -89,7 +89,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Point that)) return false; - return java.lang.Objects.equals(x, o.x) && java.lang.Objects.equals(y, o.y); + return java.lang.Objects.equals(x, that.x) && java.lang.Objects.equals(y, that.y); return true; } @@ -133,10 +133,10 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static Point $allocate(); diff --git a/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/RecordOverwriting.java b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/RecordOverwriting.java index 1f7037f222..9008b4f75b 100644 --- a/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/RecordOverwriting.java +++ b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/RecordOverwriting.java @@ -13,7 +13,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof MyRecord that)) return false; - return java.lang.Objects.equals(test, o.test); + return java.lang.Objects.equals(test, that.test); return true; } @@ -47,10 +47,10 @@ public String test() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static MyRecord $allocate(); diff --git a/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/SimpleRecord.java b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/SimpleRecord.java index 0ca3959164..863d12c480 100644 --- a/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/SimpleRecord.java +++ b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/SimpleRecord.java @@ -13,7 +13,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof SimpleRecord that)) return false; - return java.lang.Objects.equals(name, o.name); + return java.lang.Objects.equals(name, that.name); return true; } @@ -44,10 +44,10 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static SimpleRecord $allocate(); diff --git a/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/CompactConstructor.java b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/CompactConstructor.java index f0e8d8a1d4..8ca805adbe 100644 --- a/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/CompactConstructor.java +++ b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/CompactConstructor.java @@ -19,7 +19,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Mapping that)) return false; - return java.lang.Objects.equals(from, o.from) && java.lang.Objects.equals(to, o.to); + return java.lang.Objects.equals(from, that.from) && java.lang.Objects.equals(to, that.to); return true; } @@ -52,10 +52,10 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static Mapping $allocate(); diff --git a/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/InnerRecord.java b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/InnerRecord.java index 520d25f60a..e10f4ab934 100644 --- a/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/InnerRecord.java +++ b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/InnerRecord.java @@ -15,7 +15,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof MyRecord that)) return false; - return java.lang.Objects.equals(test, o.test); + return java.lang.Objects.equals(test, that.test); return true; } @@ -44,10 +44,10 @@ public final non_null String toString() { private OuterClass $enclosingThis; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static MyRecord $allocate(); @@ -115,10 +115,10 @@ public MyRecord() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static OuterClass $allocate(); diff --git a/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/NotAllowed.java b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/NotAllowed.java index 4db7885fa3..5dd9919b37 100644 --- a/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/NotAllowed.java +++ b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/NotAllowed.java @@ -15,7 +15,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Name that)) return false; - return java.lang.Objects.equals(name, o.name); + return java.lang.Objects.equals(name, that.name); return true; } @@ -51,10 +51,10 @@ static Name of(String name) { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static // package-private Name $allocate(); @@ -127,7 +127,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Point that)) return false; - return java.lang.Objects.equals(x, o.x) && java.lang.Objects.equals(y, o.y); + return java.lang.Objects.equals(x, that.x) && java.lang.Objects.equals(y, that.y); return true; } @@ -171,10 +171,10 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static Point $allocate(); diff --git a/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/RecordOverwriting.java b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/RecordOverwriting.java index 11636ee59a..15f8b673eb 100644 --- a/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/RecordOverwriting.java +++ b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/RecordOverwriting.java @@ -13,7 +13,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof MyRecord that)) return false; - return java.lang.Objects.equals(test, o.test); + return java.lang.Objects.equals(test, that.test); return true; } @@ -47,10 +47,10 @@ public String test() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static MyRecord $allocate(); diff --git a/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/SimpleRecord.java b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/SimpleRecord.java index 3176e3baa5..9f448392b8 100644 --- a/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/SimpleRecord.java +++ b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/SimpleRecord.java @@ -13,7 +13,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof SimpleRecord that)) return false; - return java.lang.Objects.equals(name, o.name); + return java.lang.Objects.equals(name, that.name); return true; } @@ -44,10 +44,10 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static SimpleRecord $allocate(); diff --git a/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/CompactConstructor.java b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/CompactConstructor.java index ff3e3c8858..5c2d92d129 100644 --- a/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/CompactConstructor.java +++ b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/CompactConstructor.java @@ -19,7 +19,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Mapping that)) return false; - return java.lang.Objects.equals(from, o.from) && java.lang.Objects.equals(to, o.to); + return java.lang.Objects.equals(from, that.from) && java.lang.Objects.equals(to, that.to); return true; } @@ -52,10 +52,10 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static Mapping $allocate(); diff --git a/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/InnerRecord.java b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/InnerRecord.java index fc5c3a3948..807dc0d6d9 100644 --- a/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/InnerRecord.java +++ b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/InnerRecord.java @@ -15,7 +15,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof MyRecord that)) return false; - return java.lang.Objects.equals(test, o.test); + return java.lang.Objects.equals(test, that.test); return true; } @@ -44,10 +44,10 @@ public final non_null String toString() { private OuterClass $enclosingThis; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static MyRecord $allocate(); @@ -131,10 +131,10 @@ public MyRecord() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static OuterClass $allocate(); diff --git a/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/NotAllowed.java b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/NotAllowed.java index 37fbc596cb..e66b7b31da 100644 --- a/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/NotAllowed.java +++ b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/NotAllowed.java @@ -15,7 +15,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Name that)) return false; - return java.lang.Objects.equals(name, o.name); + return java.lang.Objects.equals(name, that.name); return true; } @@ -51,10 +51,10 @@ static Name of(String name) { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static // package-private Name $allocate(); @@ -139,7 +139,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Point that)) return false; - return java.lang.Objects.equals(x, o.x) && java.lang.Objects.equals(y, o.y); + return java.lang.Objects.equals(x, that.x) && java.lang.Objects.equals(y, that.y); return true; } @@ -183,10 +183,10 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static Point $allocate(); diff --git a/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/RecordOverwriting.java b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/RecordOverwriting.java index fe750ad8f4..d6b609956e 100644 --- a/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/RecordOverwriting.java +++ b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/RecordOverwriting.java @@ -13,7 +13,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof MyRecord that)) return false; - return java.lang.Objects.equals(test, o.test); + return java.lang.Objects.equals(test, that.test); return true; } @@ -47,10 +47,10 @@ public String test() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static MyRecord $allocate(); diff --git a/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/SimpleRecord.java b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/SimpleRecord.java index e2d6c6ca1f..6fb7731427 100644 --- a/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/SimpleRecord.java +++ b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/SimpleRecord.java @@ -13,7 +13,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof SimpleRecord that)) return false; - return java.lang.Objects.equals(name, o.name); + return java.lang.Objects.equals(name, that.name); return true; } @@ -44,10 +44,10 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static SimpleRecord $allocate(); diff --git a/key.core/pipelineTests/records/expected/11_CreateBuilder/CompactConstructor.java b/key.core/pipelineTests/records/expected/11_CreateBuilder/CompactConstructor.java index b29d777b9a..7665b6e1de 100644 --- a/key.core/pipelineTests/records/expected/11_CreateBuilder/CompactConstructor.java +++ b/key.core/pipelineTests/records/expected/11_CreateBuilder/CompactConstructor.java @@ -19,7 +19,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Mapping that)) return false; - return java.lang.Objects.equals(from, o.from) && java.lang.Objects.equals(to, o.to); + return java.lang.Objects.equals(from, that.from) && java.lang.Objects.equals(to, that.to); return true; } @@ -52,10 +52,10 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static Mapping $allocate(); diff --git a/key.core/pipelineTests/records/expected/11_CreateBuilder/InnerRecord.java b/key.core/pipelineTests/records/expected/11_CreateBuilder/InnerRecord.java index 03abe4e62d..5fa698ccdf 100644 --- a/key.core/pipelineTests/records/expected/11_CreateBuilder/InnerRecord.java +++ b/key.core/pipelineTests/records/expected/11_CreateBuilder/InnerRecord.java @@ -15,7 +15,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof MyRecord that)) return false; - return java.lang.Objects.equals(test, o.test); + return java.lang.Objects.equals(test, that.test); return true; } @@ -44,10 +44,10 @@ public final non_null String toString() { private OuterClass $enclosingThis; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static MyRecord $allocate(); @@ -138,10 +138,10 @@ public MyRecord() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static OuterClass $allocate(); diff --git a/key.core/pipelineTests/records/expected/11_CreateBuilder/NotAllowed.java b/key.core/pipelineTests/records/expected/11_CreateBuilder/NotAllowed.java index 3c71e8e4a9..a2e12e31e9 100644 --- a/key.core/pipelineTests/records/expected/11_CreateBuilder/NotAllowed.java +++ b/key.core/pipelineTests/records/expected/11_CreateBuilder/NotAllowed.java @@ -15,7 +15,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Name that)) return false; - return java.lang.Objects.equals(name, o.name); + return java.lang.Objects.equals(name, that.name); return true; } @@ -51,10 +51,10 @@ static Name of(String name) { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static // package-private Name $allocate(); @@ -146,7 +146,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Point that)) return false; - return java.lang.Objects.equals(x, o.x) && java.lang.Objects.equals(y, o.y); + return java.lang.Objects.equals(x, that.x) && java.lang.Objects.equals(y, that.y); return true; } @@ -190,10 +190,10 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static Point $allocate(); diff --git a/key.core/pipelineTests/records/expected/11_CreateBuilder/RecordOverwriting.java b/key.core/pipelineTests/records/expected/11_CreateBuilder/RecordOverwriting.java index f2a0a5ad01..bded70534d 100644 --- a/key.core/pipelineTests/records/expected/11_CreateBuilder/RecordOverwriting.java +++ b/key.core/pipelineTests/records/expected/11_CreateBuilder/RecordOverwriting.java @@ -13,7 +13,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof MyRecord that)) return false; - return java.lang.Objects.equals(test, o.test); + return java.lang.Objects.equals(test, that.test); return true; } @@ -47,10 +47,10 @@ public String test() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static MyRecord $allocate(); diff --git a/key.core/pipelineTests/records/expected/11_CreateBuilder/SimpleRecord.java b/key.core/pipelineTests/records/expected/11_CreateBuilder/SimpleRecord.java index 3b19c572ee..0281748ffd 100644 --- a/key.core/pipelineTests/records/expected/11_CreateBuilder/SimpleRecord.java +++ b/key.core/pipelineTests/records/expected/11_CreateBuilder/SimpleRecord.java @@ -13,7 +13,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof SimpleRecord that)) return false; - return java.lang.Objects.equals(name, o.name); + return java.lang.Objects.equals(name, that.name); return true; } @@ -44,10 +44,10 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static SimpleRecord $allocate(); diff --git a/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/CompactConstructor.java b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/CompactConstructor.java index 1c6c12a2d4..82a4202981 100644 --- a/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/CompactConstructor.java +++ b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/CompactConstructor.java @@ -19,7 +19,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Mapping that)) return false; - return java.lang.Objects.equals(from, o.from) && java.lang.Objects.equals(to, o.to); + return java.lang.Objects.equals(from, that.from) && java.lang.Objects.equals(to, that.to); return true; } @@ -52,10 +52,10 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static Mapping $allocate(); diff --git a/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/InnerRecord.java b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/InnerRecord.java index 198cf32dd6..d02a4effc8 100644 --- a/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/InnerRecord.java +++ b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/InnerRecord.java @@ -15,7 +15,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof MyRecord that)) return false; - return java.lang.Objects.equals(test, o.test); + return java.lang.Objects.equals(test, that.test); return true; } @@ -44,10 +44,10 @@ public final non_null String toString() { private OuterClass $enclosingThis; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static MyRecord $allocate(); @@ -146,10 +146,10 @@ public MyRecord() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static OuterClass $allocate(); diff --git a/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/NotAllowed.java b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/NotAllowed.java index 06cbba6c07..83c289fae4 100644 --- a/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/NotAllowed.java +++ b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/NotAllowed.java @@ -15,7 +15,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Name that)) return false; - return java.lang.Objects.equals(name, o.name); + return java.lang.Objects.equals(name, that.name); return true; } @@ -51,10 +51,10 @@ static Name of(String name) { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static // package-private Name $allocate(); @@ -158,7 +158,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Point that)) return false; - return java.lang.Objects.equals(x, o.x) && java.lang.Objects.equals(y, o.y); + return java.lang.Objects.equals(x, that.x) && java.lang.Objects.equals(y, that.y); return true; } @@ -202,10 +202,10 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static Point $allocate(); diff --git a/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/RecordOverwriting.java b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/RecordOverwriting.java index ed8b4b08af..d64c5174b2 100644 --- a/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/RecordOverwriting.java +++ b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/RecordOverwriting.java @@ -13,7 +13,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof MyRecord that)) return false; - return java.lang.Objects.equals(test, o.test); + return java.lang.Objects.equals(test, that.test); return true; } @@ -47,10 +47,10 @@ public String test() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static MyRecord $allocate(); diff --git a/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/SimpleRecord.java b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/SimpleRecord.java index 8891eca833..b0a09f520b 100644 --- a/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/SimpleRecord.java +++ b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/SimpleRecord.java @@ -13,7 +13,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof SimpleRecord that)) return false; - return java.lang.Objects.equals(name, o.name); + return java.lang.Objects.equals(name, that.name); return true; } @@ -44,10 +44,10 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static SimpleRecord $allocate(); diff --git a/key.core/pipelineTests/records/expected/13_LocalClassTransformation/CompactConstructor.java b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/CompactConstructor.java index 1c6c12a2d4..82a4202981 100644 --- a/key.core/pipelineTests/records/expected/13_LocalClassTransformation/CompactConstructor.java +++ b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/CompactConstructor.java @@ -19,7 +19,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Mapping that)) return false; - return java.lang.Objects.equals(from, o.from) && java.lang.Objects.equals(to, o.to); + return java.lang.Objects.equals(from, that.from) && java.lang.Objects.equals(to, that.to); return true; } @@ -52,10 +52,10 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static Mapping $allocate(); diff --git a/key.core/pipelineTests/records/expected/13_LocalClassTransformation/InnerRecord.java b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/InnerRecord.java index 198cf32dd6..d02a4effc8 100644 --- a/key.core/pipelineTests/records/expected/13_LocalClassTransformation/InnerRecord.java +++ b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/InnerRecord.java @@ -15,7 +15,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof MyRecord that)) return false; - return java.lang.Objects.equals(test, o.test); + return java.lang.Objects.equals(test, that.test); return true; } @@ -44,10 +44,10 @@ public final non_null String toString() { private OuterClass $enclosingThis; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static MyRecord $allocate(); @@ -146,10 +146,10 @@ public MyRecord() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static OuterClass $allocate(); diff --git a/key.core/pipelineTests/records/expected/13_LocalClassTransformation/NotAllowed.java b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/NotAllowed.java index 06cbba6c07..83c289fae4 100644 --- a/key.core/pipelineTests/records/expected/13_LocalClassTransformation/NotAllowed.java +++ b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/NotAllowed.java @@ -15,7 +15,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Name that)) return false; - return java.lang.Objects.equals(name, o.name); + return java.lang.Objects.equals(name, that.name); return true; } @@ -51,10 +51,10 @@ static Name of(String name) { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static // package-private Name $allocate(); @@ -158,7 +158,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Point that)) return false; - return java.lang.Objects.equals(x, o.x) && java.lang.Objects.equals(y, o.y); + return java.lang.Objects.equals(x, that.x) && java.lang.Objects.equals(y, that.y); return true; } @@ -202,10 +202,10 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static Point $allocate(); diff --git a/key.core/pipelineTests/records/expected/13_LocalClassTransformation/RecordOverwriting.java b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/RecordOverwriting.java index ed8b4b08af..d64c5174b2 100644 --- a/key.core/pipelineTests/records/expected/13_LocalClassTransformation/RecordOverwriting.java +++ b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/RecordOverwriting.java @@ -13,7 +13,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof MyRecord that)) return false; - return java.lang.Objects.equals(test, o.test); + return java.lang.Objects.equals(test, that.test); return true; } @@ -47,10 +47,10 @@ public String test() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static MyRecord $allocate(); diff --git a/key.core/pipelineTests/records/expected/13_LocalClassTransformation/SimpleRecord.java b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/SimpleRecord.java index 8891eca833..b0a09f520b 100644 --- a/key.core/pipelineTests/records/expected/13_LocalClassTransformation/SimpleRecord.java +++ b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/SimpleRecord.java @@ -13,7 +13,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof SimpleRecord that)) return false; - return java.lang.Objects.equals(name, o.name); + return java.lang.Objects.equals(name, that.name); return true; } @@ -44,10 +44,10 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static SimpleRecord $allocate(); diff --git a/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/CompactConstructor.java b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/CompactConstructor.java index 1c6c12a2d4..82a4202981 100644 --- a/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/CompactConstructor.java +++ b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/CompactConstructor.java @@ -19,7 +19,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Mapping that)) return false; - return java.lang.Objects.equals(from, o.from) && java.lang.Objects.equals(to, o.to); + return java.lang.Objects.equals(from, that.from) && java.lang.Objects.equals(to, that.to); return true; } @@ -52,10 +52,10 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static Mapping $allocate(); diff --git a/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/InnerRecord.java b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/InnerRecord.java index 198cf32dd6..d02a4effc8 100644 --- a/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/InnerRecord.java +++ b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/InnerRecord.java @@ -15,7 +15,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof MyRecord that)) return false; - return java.lang.Objects.equals(test, o.test); + return java.lang.Objects.equals(test, that.test); return true; } @@ -44,10 +44,10 @@ public final non_null String toString() { private OuterClass $enclosingThis; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static MyRecord $allocate(); @@ -146,10 +146,10 @@ public MyRecord() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static OuterClass $allocate(); diff --git a/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/NotAllowed.java b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/NotAllowed.java index 06cbba6c07..83c289fae4 100644 --- a/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/NotAllowed.java +++ b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/NotAllowed.java @@ -15,7 +15,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Name that)) return false; - return java.lang.Objects.equals(name, o.name); + return java.lang.Objects.equals(name, that.name); return true; } @@ -51,10 +51,10 @@ static Name of(String name) { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static // package-private Name $allocate(); @@ -158,7 +158,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof Point that)) return false; - return java.lang.Objects.equals(x, o.x) && java.lang.Objects.equals(y, o.y); + return java.lang.Objects.equals(x, that.x) && java.lang.Objects.equals(y, that.y); return true; } @@ -202,10 +202,10 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static Point $allocate(); diff --git a/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/RecordOverwriting.java b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/RecordOverwriting.java index ed8b4b08af..d64c5174b2 100644 --- a/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/RecordOverwriting.java +++ b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/RecordOverwriting.java @@ -13,7 +13,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof MyRecord that)) return false; - return java.lang.Objects.equals(test, o.test); + return java.lang.Objects.equals(test, that.test); return true; } @@ -47,10 +47,10 @@ public String test() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static MyRecord $allocate(); diff --git a/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/SimpleRecord.java b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/SimpleRecord.java index 8891eca833..b0a09f520b 100644 --- a/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/SimpleRecord.java +++ b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/SimpleRecord.java @@ -13,7 +13,7 @@ public final boolean hashCode(java.lang.Object o) { return true; if (!(o instanceof SimpleRecord that)) return false; - return java.lang.Objects.equals(name, o.name); + return java.lang.Objects.equals(name, that.name); return true; } @@ -44,10 +44,10 @@ public final non_null String toString() { static private boolean $classPrepared; @javax.annotation.processing.Generated() - static public model boolean <$staticInv>; + static public model boolean $staticInv; @javax.annotation.processing.Generated() - static public model boolean <$staticInv_free>; + static public model boolean $staticInv_free; public static SimpleRecord $allocate(); diff --git a/key.core/pipelineTests/simple/expected/02_JMLTransformer/Test.java b/key.core/pipelineTests/simple/expected/02_JMLTransformer/Test.java deleted file mode 100644 index dba29c488a..0000000000 --- a/key.core/pipelineTests/simple/expected/02_JMLTransformer/Test.java +++ /dev/null @@ -1,24 +0,0 @@ -public class Test { - - public static int abc; - - static { - // should be resolved to 2 - abc = 1 + 1; - } - - public int memberVar; - - { - memberVar = 42; - } -} - -public class SubClass extends Test { - - public int memberVar; - - { - memberVar = 41; - } -} diff --git a/key.core/pipelineTests/simple/expected/03_JmlDocRemoval/Test.java b/key.core/pipelineTests/simple/expected/03_JmlDocRemoval/Test.java deleted file mode 100644 index dba29c488a..0000000000 --- a/key.core/pipelineTests/simple/expected/03_JmlDocRemoval/Test.java +++ /dev/null @@ -1,24 +0,0 @@ -public class Test { - - public static int abc; - - static { - // should be resolved to 2 - abc = 1 + 1; - } - - public int memberVar; - - { - memberVar = 42; - } -} - -public class SubClass extends Test { - - public int memberVar; - - { - memberVar = 41; - } -} diff --git a/key.core/pipelineTests/simple/expected/04_ImplicitFieldAdder/Test.java b/key.core/pipelineTests/simple/expected/04_ImplicitFieldAdder/Test.java deleted file mode 100644 index e3c9d609b0..0000000000 --- a/key.core/pipelineTests/simple/expected/04_ImplicitFieldAdder/Test.java +++ /dev/null @@ -1,60 +0,0 @@ -public class Test { - - public static int abc; - - static { - // should be resolved to 2 - abc = 1 + 1; - } - - public int memberVar; - - { - memberVar = 42; - } - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; -} - -public class SubClass extends Test { - - public int memberVar; - - { - memberVar = 41; - } - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; -} diff --git a/key.core/pipelineTests/simple/expected/05_InstanceAllocationMethodBuilder/Test.java b/key.core/pipelineTests/simple/expected/05_InstanceAllocationMethodBuilder/Test.java deleted file mode 100644 index 939c13da9b..0000000000 --- a/key.core/pipelineTests/simple/expected/05_InstanceAllocationMethodBuilder/Test.java +++ /dev/null @@ -1,64 +0,0 @@ -public class Test { - - public static int abc; - - static { - // should be resolved to 2 - abc = 1 + 1; - } - - public int memberVar; - - { - memberVar = 42; - } - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static Test $allocate(); -} - -public class SubClass extends Test { - - public int memberVar; - - { - memberVar = 41; - } - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static SubClass $allocate(); -} diff --git a/key.core/pipelineTests/simple/expected/06_ConstructorNormalformBuilder/Test.java b/key.core/pipelineTests/simple/expected/06_ConstructorNormalformBuilder/Test.java deleted file mode 100644 index 0fcacd6fef..0000000000 --- a/key.core/pipelineTests/simple/expected/06_ConstructorNormalformBuilder/Test.java +++ /dev/null @@ -1,100 +0,0 @@ -public class Test { - - public static int abc; - - static { - // should be resolved to 2 - abc = 1 + 1; - } - - public int memberVar; - - { - memberVar = 42; - } - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static Test $allocate(); - - public Test() { - } - - private void $objectInitializer0() { - memberVar = 42; - } - - public void $init() { - super.$init(); - $objectInitializer0(); - super.$init(); - $objectInitializer0(); - } - - private void $objectInitializer0() { - memberVar = 42; - } -} - -public class SubClass extends Test { - - public int memberVar; - - { - memberVar = 41; - } - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static SubClass $allocate(); - - public SubClass() { - } - - private void $objectInitializer0() { - memberVar = 41; - } - - public void $init() { - super.$init(); - $objectInitializer0(); - super.$init(); - $objectInitializer0(); - } - - private void $objectInitializer0() { - memberVar = 41; - } -} diff --git a/key.core/pipelineTests/simple/expected/07_ClassPreparationMethodBuilder/Test.java b/key.core/pipelineTests/simple/expected/07_ClassPreparationMethodBuilder/Test.java deleted file mode 100644 index 825b89f91c..0000000000 --- a/key.core/pipelineTests/simple/expected/07_ClassPreparationMethodBuilder/Test.java +++ /dev/null @@ -1,106 +0,0 @@ -public class Test { - - public static int abc; - - static { - // should be resolved to 2 - abc = 1 + 1; - } - - public int memberVar; - - { - memberVar = 42; - } - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static Test $allocate(); - - public Test() { - } - - private void $objectInitializer0() { - memberVar = 42; - } - - public void $init() { - super.$init(); - $objectInitializer0(); - super.$init(); - $objectInitializer0(); - } - - private void $objectInitializer0() { - memberVar = 42; - } - - static private void $clprepare() { - } -} - -public class SubClass extends Test { - - public int memberVar; - - { - memberVar = 41; - } - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static SubClass $allocate(); - - public SubClass() { - } - - private void $objectInitializer0() { - memberVar = 41; - } - - public void $init() { - super.$init(); - $objectInitializer0(); - super.$init(); - $objectInitializer0(); - } - - private void $objectInitializer0() { - memberVar = 41; - } - - static private void $clprepare() { - } -} diff --git a/key.core/pipelineTests/simple/expected/08_ClassInitializeMethodBuilder/Test.java b/key.core/pipelineTests/simple/expected/08_ClassInitializeMethodBuilder/Test.java deleted file mode 100644 index 5d8570e373..0000000000 --- a/key.core/pipelineTests/simple/expected/08_ClassInitializeMethodBuilder/Test.java +++ /dev/null @@ -1,186 +0,0 @@ -public class Test { - - public static int abc; - - static { - // should be resolved to 2 - abc = 1 + 1; - } - - public int memberVar; - - { - memberVar = 42; - } - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static Test $allocate(); - - public Test() { - } - - private void $objectInitializer0() { - memberVar = 42; - } - - public void $init() { - super.$init(); - $objectInitializer0(); - super.$init(); - $objectInitializer0(); - } - - private void $objectInitializer0() { - memberVar = 42; - } - - static private void $clprepare() { - } - - static public void $clinit() { - if (!@($classInitialized)) { - if (!@($classInitializationInProgress)) { - if (!@($classPrepared)) { - //Created by ClassInitializeMethodBuilder.java:219 - @($clprepare()); - } - if (@($classErroneous)) { - throw new java.lang.NoClassDefFoundError(); - } - //Created by ClassInitializeMethodBuilder.java:243 - @($classInitializationInProgress) = true; - try { - @(java.lang.Object.$clinit()); - { - // should be resolved to 2 - abc = 1 + 1; - } - }//Created by ClassInitializeMethodBuilder.java:194 - catch (java.lang.Error err) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw err; - } catch (java.lang.Throwable twa) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw new java.lang.ExceptionInInitializerError(twa); - } - //Created by ClassInitializeMethodBuilder.java:249 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:251 - @($classErroneous) = false; - //Created by ClassInitializeMethodBuilder.java:253 - @($classInitialized) = true; - } - } - } -} - -public class SubClass extends Test { - - public int memberVar; - - { - memberVar = 41; - } - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static SubClass $allocate(); - - public SubClass() { - } - - private void $objectInitializer0() { - memberVar = 41; - } - - public void $init() { - super.$init(); - $objectInitializer0(); - super.$init(); - $objectInitializer0(); - } - - private void $objectInitializer0() { - memberVar = 41; - } - - static private void $clprepare() { - } - - static public void $clinit() { - if (!@($classInitialized)) { - if (!@($classInitializationInProgress)) { - if (!@($classPrepared)) { - //Created by ClassInitializeMethodBuilder.java:219 - @($clprepare()); - } - if (@($classErroneous)) { - throw new java.lang.NoClassDefFoundError(); - } - //Created by ClassInitializeMethodBuilder.java:243 - @($classInitializationInProgress) = true; - try { - @(Test.$clinit()); - }//Created by ClassInitializeMethodBuilder.java:194 - catch (java.lang.Error err) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw err; - } catch (java.lang.Throwable twa) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw new java.lang.ExceptionInInitializerError(twa); - } - //Created by ClassInitializeMethodBuilder.java:249 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:251 - @($classErroneous) = false; - //Created by ClassInitializeMethodBuilder.java:253 - @($classInitialized) = true; - } - } - } -} diff --git a/key.core/pipelineTests/simple/expected/09_PrepareObjectBuilder/Test.java b/key.core/pipelineTests/simple/expected/09_PrepareObjectBuilder/Test.java deleted file mode 100644 index 53a5436e9a..0000000000 --- a/key.core/pipelineTests/simple/expected/09_PrepareObjectBuilder/Test.java +++ /dev/null @@ -1,210 +0,0 @@ -public class Test { - - public static int abc; - - static { - // should be resolved to 2 - abc = 1 + 1; - } - - public int memberVar; - - { - memberVar = 42; - } - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static Test $allocate(); - - public Test() { - } - - private void $objectInitializer0() { - memberVar = 42; - } - - public void $init() { - super.$init(); - $objectInitializer0(); - super.$init(); - $objectInitializer0(); - } - - private void $objectInitializer0() { - memberVar = 42; - } - - static private void $clprepare() { - } - - static public void $clinit() { - if (!@($classInitialized)) { - if (!@($classInitializationInProgress)) { - if (!@($classPrepared)) { - //Created by ClassInitializeMethodBuilder.java:219 - @($clprepare()); - } - if (@($classErroneous)) { - throw new java.lang.NoClassDefFoundError(); - } - //Created by ClassInitializeMethodBuilder.java:243 - @($classInitializationInProgress) = true; - try { - @(java.lang.Object.$clinit()); - { - // should be resolved to 2 - abc = 1 + 1; - } - }//Created by ClassInitializeMethodBuilder.java:194 - catch (java.lang.Error err) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw err; - } catch (java.lang.Throwable twa) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw new java.lang.ExceptionInInitializerError(twa); - } - //Created by ClassInitializeMethodBuilder.java:249 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:251 - @($classErroneous) = false; - //Created by ClassInitializeMethodBuilder.java:253 - @($classInitialized) = true; - } - } - } - - protected void $prepare() { - super.$prepare(); - //Created by PrepareObjectBuilder.java:94 - this.memberVar = 0; - } - - private void $prepareEnter() { - super.$prepare(); - //Created by PrepareObjectBuilder.java:94 - this.memberVar = 0; - } -} - -public class SubClass extends Test { - - public int memberVar; - - { - memberVar = 41; - } - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static SubClass $allocate(); - - public SubClass() { - } - - private void $objectInitializer0() { - memberVar = 41; - } - - public void $init() { - super.$init(); - $objectInitializer0(); - super.$init(); - $objectInitializer0(); - } - - private void $objectInitializer0() { - memberVar = 41; - } - - static private void $clprepare() { - } - - static public void $clinit() { - if (!@($classInitialized)) { - if (!@($classInitializationInProgress)) { - if (!@($classPrepared)) { - //Created by ClassInitializeMethodBuilder.java:219 - @($clprepare()); - } - if (@($classErroneous)) { - throw new java.lang.NoClassDefFoundError(); - } - //Created by ClassInitializeMethodBuilder.java:243 - @($classInitializationInProgress) = true; - try { - @(Test.$clinit()); - }//Created by ClassInitializeMethodBuilder.java:194 - catch (java.lang.Error err) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw err; - } catch (java.lang.Throwable twa) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw new java.lang.ExceptionInInitializerError(twa); - } - //Created by ClassInitializeMethodBuilder.java:249 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:251 - @($classErroneous) = false; - //Created by ClassInitializeMethodBuilder.java:253 - @($classInitialized) = true; - } - } - } - - protected void $prepare() { - super.$prepare(); - //Created by PrepareObjectBuilder.java:94 - this.memberVar = 0; - } - - private void $prepareEnter() { - super.$prepare(); - //Created by PrepareObjectBuilder.java:94 - this.memberVar = 0; - } -} diff --git a/key.core/pipelineTests/simple/expected/10_CreateBuilder/Test.java b/key.core/pipelineTests/simple/expected/10_CreateBuilder/Test.java deleted file mode 100644 index 0116b54018..0000000000 --- a/key.core/pipelineTests/simple/expected/10_CreateBuilder/Test.java +++ /dev/null @@ -1,224 +0,0 @@ -public class Test { - - public static int abc; - - static { - // should be resolved to 2 - abc = 1 + 1; - } - - public int memberVar; - - { - memberVar = 42; - } - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static Test $allocate(); - - public Test() { - } - - private void $objectInitializer0() { - memberVar = 42; - } - - public void $init() { - super.$init(); - $objectInitializer0(); - super.$init(); - $objectInitializer0(); - } - - private void $objectInitializer0() { - memberVar = 42; - } - - static private void $clprepare() { - } - - static public void $clinit() { - if (!@($classInitialized)) { - if (!@($classInitializationInProgress)) { - if (!@($classPrepared)) { - //Created by ClassInitializeMethodBuilder.java:219 - @($clprepare()); - } - if (@($classErroneous)) { - throw new java.lang.NoClassDefFoundError(); - } - //Created by ClassInitializeMethodBuilder.java:243 - @($classInitializationInProgress) = true; - try { - @(java.lang.Object.$clinit()); - { - // should be resolved to 2 - abc = 1 + 1; - } - }//Created by ClassInitializeMethodBuilder.java:194 - catch (java.lang.Error err) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw err; - } catch (java.lang.Throwable twa) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw new java.lang.ExceptionInInitializerError(twa); - } - //Created by ClassInitializeMethodBuilder.java:249 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:251 - @($classErroneous) = false; - //Created by ClassInitializeMethodBuilder.java:253 - @($classInitialized) = true; - } - } - } - - protected void $prepare() { - super.$prepare(); - //Created by PrepareObjectBuilder.java:94 - this.memberVar = 0; - } - - private void $prepareEnter() { - super.$prepare(); - //Created by PrepareObjectBuilder.java:94 - this.memberVar = 0; - } - - public Test $create() { - //Created by CreateBuilder.java:57 - this.$initialized = false; - $prepareEnter(); - return this; - } -} - -public class SubClass extends Test { - - public int memberVar; - - { - memberVar = 41; - } - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static SubClass $allocate(); - - public SubClass() { - } - - private void $objectInitializer0() { - memberVar = 41; - } - - public void $init() { - super.$init(); - $objectInitializer0(); - super.$init(); - $objectInitializer0(); - } - - private void $objectInitializer0() { - memberVar = 41; - } - - static private void $clprepare() { - } - - static public void $clinit() { - if (!@($classInitialized)) { - if (!@($classInitializationInProgress)) { - if (!@($classPrepared)) { - //Created by ClassInitializeMethodBuilder.java:219 - @($clprepare()); - } - if (@($classErroneous)) { - throw new java.lang.NoClassDefFoundError(); - } - //Created by ClassInitializeMethodBuilder.java:243 - @($classInitializationInProgress) = true; - try { - @(Test.$clinit()); - }//Created by ClassInitializeMethodBuilder.java:194 - catch (java.lang.Error err) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw err; - } catch (java.lang.Throwable twa) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw new java.lang.ExceptionInInitializerError(twa); - } - //Created by ClassInitializeMethodBuilder.java:249 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:251 - @($classErroneous) = false; - //Created by ClassInitializeMethodBuilder.java:253 - @($classInitialized) = true; - } - } - } - - protected void $prepare() { - super.$prepare(); - //Created by PrepareObjectBuilder.java:94 - this.memberVar = 0; - } - - private void $prepareEnter() { - super.$prepare(); - //Created by PrepareObjectBuilder.java:94 - this.memberVar = 0; - } - - public SubClass $create() { - //Created by CreateBuilder.java:57 - this.$initialized = false; - $prepareEnter(); - return this; - } -} diff --git a/key.core/pipelineTests/simple/expected/11_CreateObjectBuilder/Test.java b/key.core/pipelineTests/simple/expected/11_CreateObjectBuilder/Test.java deleted file mode 100644 index 44f496647f..0000000000 --- a/key.core/pipelineTests/simple/expected/11_CreateObjectBuilder/Test.java +++ /dev/null @@ -1,240 +0,0 @@ -public class Test { - - public static int abc; - - static { - // should be resolved to 2 - abc = 1 + 1; - } - - public int memberVar; - - { - memberVar = 42; - } - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static Test $allocate(); - - public Test() { - } - - private void $objectInitializer0() { - memberVar = 42; - } - - public void $init() { - super.$init(); - $objectInitializer0(); - super.$init(); - $objectInitializer0(); - } - - private void $objectInitializer0() { - memberVar = 42; - } - - static private void $clprepare() { - } - - static public void $clinit() { - if (!@($classInitialized)) { - if (!@($classInitializationInProgress)) { - if (!@($classPrepared)) { - //Created by ClassInitializeMethodBuilder.java:219 - @($clprepare()); - } - if (@($classErroneous)) { - throw new java.lang.NoClassDefFoundError(); - } - //Created by ClassInitializeMethodBuilder.java:243 - @($classInitializationInProgress) = true; - try { - @(java.lang.Object.$clinit()); - { - // should be resolved to 2 - abc = 1 + 1; - } - }//Created by ClassInitializeMethodBuilder.java:194 - catch (java.lang.Error err) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw err; - } catch (java.lang.Throwable twa) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw new java.lang.ExceptionInInitializerError(twa); - } - //Created by ClassInitializeMethodBuilder.java:249 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:251 - @($classErroneous) = false; - //Created by ClassInitializeMethodBuilder.java:253 - @($classInitialized) = true; - } - } - } - - protected void $prepare() { - super.$prepare(); - //Created by PrepareObjectBuilder.java:94 - this.memberVar = 0; - } - - private void $prepareEnter() { - super.$prepare(); - //Created by PrepareObjectBuilder.java:94 - this.memberVar = 0; - } - - public Test $create() { - //Created by CreateBuilder.java:57 - this.$initialized = false; - $prepareEnter(); - return this; - } - - public static Test $createObject() { - Test __NEW__; - //Created by CreateObjectBuilder.java:70 - __NEW__ = Test.$allocate(); - __NEW__.$create()@Test - return __NEW__; - } -} - -public class SubClass extends Test { - - public int memberVar; - - { - memberVar = 41; - } - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static SubClass $allocate(); - - public SubClass() { - } - - private void $objectInitializer0() { - memberVar = 41; - } - - public void $init() { - super.$init(); - $objectInitializer0(); - super.$init(); - $objectInitializer0(); - } - - private void $objectInitializer0() { - memberVar = 41; - } - - static private void $clprepare() { - } - - static public void $clinit() { - if (!@($classInitialized)) { - if (!@($classInitializationInProgress)) { - if (!@($classPrepared)) { - //Created by ClassInitializeMethodBuilder.java:219 - @($clprepare()); - } - if (@($classErroneous)) { - throw new java.lang.NoClassDefFoundError(); - } - //Created by ClassInitializeMethodBuilder.java:243 - @($classInitializationInProgress) = true; - try { - @(Test.$clinit()); - }//Created by ClassInitializeMethodBuilder.java:194 - catch (java.lang.Error err) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw err; - } catch (java.lang.Throwable twa) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw new java.lang.ExceptionInInitializerError(twa); - } - //Created by ClassInitializeMethodBuilder.java:249 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:251 - @($classErroneous) = false; - //Created by ClassInitializeMethodBuilder.java:253 - @($classInitialized) = true; - } - } - } - - protected void $prepare() { - super.$prepare(); - //Created by PrepareObjectBuilder.java:94 - this.memberVar = 0; - } - - private void $prepareEnter() { - super.$prepare(); - //Created by PrepareObjectBuilder.java:94 - this.memberVar = 0; - } - - public SubClass $create() { - //Created by CreateBuilder.java:57 - this.$initialized = false; - $prepareEnter(); - return this; - } - - public static SubClass $createObject() { - SubClass __NEW__; - //Created by CreateObjectBuilder.java:70 - __NEW__ = SubClass.$allocate(); - __NEW__.$create()@SubClass - return __NEW__; - } -} diff --git a/key.core/pipelineTests/simple/expected/12_LocalClassTransformation/Test.java b/key.core/pipelineTests/simple/expected/12_LocalClassTransformation/Test.java deleted file mode 100644 index 44f496647f..0000000000 --- a/key.core/pipelineTests/simple/expected/12_LocalClassTransformation/Test.java +++ /dev/null @@ -1,240 +0,0 @@ -public class Test { - - public static int abc; - - static { - // should be resolved to 2 - abc = 1 + 1; - } - - public int memberVar; - - { - memberVar = 42; - } - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static Test $allocate(); - - public Test() { - } - - private void $objectInitializer0() { - memberVar = 42; - } - - public void $init() { - super.$init(); - $objectInitializer0(); - super.$init(); - $objectInitializer0(); - } - - private void $objectInitializer0() { - memberVar = 42; - } - - static private void $clprepare() { - } - - static public void $clinit() { - if (!@($classInitialized)) { - if (!@($classInitializationInProgress)) { - if (!@($classPrepared)) { - //Created by ClassInitializeMethodBuilder.java:219 - @($clprepare()); - } - if (@($classErroneous)) { - throw new java.lang.NoClassDefFoundError(); - } - //Created by ClassInitializeMethodBuilder.java:243 - @($classInitializationInProgress) = true; - try { - @(java.lang.Object.$clinit()); - { - // should be resolved to 2 - abc = 1 + 1; - } - }//Created by ClassInitializeMethodBuilder.java:194 - catch (java.lang.Error err) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw err; - } catch (java.lang.Throwable twa) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw new java.lang.ExceptionInInitializerError(twa); - } - //Created by ClassInitializeMethodBuilder.java:249 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:251 - @($classErroneous) = false; - //Created by ClassInitializeMethodBuilder.java:253 - @($classInitialized) = true; - } - } - } - - protected void $prepare() { - super.$prepare(); - //Created by PrepareObjectBuilder.java:94 - this.memberVar = 0; - } - - private void $prepareEnter() { - super.$prepare(); - //Created by PrepareObjectBuilder.java:94 - this.memberVar = 0; - } - - public Test $create() { - //Created by CreateBuilder.java:57 - this.$initialized = false; - $prepareEnter(); - return this; - } - - public static Test $createObject() { - Test __NEW__; - //Created by CreateObjectBuilder.java:70 - __NEW__ = Test.$allocate(); - __NEW__.$create()@Test - return __NEW__; - } -} - -public class SubClass extends Test { - - public int memberVar; - - { - memberVar = 41; - } - - @javax.annotation.processing.Generated() - static private boolean $classInitializationInProgress; - - @javax.annotation.processing.Generated() - static private boolean $classErroneous; - - @javax.annotation.processing.Generated() - static private boolean $classInitialized; - - @javax.annotation.processing.Generated() - static private boolean $classPrepared; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv; - - @javax.annotation.processing.Generated() - static public model boolean $staticInv_free; - - public static SubClass $allocate(); - - public SubClass() { - } - - private void $objectInitializer0() { - memberVar = 41; - } - - public void $init() { - super.$init(); - $objectInitializer0(); - super.$init(); - $objectInitializer0(); - } - - private void $objectInitializer0() { - memberVar = 41; - } - - static private void $clprepare() { - } - - static public void $clinit() { - if (!@($classInitialized)) { - if (!@($classInitializationInProgress)) { - if (!@($classPrepared)) { - //Created by ClassInitializeMethodBuilder.java:219 - @($clprepare()); - } - if (@($classErroneous)) { - throw new java.lang.NoClassDefFoundError(); - } - //Created by ClassInitializeMethodBuilder.java:243 - @($classInitializationInProgress) = true; - try { - @(Test.$clinit()); - }//Created by ClassInitializeMethodBuilder.java:194 - catch (java.lang.Error err) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw err; - } catch (java.lang.Throwable twa) { - //Created by ClassInitializeMethodBuilder.java:154 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:155 - @($classErroneous) = true; - throw new java.lang.ExceptionInInitializerError(twa); - } - //Created by ClassInitializeMethodBuilder.java:249 - @($classInitializationInProgress) = false; - //Created by ClassInitializeMethodBuilder.java:251 - @($classErroneous) = false; - //Created by ClassInitializeMethodBuilder.java:253 - @($classInitialized) = true; - } - } - } - - protected void $prepare() { - super.$prepare(); - //Created by PrepareObjectBuilder.java:94 - this.memberVar = 0; - } - - private void $prepareEnter() { - super.$prepare(); - //Created by PrepareObjectBuilder.java:94 - this.memberVar = 0; - } - - public SubClass $create() { - //Created by CreateBuilder.java:57 - this.$initialized = false; - $prepareEnter(); - return this; - } - - public static SubClass $createObject() { - SubClass __NEW__; - //Created by CreateObjectBuilder.java:70 - __NEW__ = SubClass.$allocate(); - __NEW__.$create()@SubClass - return __NEW__; - } -} From 3db3d0da6777148954b76d861293be4fe38c6d32 Mon Sep 17 00:00:00 2001 From: Alexander Weigl Date: Mon, 30 Mar 2026 15:44:33 +0200 Subject: [PATCH 4/8] small adaptions, first class axiom --- .../pipeline/JMLTransformer.java | 48 +++---------- .../pipeline/RecordClassBuilder.java | 71 +++++++++++++------ .../TransformationPipelineServices.java | 56 ++++++++++----- 3 files changed, 99 insertions(+), 76 deletions(-) diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/JMLTransformer.java b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/JMLTransformer.java index c24de23403..f02c1c8601 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/JMLTransformer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/JMLTransformer.java @@ -222,7 +222,7 @@ public JMLTransformer(TransformationPipelineServices services) { for (var modifier : modifiers) { methodDecl.addModifier(modifier.getParserKeyword()); } - addSpec(methodDecl, decl); + TransformationPipelineServices.addSpec(methodDecl, decl); return methodDecl; } @@ -280,7 +280,7 @@ private void transformClassLevelComments(TypeDeclaration td) throws SLTransla // The preparser split along the grammar rules in KeYParser.g4, and gives you a list // of JML entities. - PreParser pp = getPreParser(); + PreParser pp = TransformationPipelineServices.getPreParser(); // We might have multiple textual constructs now, because the single comment could // contain multiple JML entities (e.g. method contract and ghost field declaration) @@ -301,7 +301,7 @@ private void transformClassLevelComments(TypeDeclaration td) throws SLTransla jmlModifiers = null; // these are used now // attach all specification cases accumulated so far for (TextualJMLSpecCase specCase : specCases) { - addSpec(decl, specCase); + TransformationPipelineServices.addSpec(decl, specCase); } td.addMember(decl); specCases.clear(); @@ -310,7 +310,7 @@ private void transformClassLevelComments(TypeDeclaration td) throws SLTransla || c instanceof TextualJMLClassInv || c instanceof TextualJMLInitially || c instanceof TextualJMLDepends) { - addClassSpec(td, c); + TransformationPipelineServices.addClassSpec(td, c); } else if (c instanceof TextualJMLSpecCase specCase) { // accumulate spec cases (these are model method contracts) to attach them // in a later loop iteration to the model method declaration @@ -354,7 +354,7 @@ private void transformClassLevelComments(TypeDeclaration td) throws SLTransla // add specifications to (Java) method and constructor declarations if (member instanceof CallableDeclaration c) { for (var specCase : specCases) { - addSpec(c, specCase); + TransformationPipelineServices.addSpec(c, specCase); } specCases.clear(); } @@ -387,37 +387,9 @@ private void transformClassLevelComments(TypeDeclaration td) throws SLTransla } } - private static @NonNull PreParser getPreParser() { - return new PreParser(); - } - - private void addClassSpec(TypeDeclaration td, TextualJMLConstruct c) { - if (!td.containsData(KEY_CLASS_SPEC)) { - td.setData(KEY_CLASS_SPEC, new ArrayList<>(4)); - } - List specList = td.getData(KEY_CLASS_SPEC); - specList.add(c); - } - - private void addSpec(Node nextMember, TextualJMLConstruct specCase) { - if (!nextMember.containsData(KEY_SPEC_CASE)) { - nextMember.setData(KEY_SPEC_CASE, new ArrayList<>(4)); - } - List specList = nextMember.getData(KEY_SPEC_CASE); - specList.add(specCase); - } - - private void addLoopSpec(Node nextMember, TextualJMLLoopSpec spec) { - if (!nextMember.containsData(KEY_LOOP_SPEC)) { - nextMember.setData(KEY_LOOP_SPEC, new ArrayList<>(4)); - } - List specList = nextMember.getData(KEY_LOOP_SPEC); - specList.add(spec); - } - private void transformMethodLevelCommentsAt(BlockStmt blockStmt, URI fileName) throws SLTranslationException { - PreParser io = getPreParser(); + PreParser io = TransformationPipelineServices.getPreParser(); var stmts = new ArrayList<>(blockStmt.getStatements()); var newStmts = new ArrayList(blockStmt.getStatements().size() * 2); @@ -480,7 +452,7 @@ private void transformMethodLevelCommentsAt(BlockStmt blockStmt, URI fileName) if (specifiedStmt instanceof BlockStmt || specifiedStmt instanceof NodeWithBody /* aka loops */ || specifiedStmt instanceof LabeledStmt) { - addSpec(specifiedStmt, spec); + TransformationPipelineServices.addSpec(specifiedStmt, spec); continue; } else { throw new IllegalStateException( @@ -498,7 +470,7 @@ private void transformMethodLevelCommentsAt(BlockStmt blockStmt, URI fileName) if (specifiedStmt instanceof BlockStmt || specifiedStmt instanceof NodeWithBody /* aka loops */ || specifiedStmt instanceof LabeledStmt) { - addLoopSpec(specifiedStmt, spec); + TransformationPipelineServices.addLoopSpec(specifiedStmt, spec); continue; } else { throw new IllegalStateException( @@ -546,7 +518,7 @@ public void apply(@NonNull CompilationUnit cu) { // Currently, we only support modifier at type declaration level. // Other things would be ghost classes or model imports. var input = sanitizer.asString(jdtd.jmlDocs()); - PreParser pp = getPreParser(); + PreParser pp = TransformationPipelineServices.getPreParser(); modifiers = pp.parseModifiers(input); } else { if (modifiers != null && !modifiers.isEmpty()) { @@ -578,7 +550,7 @@ public void apply(@NonNull CompilationUnit cu) { * @param hasMods the node the modifiers should be attached to */ private void transformModifiers(NodeWithModifiers hasMods) { - PreParser pp = getPreParser(); + PreParser pp = TransformationPipelineServices.getPreParser(); services.addWarnings(pp.getWarnings()); for (Modifier mod : hasMods.getModifiers()) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/RecordClassBuilder.java b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/RecordClassBuilder.java index 1dced66194..3d19932b24 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/RecordClassBuilder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/RecordClassBuilder.java @@ -5,7 +5,6 @@ import com.github.javaparser.StaticJavaParser; import com.github.javaparser.ast.CompilationUnit; -import com.github.javaparser.ast.Modifier; import com.github.javaparser.ast.NodeList; import com.github.javaparser.ast.body.*; import com.github.javaparser.ast.expr.*; @@ -14,18 +13,19 @@ import com.github.javaparser.ast.stmt.BlockStmt; import com.github.javaparser.ast.stmt.ReturnStmt; import com.github.javaparser.ast.type.Type; +import org.jspecify.annotations.Nullable; import javax.annotation.processing.Generated; import java.util.Arrays; import java.util.List; -import java.util.Objects; +import java.util.stream.Collectors; import static com.github.javaparser.ast.Modifier.DefaultKeyword.*; /// This transformation is made to transform any found [RecordDeclaration] into a corresponding /// [ClassOrInterfaceDeclaration]. -/// +/// @see [Java SE 25](https://docs.oracle.com/en/java/javase/25/language/records.html) /// @author weigl /// @since 2026-03-11 public class RecordClassBuilder extends JavaTransformer { @@ -45,28 +45,37 @@ private ClassOrInterfaceDeclaration transform(RecordDeclaration recordDeclaratio ClassOrInterfaceDeclaration clazz = new ClassOrInterfaceDeclaration(); clazz.setModifiers(recordDeclaration.getModifiers()); clazz.addModifier(FINAL); + if(clazz.isNestedType() || clazz.isLocalClassDeclaration()) { + clazz.addModifier(STATIC); // do not have a pointer to the outer this. + } clazz.setName(recordDeclaration.getName()); - clazz.addExtendedType(java.lang.Record.class); + clazz.addSingleMemberAnnotation(Generated.class, getClass().getName()); - clazz.addAnnotation(Generated.class); + services.attachTypeSpec(clazz, + equalFieldsEqualRecords(recordDeclaration)); for (Parameter parameter : recordDeclaration.getParameters()) { FieldDeclaration field = clazz.addField(parameter.type(), parameter.getNameAsString(), PRIVATE, FINAL); field.getModifiers().addAll(parameter.getModifiers()); - - MethodDeclaration getter = clazz.addMethod(parameter.getNameAsString()); - getter.setType(parameter.type()); - getter.addModifier(PUBLIC, FINAL); - for(var mod : parameter.getModifiers()) { - if(mod.getKeyword() instanceof JmlDocModifier) { - getter.getModifiers().add(mod.clone()); - } + field.addSingleMemberAnnotation(Generated.class, getClass().getName()); + + // only create a getter public final () { return ;} + // unless there is no declaration in the record. + if(recordDeclaration.getMethodsByName(parameter.getNameAsString()).isEmpty()) { + MethodDeclaration getter = clazz.addMethod(parameter.getNameAsString()); + getter.setType(parameter.type()); + getter.addModifier(PUBLIC, FINAL); + for (var mod : parameter.getModifiers()) { + if (mod.getKeyword() instanceof JmlDocModifier) { + getter.getModifiers().add(mod.clone()); + } + } + getter.getBody().get().addStatement(new ReturnStmt(parameter.getNameAsExpression())); + getter.addSingleMemberAnnotation(Generated.class, getClass().getName()); } - getter.getBody().get().addStatement(new ReturnStmt(parameter.getNameAsExpression())); } - // TODO generate equals and hashcode boolean hasNoEquals = recordDeclaration.getMethodsBySignature("equals", "java.lang.Object").isEmpty(); boolean hasNoHashcode = recordDeclaration.getMethodsBySignature("hashCode").isEmpty(); @@ -88,6 +97,7 @@ private ClassOrInterfaceDeclaration transform(RecordDeclaration recordDeclaratio body.addStatement(new ReturnStmt(equalFields)); body.addStatement(new ReturnStmt(new BooleanLiteralExpr(true))); + equals.addSingleMemberAnnotation(Generated.class, getClass().getName()); } if (hasNoHashcode) { @@ -99,11 +109,10 @@ private ClassOrInterfaceDeclaration transform(RecordDeclaration recordDeclaratio .map(it -> (Expression) it) .toList(); final Expression call = callObjects("hash", args); - hashCode.getBody().get() - .addStatement(new ReturnStmt(call)); + hashCode.getBody().get().addStatement(new ReturnStmt(call)); + hashCode.addSingleMemberAnnotation(Generated.class, getClass().getName()); } - // TODO generate toString boolean hasNoToString = recordDeclaration.getMethodsBySignature("toString").isEmpty(); if (hasNoToString) { MethodDeclaration toString = clazz.addMethod("toString", PUBLIC, FINAL, JML_NON_NULL); @@ -111,20 +120,40 @@ private ClassOrInterfaceDeclaration transform(RecordDeclaration recordDeclaratio toString.setType(String.class); ConcatBuilder concatBuilder = new ConcatBuilder(); concatBuilder.addStr(clazz.getNameAsString() + "["); - for (Parameter parameter : recordDeclaration.getParameters()) { + NodeList parameters = recordDeclaration.getParameters(); + for (int i = 0; i < parameters.size(); i++) { + Parameter parameter = parameters.get(i); concatBuilder.addStr(parameter.getNameAsString() + "="); concatBuilder.addVar(parameter.getNameAsString()); - concatBuilder.addStr(","); + if(i < parameters.size() - 1) { + concatBuilder.addStr(","); + } } concatBuilder.addStr("]"); toString.getBody().get().addStatement(new ReturnStmt(concatBuilder.expr)); + toString.addSingleMemberAnnotation(Generated.class, getClass().getName()); } - clazz.getMembers().addAll(recordDeclaration.getMembers()); return clazz; } + private static @Nullable String equalFieldsEqualRecords(RecordDeclaration recordDeclaration) { + if(recordDeclaration.getParameters().isEmpty()) { + return null; + } + + var identityOfFields = recordDeclaration.getParameters().stream() + .map(Parameter::getNameAsString) + .map(it -> "a.%s == b.%s".formatted(it, it)) + .collect(Collectors.joining(" && ")); + + return "public axiom (\\forall %s a,b; %s; a.equals(b));".formatted( + recordDeclaration.getNameAsString(), + identityOfFields + ); + } + private Expression callObjects(String method, Expression... exprs) { return callObjects(method, Arrays.stream(exprs).toList()); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/TransformationPipelineServices.java b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/TransformationPipelineServices.java index 6a9fc78154..7ecf80ca49 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/TransformationPipelineServices.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/TransformationPipelineServices.java @@ -11,6 +11,10 @@ import de.uka.ilkd.key.java.transformations.EvaluationException; import de.uka.ilkd.key.speclang.PositionedString; +import de.uka.ilkd.key.speclang.jml.pretranslation.TextualJMLConstruct; +import de.uka.ilkd.key.speclang.jml.pretranslation.TextualJMLLoopSpec; +import de.uka.ilkd.key.speclang.njml.PreParser; +import org.jspecify.annotations.NonNull; import org.key_project.util.collection.ImmutableList; import com.github.javaparser.JavaParser; @@ -54,6 +58,34 @@ public TransformationPipelineServices(JavaParserFactory javaParserFactory, this.javaParserFactory = javaParserFactory; } + static void addSpec(Node nextMember, TextualJMLConstruct specCase) { + if (!nextMember.containsData(JMLTransformer.KEY_SPEC_CASE)) { + nextMember.setData(JMLTransformer.KEY_SPEC_CASE, new ArrayList<>(4)); + } + List specList = nextMember.getData(JMLTransformer.KEY_SPEC_CASE); + specList.add(specCase); + } + + static @NonNull PreParser getPreParser() { + return new PreParser(); + } + + static void addClassSpec(TypeDeclaration td, TextualJMLConstruct c) { + if (!td.containsData(JMLTransformer.KEY_CLASS_SPEC)) { + td.setData(JMLTransformer.KEY_CLASS_SPEC, new ArrayList<>(4)); + } + List specList = td.getData(JMLTransformer.KEY_CLASS_SPEC); + specList.add(c); + } + + static void addLoopSpec(Node nextMember, TextualJMLLoopSpec spec) { + if (!nextMember.containsData(JMLTransformer.KEY_LOOP_SPEC)) { + nextMember.setData(JMLTransformer.KEY_LOOP_SPEC, new ArrayList<>(4)); + } + List specList = nextMember.getData(JMLTransformer.KEY_LOOP_SPEC); + specList.add(spec); + } + public void addWarning(PositionedString warning) { warnings.add(warning); } @@ -287,6 +319,13 @@ public Statement parseStatement(String code) { return getParser().parseStatement(code).getResult().orElseThrow(); } + public void attachTypeSpec(TypeDeclaration clazz, @Nullable String spec) { + if(spec==null) return; + PreParser pp = getPreParser(); + ImmutableList specification = pp.parseClassLevel(spec); + specification.forEach(it -> addClassSpec(clazz, it)); + } + /** * Cache of important data. This is done mainly for performance reasons. @@ -367,23 +406,6 @@ public Set recordDeclarations() { public List getAllSupertypes(TypeDeclaration td) { return td.resolve().getAncestors(); - /* - * if (td.isEnumDeclaration()) { - * return Collections.singletonList(getType("java", "lang", "Enum")); - * } - * - * if (td.isRecordDeclaration()) { - * return Collections.singletonList(getType("java", "lang", "Record")); - * } - * - * if (td.isAnnotationDeclaration()) { - * return Collections.emptyList(); - * } - * - * ClassOrInterfaceDeclaration cd = (ClassOrInterfaceDeclaration) td; - * var a = cd.resolve(); - * return typeDeclaration2allSupertypes.get(td); - */ } public List getUnits() { From 7012de7ecf1348e741a8d046ab47dbde7aad5b32 Mon Sep 17 00:00:00 2001 From: Alexander Weigl Date: Mon, 30 Mar 2026 19:36:36 +0200 Subject: [PATCH 5/8] fix IssueDialog, JML in Java printing --- .../01_EnumClassBuilder/InnerRecord.java | 4 +- .../CompactConstructor.java | 36 +- .../02_RecordClassBuilder/InnerRecord.java | 31 +- .../02_RecordClassBuilder/NotAllowed.java | 55 +- .../RecordOverwriting.java | 24 +- .../02_RecordClassBuilder/SimpleRecord.java | 25 +- .../03_JMLTransformer/CompactConstructor.java | 36 +- .../03_JMLTransformer/InnerRecord.java | 31 +- .../03_JMLTransformer/NotAllowed.java | 55 +- .../03_JMLTransformer/RecordOverwriting.java | 24 +- .../03_JMLTransformer/SimpleRecord.java | 25 +- .../04_JmlDocRemoval/CompactConstructor.java | 36 +- .../04_JmlDocRemoval/InnerRecord.java | 31 +- .../expected/04_JmlDocRemoval/NotAllowed.java | 55 +- .../04_JmlDocRemoval/RecordOverwriting.java | 24 +- .../04_JmlDocRemoval/SimpleRecord.java | 25 +- .../CompactConstructor.java | 36 +- .../05_ImplicitFieldAdder/InnerRecord.java | 31 +- .../05_ImplicitFieldAdder/NotAllowed.java | 55 +- .../RecordOverwriting.java | 24 +- .../05_ImplicitFieldAdder/SimpleRecord.java | 25 +- .../CompactConstructor.java | 36 +- .../InnerRecord.java | 31 +- .../NotAllowed.java | 55 +- .../RecordOverwriting.java | 24 +- .../SimpleRecord.java | 25 +- .../CompactConstructor.java | 51 +- .../InnerRecord.java | 39 +- .../NotAllowed.java | 67 +- .../RecordOverwriting.java | 32 +- .../SimpleRecord.java | 30 +- .../CompactConstructor.java | 51 +- .../InnerRecord.java | 39 +- .../NotAllowed.java | 67 +- .../RecordOverwriting.java | 32 +- .../SimpleRecord.java | 30 +- .../CompactConstructor.java | 51 +- .../InnerRecord.java | 39 +- .../NotAllowed.java | 67 +- .../RecordOverwriting.java | 32 +- .../SimpleRecord.java | 30 +- .../CompactConstructor.java | 51 +- .../10_PrepareObjectBuilder/InnerRecord.java | 39 +- .../10_PrepareObjectBuilder/NotAllowed.java | 67 +- .../RecordOverwriting.java | 32 +- .../10_PrepareObjectBuilder/SimpleRecord.java | 30 +- .../11_CreateBuilder/CompactConstructor.java | 51 +- .../11_CreateBuilder/InnerRecord.java | 39 +- .../expected/11_CreateBuilder/NotAllowed.java | 67 +- .../11_CreateBuilder/RecordOverwriting.java | 32 +- .../11_CreateBuilder/SimpleRecord.java | 30 +- .../CompactConstructor.java | 51 +- .../12_CreateObjectBuilder/InnerRecord.java | 39 +- .../12_CreateObjectBuilder/NotAllowed.java | 67 +- .../RecordOverwriting.java | 32 +- .../12_CreateObjectBuilder/SimpleRecord.java | 30 +- .../CompactConstructor.java | 51 +- .../InnerRecord.java | 39 +- .../NotAllowed.java | 67 +- .../RecordOverwriting.java | 32 +- .../SimpleRecord.java | 30 +- .../CompactConstructor.java | 51 +- .../InnerRecord.java | 39 +- .../NotAllowed.java | 67 +- .../RecordOverwriting.java | 32 +- .../SimpleRecord.java | 30 +- .../records/input/InnerRecord.java | 4 +- .../pipelineTests/records/input/Point3d.java | 1 + .../uka/ilkd/key/java/SpecialJavaPrinter.java | 1333 +++++++++++++++++ .../key/java/transformations/AstFactory.java | 4 + .../pipeline/JavaTransformer.java | 11 +- .../pipeline/RecordClassBuilder.java | 133 +- .../TransformationPipelineServices.java | 23 + .../key/proof/init/ProblemInitializer.java | 2 +- .../de/uka/ilkd/key/util/ExceptionTools.java | 2 +- .../src/test/java/KeyJavaPipelineTest.java | 12 +- key.ui/examples/Java/Records/src/Point.java | 21 + .../java/de/uka/ilkd/key/gui/IssueDialog.java | 82 +- 78 files changed, 3509 insertions(+), 730 deletions(-) create mode 100644 key.core/pipelineTests/records/input/Point3d.java create mode 100644 key.core/src/main/java/de/uka/ilkd/key/java/SpecialJavaPrinter.java create mode 100644 key.ui/examples/Java/Records/src/Point.java diff --git a/key.core/pipelineTests/records/expected/01_EnumClassBuilder/InnerRecord.java b/key.core/pipelineTests/records/expected/01_EnumClassBuilder/InnerRecord.java index b610cfc529..2046d14ecf 100644 --- a/key.core/pipelineTests/records/expected/01_EnumClassBuilder/InnerRecord.java +++ b/key.core/pipelineTests/records/expected/01_EnumClassBuilder/InnerRecord.java @@ -1,4 +1,6 @@ -class OuterClass { +import java.lang.Object; + +public class OuterClass { final record MyRecord(String test) { } diff --git a/key.core/pipelineTests/records/expected/02_RecordClassBuilder/CompactConstructor.java b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/CompactConstructor.java index 639557a99b..df0404e2f0 100644 --- a/key.core/pipelineTests/records/expected/02_RecordClassBuilder/CompactConstructor.java +++ b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/CompactConstructor.java @@ -1,36 +1,62 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class Mapping extends Record { - + //@ axiom (\forall Mapping a, b; a.from == b.from&&a.to == b.to; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String from; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String from() { return from; } + @javax.annotation.processing.Generated("RecordClassBuilder") private final String to; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String to() { return to; } + @javax.annotation.processing.Generated("RecordClassBuilder") + public Mapping(String from, String to) { + { + // compact constructor! + from = "abc"; + to = "def"; + } + //Created by RecordClassBuilder.java:105 + this.from = from; + //Created by RecordClassBuilder.java:105 + this.to = to; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Mapping that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Mapping)) return false; + //Created by RecordClassBuilder.java:171 + final Mapping that = (Mapping) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(from, that.from) && java.lang.Objects.equals(to, that.to); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(from, to); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Mapping[" + "from=" + from + "," + "to=" + to + "," + "]"; + return "Mapping[" + "from=" + from + "," + "to=" + to + "]"; } Mapping { diff --git a/key.core/pipelineTests/records/expected/02_RecordClassBuilder/InnerRecord.java b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/InnerRecord.java index 7c4ad3556a..bd5f4774cf 100644 --- a/key.core/pipelineTests/records/expected/02_RecordClassBuilder/InnerRecord.java +++ b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/InnerRecord.java @@ -1,32 +1,51 @@ -class OuterClass { +import java.lang.Object; - @Generated() - final class MyRecord extends Record { +public class OuterClass { + @javax.annotation.processing.Generated("RecordClassBuilder") + final class MyRecord extends Record { + //@ axiom (\forall MyRecord a, b; a.test == b.test; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String test; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String test() { return test; } + @javax.annotation.processing.Generated("RecordClassBuilder") + public MyRecord(String test) { + //Created by RecordClassBuilder.java:105 + this.test = test; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof MyRecord that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof MyRecord)) return false; + //Created by RecordClassBuilder.java:171 + final MyRecord that = (MyRecord) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(test, that.test); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(test); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "MyRecord[" + "test=" + test + "," + "]"; + return "MyRecord[" + "test=" + test + "]"; } } } diff --git a/key.core/pipelineTests/records/expected/02_RecordClassBuilder/NotAllowed.java b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/NotAllowed.java index 1fb5d2ed73..804f713362 100644 --- a/key.core/pipelineTests/records/expected/02_RecordClassBuilder/NotAllowed.java +++ b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/NotAllowed.java @@ -1,32 +1,48 @@ //https://mikemybytes.com/2022/02/16/java-records-and-compact-constructors/ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class // package-private Name extends Record { - + //@ axiom (\forall Name a, b; a.name == b.name; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String name; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String name() { return name; } + // was package)' + private Name(String name) { + this.name = name; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Name that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Name)) return false; + //Created by RecordClassBuilder.java:171 + final Name that = (Name) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(name, that.name); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(name); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Name[" + "name=" + name + "," + "]"; + return "Name[" + "name=" + name + "]"; } // was package)' @@ -39,39 +55,58 @@ static Name of(String name) { } } -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class Point extends Record { - + //@ axiom (\forall Point a, b; a.x == b.x&&a.y == b.y; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final int x; + @javax.annotation.processing.Generated("RecordClassBuilder") public final int x() { return x; } + @javax.annotation.processing.Generated("RecordClassBuilder") private final int y; + @javax.annotation.processing.Generated("RecordClassBuilder") public final int y() { return y; } + Point(int x, int y) { + // boring! + this.x = x; + this.y = y; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Point that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Point)) return false; + //Created by RecordClassBuilder.java:171 + final Point that = (Point) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(x, that.x) && java.lang.Objects.equals(y, that.y); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(x, y); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Point[" + "x=" + x + "," + "y=" + y + "," + "]"; + return "Point[" + "x=" + x + "," + "y=" + y + "]"; } Point(int x, int y) { diff --git a/key.core/pipelineTests/records/expected/02_RecordClassBuilder/RecordOverwriting.java b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/RecordOverwriting.java index dd06d25703..6ccd9782ab 100644 --- a/key.core/pipelineTests/records/expected/02_RecordClassBuilder/RecordOverwriting.java +++ b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/RecordOverwriting.java @@ -1,25 +1,19 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class MyRecord extends Record { - + //@ axiom (\forall MyRecord a, b; a.test == b.test; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String test; - public final String test() { - return test; - } - - @Override() - public final boolean hashCode(java.lang.Object o) { - if (this == o) - return true; - if (!(o instanceof MyRecord that)) - return false; - return java.lang.Objects.equals(test, that.test); - return true; + @javax.annotation.processing.Generated("RecordClassBuilder") + public MyRecord(String test) { + //Created by RecordClassBuilder.java:105 + this.test = test; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "MyRecord[" + "test=" + test + "," + "]"; + return "MyRecord[" + "test=" + test + "]"; } public int hashCode() { diff --git a/key.core/pipelineTests/records/expected/02_RecordClassBuilder/SimpleRecord.java b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/SimpleRecord.java index 486dff4fd0..00b14e7f4f 100644 --- a/key.core/pipelineTests/records/expected/02_RecordClassBuilder/SimpleRecord.java +++ b/key.core/pipelineTests/records/expected/02_RecordClassBuilder/SimpleRecord.java @@ -1,30 +1,45 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") public final class SimpleRecord extends Record { - + //@ axiom (\forall SimpleRecord a, b; a.name == b.name; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final /*@ nullable */ String name; + @javax.annotation.processing.Generated("RecordClassBuilder") public final /*@ nullable */ String name() { return name; } + SimpleRecord(String name) { + this.name = name; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof SimpleRecord that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof SimpleRecord)) return false; + //Created by RecordClassBuilder.java:171 + final SimpleRecord that = (SimpleRecord) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(name, that.name); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(name); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "SimpleRecord[" + "name=" + name + "," + "]"; + return "SimpleRecord[" + "name=" + name + "]"; } SimpleRecord(String name) { diff --git a/key.core/pipelineTests/records/expected/03_JMLTransformer/CompactConstructor.java b/key.core/pipelineTests/records/expected/03_JMLTransformer/CompactConstructor.java index 639557a99b..df0404e2f0 100644 --- a/key.core/pipelineTests/records/expected/03_JMLTransformer/CompactConstructor.java +++ b/key.core/pipelineTests/records/expected/03_JMLTransformer/CompactConstructor.java @@ -1,36 +1,62 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class Mapping extends Record { - + //@ axiom (\forall Mapping a, b; a.from == b.from&&a.to == b.to; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String from; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String from() { return from; } + @javax.annotation.processing.Generated("RecordClassBuilder") private final String to; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String to() { return to; } + @javax.annotation.processing.Generated("RecordClassBuilder") + public Mapping(String from, String to) { + { + // compact constructor! + from = "abc"; + to = "def"; + } + //Created by RecordClassBuilder.java:105 + this.from = from; + //Created by RecordClassBuilder.java:105 + this.to = to; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Mapping that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Mapping)) return false; + //Created by RecordClassBuilder.java:171 + final Mapping that = (Mapping) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(from, that.from) && java.lang.Objects.equals(to, that.to); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(from, to); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Mapping[" + "from=" + from + "," + "to=" + to + "," + "]"; + return "Mapping[" + "from=" + from + "," + "to=" + to + "]"; } Mapping { diff --git a/key.core/pipelineTests/records/expected/03_JMLTransformer/InnerRecord.java b/key.core/pipelineTests/records/expected/03_JMLTransformer/InnerRecord.java index 7c4ad3556a..bd5f4774cf 100644 --- a/key.core/pipelineTests/records/expected/03_JMLTransformer/InnerRecord.java +++ b/key.core/pipelineTests/records/expected/03_JMLTransformer/InnerRecord.java @@ -1,32 +1,51 @@ -class OuterClass { +import java.lang.Object; - @Generated() - final class MyRecord extends Record { +public class OuterClass { + @javax.annotation.processing.Generated("RecordClassBuilder") + final class MyRecord extends Record { + //@ axiom (\forall MyRecord a, b; a.test == b.test; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String test; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String test() { return test; } + @javax.annotation.processing.Generated("RecordClassBuilder") + public MyRecord(String test) { + //Created by RecordClassBuilder.java:105 + this.test = test; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof MyRecord that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof MyRecord)) return false; + //Created by RecordClassBuilder.java:171 + final MyRecord that = (MyRecord) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(test, that.test); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(test); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "MyRecord[" + "test=" + test + "," + "]"; + return "MyRecord[" + "test=" + test + "]"; } } } diff --git a/key.core/pipelineTests/records/expected/03_JMLTransformer/NotAllowed.java b/key.core/pipelineTests/records/expected/03_JMLTransformer/NotAllowed.java index 1fb5d2ed73..804f713362 100644 --- a/key.core/pipelineTests/records/expected/03_JMLTransformer/NotAllowed.java +++ b/key.core/pipelineTests/records/expected/03_JMLTransformer/NotAllowed.java @@ -1,32 +1,48 @@ //https://mikemybytes.com/2022/02/16/java-records-and-compact-constructors/ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class // package-private Name extends Record { - + //@ axiom (\forall Name a, b; a.name == b.name; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String name; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String name() { return name; } + // was package)' + private Name(String name) { + this.name = name; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Name that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Name)) return false; + //Created by RecordClassBuilder.java:171 + final Name that = (Name) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(name, that.name); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(name); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Name[" + "name=" + name + "," + "]"; + return "Name[" + "name=" + name + "]"; } // was package)' @@ -39,39 +55,58 @@ static Name of(String name) { } } -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class Point extends Record { - + //@ axiom (\forall Point a, b; a.x == b.x&&a.y == b.y; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final int x; + @javax.annotation.processing.Generated("RecordClassBuilder") public final int x() { return x; } + @javax.annotation.processing.Generated("RecordClassBuilder") private final int y; + @javax.annotation.processing.Generated("RecordClassBuilder") public final int y() { return y; } + Point(int x, int y) { + // boring! + this.x = x; + this.y = y; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Point that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Point)) return false; + //Created by RecordClassBuilder.java:171 + final Point that = (Point) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(x, that.x) && java.lang.Objects.equals(y, that.y); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(x, y); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Point[" + "x=" + x + "," + "y=" + y + "," + "]"; + return "Point[" + "x=" + x + "," + "y=" + y + "]"; } Point(int x, int y) { diff --git a/key.core/pipelineTests/records/expected/03_JMLTransformer/RecordOverwriting.java b/key.core/pipelineTests/records/expected/03_JMLTransformer/RecordOverwriting.java index dd06d25703..6ccd9782ab 100644 --- a/key.core/pipelineTests/records/expected/03_JMLTransformer/RecordOverwriting.java +++ b/key.core/pipelineTests/records/expected/03_JMLTransformer/RecordOverwriting.java @@ -1,25 +1,19 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class MyRecord extends Record { - + //@ axiom (\forall MyRecord a, b; a.test == b.test; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String test; - public final String test() { - return test; - } - - @Override() - public final boolean hashCode(java.lang.Object o) { - if (this == o) - return true; - if (!(o instanceof MyRecord that)) - return false; - return java.lang.Objects.equals(test, that.test); - return true; + @javax.annotation.processing.Generated("RecordClassBuilder") + public MyRecord(String test) { + //Created by RecordClassBuilder.java:105 + this.test = test; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "MyRecord[" + "test=" + test + "," + "]"; + return "MyRecord[" + "test=" + test + "]"; } public int hashCode() { diff --git a/key.core/pipelineTests/records/expected/03_JMLTransformer/SimpleRecord.java b/key.core/pipelineTests/records/expected/03_JMLTransformer/SimpleRecord.java index a321870cb4..f136fd43f0 100644 --- a/key.core/pipelineTests/records/expected/03_JMLTransformer/SimpleRecord.java +++ b/key.core/pipelineTests/records/expected/03_JMLTransformer/SimpleRecord.java @@ -1,30 +1,45 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") public final class SimpleRecord extends Record { - + //@ axiom (\forall SimpleRecord a, b; a.name == b.name; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final /*@ nullable */ nullable String name; + @javax.annotation.processing.Generated("RecordClassBuilder") public final /*@ nullable */ nullable String name() { return name; } + SimpleRecord(String name) { + this.name = name; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof SimpleRecord that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof SimpleRecord)) return false; + //Created by RecordClassBuilder.java:171 + final SimpleRecord that = (SimpleRecord) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(name, that.name); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(name); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "SimpleRecord[" + "name=" + name + "," + "]"; + return "SimpleRecord[" + "name=" + name + "]"; } SimpleRecord(String name) { diff --git a/key.core/pipelineTests/records/expected/04_JmlDocRemoval/CompactConstructor.java b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/CompactConstructor.java index 639557a99b..df0404e2f0 100644 --- a/key.core/pipelineTests/records/expected/04_JmlDocRemoval/CompactConstructor.java +++ b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/CompactConstructor.java @@ -1,36 +1,62 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class Mapping extends Record { - + //@ axiom (\forall Mapping a, b; a.from == b.from&&a.to == b.to; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String from; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String from() { return from; } + @javax.annotation.processing.Generated("RecordClassBuilder") private final String to; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String to() { return to; } + @javax.annotation.processing.Generated("RecordClassBuilder") + public Mapping(String from, String to) { + { + // compact constructor! + from = "abc"; + to = "def"; + } + //Created by RecordClassBuilder.java:105 + this.from = from; + //Created by RecordClassBuilder.java:105 + this.to = to; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Mapping that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Mapping)) return false; + //Created by RecordClassBuilder.java:171 + final Mapping that = (Mapping) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(from, that.from) && java.lang.Objects.equals(to, that.to); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(from, to); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Mapping[" + "from=" + from + "," + "to=" + to + "," + "]"; + return "Mapping[" + "from=" + from + "," + "to=" + to + "]"; } Mapping { diff --git a/key.core/pipelineTests/records/expected/04_JmlDocRemoval/InnerRecord.java b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/InnerRecord.java index 7c4ad3556a..bd5f4774cf 100644 --- a/key.core/pipelineTests/records/expected/04_JmlDocRemoval/InnerRecord.java +++ b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/InnerRecord.java @@ -1,32 +1,51 @@ -class OuterClass { +import java.lang.Object; - @Generated() - final class MyRecord extends Record { +public class OuterClass { + @javax.annotation.processing.Generated("RecordClassBuilder") + final class MyRecord extends Record { + //@ axiom (\forall MyRecord a, b; a.test == b.test; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String test; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String test() { return test; } + @javax.annotation.processing.Generated("RecordClassBuilder") + public MyRecord(String test) { + //Created by RecordClassBuilder.java:105 + this.test = test; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof MyRecord that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof MyRecord)) return false; + //Created by RecordClassBuilder.java:171 + final MyRecord that = (MyRecord) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(test, that.test); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(test); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "MyRecord[" + "test=" + test + "," + "]"; + return "MyRecord[" + "test=" + test + "]"; } } } diff --git a/key.core/pipelineTests/records/expected/04_JmlDocRemoval/NotAllowed.java b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/NotAllowed.java index 1fb5d2ed73..804f713362 100644 --- a/key.core/pipelineTests/records/expected/04_JmlDocRemoval/NotAllowed.java +++ b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/NotAllowed.java @@ -1,32 +1,48 @@ //https://mikemybytes.com/2022/02/16/java-records-and-compact-constructors/ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class // package-private Name extends Record { - + //@ axiom (\forall Name a, b; a.name == b.name; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String name; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String name() { return name; } + // was package)' + private Name(String name) { + this.name = name; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Name that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Name)) return false; + //Created by RecordClassBuilder.java:171 + final Name that = (Name) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(name, that.name); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(name); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Name[" + "name=" + name + "," + "]"; + return "Name[" + "name=" + name + "]"; } // was package)' @@ -39,39 +55,58 @@ static Name of(String name) { } } -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class Point extends Record { - + //@ axiom (\forall Point a, b; a.x == b.x&&a.y == b.y; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final int x; + @javax.annotation.processing.Generated("RecordClassBuilder") public final int x() { return x; } + @javax.annotation.processing.Generated("RecordClassBuilder") private final int y; + @javax.annotation.processing.Generated("RecordClassBuilder") public final int y() { return y; } + Point(int x, int y) { + // boring! + this.x = x; + this.y = y; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Point that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Point)) return false; + //Created by RecordClassBuilder.java:171 + final Point that = (Point) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(x, that.x) && java.lang.Objects.equals(y, that.y); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(x, y); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Point[" + "x=" + x + "," + "y=" + y + "," + "]"; + return "Point[" + "x=" + x + "," + "y=" + y + "]"; } Point(int x, int y) { diff --git a/key.core/pipelineTests/records/expected/04_JmlDocRemoval/RecordOverwriting.java b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/RecordOverwriting.java index dd06d25703..6ccd9782ab 100644 --- a/key.core/pipelineTests/records/expected/04_JmlDocRemoval/RecordOverwriting.java +++ b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/RecordOverwriting.java @@ -1,25 +1,19 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class MyRecord extends Record { - + //@ axiom (\forall MyRecord a, b; a.test == b.test; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String test; - public final String test() { - return test; - } - - @Override() - public final boolean hashCode(java.lang.Object o) { - if (this == o) - return true; - if (!(o instanceof MyRecord that)) - return false; - return java.lang.Objects.equals(test, that.test); - return true; + @javax.annotation.processing.Generated("RecordClassBuilder") + public MyRecord(String test) { + //Created by RecordClassBuilder.java:105 + this.test = test; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "MyRecord[" + "test=" + test + "," + "]"; + return "MyRecord[" + "test=" + test + "]"; } public int hashCode() { diff --git a/key.core/pipelineTests/records/expected/04_JmlDocRemoval/SimpleRecord.java b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/SimpleRecord.java index 871598267b..7c78130439 100644 --- a/key.core/pipelineTests/records/expected/04_JmlDocRemoval/SimpleRecord.java +++ b/key.core/pipelineTests/records/expected/04_JmlDocRemoval/SimpleRecord.java @@ -1,30 +1,45 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") public final class SimpleRecord extends Record { - + //@ axiom (\forall SimpleRecord a, b; a.name == b.name; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final nullable String name; + @javax.annotation.processing.Generated("RecordClassBuilder") public final nullable String name() { return name; } + SimpleRecord(String name) { + this.name = name; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof SimpleRecord that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof SimpleRecord)) return false; + //Created by RecordClassBuilder.java:171 + final SimpleRecord that = (SimpleRecord) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(name, that.name); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(name); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "SimpleRecord[" + "name=" + name + "," + "]"; + return "SimpleRecord[" + "name=" + name + "]"; } SimpleRecord(String name) { diff --git a/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/CompactConstructor.java b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/CompactConstructor.java index bffc624f91..07c0978089 100644 --- a/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/CompactConstructor.java +++ b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/CompactConstructor.java @@ -1,36 +1,62 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class Mapping extends Record { - + //@ axiom (\forall Mapping a, b; a.from == b.from&&a.to == b.to; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String from; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String from() { return from; } + @javax.annotation.processing.Generated("RecordClassBuilder") private final String to; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String to() { return to; } + @javax.annotation.processing.Generated("RecordClassBuilder") + public Mapping(String from, String to) { + { + // compact constructor! + from = "abc"; + to = "def"; + } + //Created by RecordClassBuilder.java:105 + this.from = from; + //Created by RecordClassBuilder.java:105 + this.to = to; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Mapping that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Mapping)) return false; + //Created by RecordClassBuilder.java:171 + final Mapping that = (Mapping) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(from, that.from) && java.lang.Objects.equals(to, that.to); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(from, to); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Mapping[" + "from=" + from + "," + "to=" + to + "," + "]"; + return "Mapping[" + "from=" + from + "," + "to=" + to + "]"; } Mapping { diff --git a/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/InnerRecord.java b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/InnerRecord.java index d6f91e3ded..3a0e436b83 100644 --- a/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/InnerRecord.java +++ b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/InnerRecord.java @@ -1,32 +1,51 @@ -class OuterClass { +import java.lang.Object; - @Generated() - final class MyRecord extends Record { +public class OuterClass { + @javax.annotation.processing.Generated("RecordClassBuilder") + final class MyRecord extends Record { + //@ axiom (\forall MyRecord a, b; a.test == b.test; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String test; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String test() { return test; } + @javax.annotation.processing.Generated("RecordClassBuilder") + public MyRecord(String test) { + //Created by RecordClassBuilder.java:105 + this.test = test; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof MyRecord that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof MyRecord)) return false; + //Created by RecordClassBuilder.java:171 + final MyRecord that = (MyRecord) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(test, that.test); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(test); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "MyRecord[" + "test=" + test + "," + "]"; + return "MyRecord[" + "test=" + test + "]"; } @javax.annotation.processing.Generated() diff --git a/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/NotAllowed.java b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/NotAllowed.java index 49f7549c37..ee842abc9c 100644 --- a/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/NotAllowed.java +++ b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/NotAllowed.java @@ -1,32 +1,48 @@ //https://mikemybytes.com/2022/02/16/java-records-and-compact-constructors/ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class // package-private Name extends Record { - + //@ axiom (\forall Name a, b; a.name == b.name; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String name; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String name() { return name; } + // was package)' + private Name(String name) { + this.name = name; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Name that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Name)) return false; + //Created by RecordClassBuilder.java:171 + final Name that = (Name) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(name, that.name); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(name); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Name[" + "name=" + name + "," + "]"; + return "Name[" + "name=" + name + "]"; } // was package)' @@ -57,39 +73,58 @@ static Name of(String name) { static public model boolean $staticInv_free; } -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class Point extends Record { - + //@ axiom (\forall Point a, b; a.x == b.x&&a.y == b.y; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final int x; + @javax.annotation.processing.Generated("RecordClassBuilder") public final int x() { return x; } + @javax.annotation.processing.Generated("RecordClassBuilder") private final int y; + @javax.annotation.processing.Generated("RecordClassBuilder") public final int y() { return y; } + Point(int x, int y) { + // boring! + this.x = x; + this.y = y; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Point that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Point)) return false; + //Created by RecordClassBuilder.java:171 + final Point that = (Point) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(x, that.x) && java.lang.Objects.equals(y, that.y); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(x, y); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Point[" + "x=" + x + "," + "y=" + y + "," + "]"; + return "Point[" + "x=" + x + "," + "y=" + y + "]"; } Point(int x, int y) { diff --git a/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/RecordOverwriting.java b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/RecordOverwriting.java index b82d97d210..4a21e46b9e 100644 --- a/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/RecordOverwriting.java +++ b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/RecordOverwriting.java @@ -1,25 +1,19 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class MyRecord extends Record { - + //@ axiom (\forall MyRecord a, b; a.test == b.test; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String test; - public final String test() { - return test; - } - - @Override() - public final boolean hashCode(java.lang.Object o) { - if (this == o) - return true; - if (!(o instanceof MyRecord that)) - return false; - return java.lang.Objects.equals(test, that.test); - return true; + @javax.annotation.processing.Generated("RecordClassBuilder") + public MyRecord(String test) { + //Created by RecordClassBuilder.java:105 + this.test = test; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "MyRecord[" + "test=" + test + "," + "]"; + return "MyRecord[" + "test=" + test + "]"; } public int hashCode() { diff --git a/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/SimpleRecord.java b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/SimpleRecord.java index f09aa83267..3f7d3ec48d 100644 --- a/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/SimpleRecord.java +++ b/key.core/pipelineTests/records/expected/05_ImplicitFieldAdder/SimpleRecord.java @@ -1,30 +1,45 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") public final class SimpleRecord extends Record { - + //@ axiom (\forall SimpleRecord a, b; a.name == b.name; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final nullable String name; + @javax.annotation.processing.Generated("RecordClassBuilder") public final nullable String name() { return name; } + SimpleRecord(String name) { + this.name = name; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof SimpleRecord that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof SimpleRecord)) return false; + //Created by RecordClassBuilder.java:171 + final SimpleRecord that = (SimpleRecord) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(name, that.name); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(name); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "SimpleRecord[" + "name=" + name + "," + "]"; + return "SimpleRecord[" + "name=" + name + "]"; } SimpleRecord(String name) { diff --git a/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/CompactConstructor.java b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/CompactConstructor.java index bd195fa7ab..433dc47767 100644 --- a/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/CompactConstructor.java +++ b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/CompactConstructor.java @@ -1,36 +1,62 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class Mapping extends Record { - + //@ axiom (\forall Mapping a, b; a.from == b.from&&a.to == b.to; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String from; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String from() { return from; } + @javax.annotation.processing.Generated("RecordClassBuilder") private final String to; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String to() { return to; } + @javax.annotation.processing.Generated("RecordClassBuilder") + public Mapping(String from, String to) { + { + // compact constructor! + from = "abc"; + to = "def"; + } + //Created by RecordClassBuilder.java:105 + this.from = from; + //Created by RecordClassBuilder.java:105 + this.to = to; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Mapping that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Mapping)) return false; + //Created by RecordClassBuilder.java:171 + final Mapping that = (Mapping) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(from, that.from) && java.lang.Objects.equals(to, that.to); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(from, to); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Mapping[" + "from=" + from + "," + "to=" + to + "," + "]"; + return "Mapping[" + "from=" + from + "," + "to=" + to + "]"; } Mapping { diff --git a/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/InnerRecord.java b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/InnerRecord.java index 795cae4c43..d2f0626491 100644 --- a/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/InnerRecord.java +++ b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/InnerRecord.java @@ -1,32 +1,51 @@ -class OuterClass { +import java.lang.Object; - @Generated() - final class MyRecord extends Record { +public class OuterClass { + @javax.annotation.processing.Generated("RecordClassBuilder") + final class MyRecord extends Record { + //@ axiom (\forall MyRecord a, b; a.test == b.test; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String test; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String test() { return test; } + @javax.annotation.processing.Generated("RecordClassBuilder") + public MyRecord(String test) { + //Created by RecordClassBuilder.java:105 + this.test = test; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof MyRecord that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof MyRecord)) return false; + //Created by RecordClassBuilder.java:171 + final MyRecord that = (MyRecord) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(test, that.test); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(test); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "MyRecord[" + "test=" + test + "," + "]"; + return "MyRecord[" + "test=" + test + "]"; } @javax.annotation.processing.Generated() diff --git a/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/NotAllowed.java b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/NotAllowed.java index 7ca3601dd7..b7aa4e9fd6 100644 --- a/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/NotAllowed.java +++ b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/NotAllowed.java @@ -1,32 +1,48 @@ //https://mikemybytes.com/2022/02/16/java-records-and-compact-constructors/ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class // package-private Name extends Record { - + //@ axiom (\forall Name a, b; a.name == b.name; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String name; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String name() { return name; } + // was package)' + private Name(String name) { + this.name = name; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Name that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Name)) return false; + //Created by RecordClassBuilder.java:171 + final Name that = (Name) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(name, that.name); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(name); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Name[" + "name=" + name + "," + "]"; + return "Name[" + "name=" + name + "]"; } // was package)' @@ -60,39 +76,58 @@ static Name of(String name) { Name $allocate(); } -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class Point extends Record { - + //@ axiom (\forall Point a, b; a.x == b.x&&a.y == b.y; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final int x; + @javax.annotation.processing.Generated("RecordClassBuilder") public final int x() { return x; } + @javax.annotation.processing.Generated("RecordClassBuilder") private final int y; + @javax.annotation.processing.Generated("RecordClassBuilder") public final int y() { return y; } + Point(int x, int y) { + // boring! + this.x = x; + this.y = y; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Point that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Point)) return false; + //Created by RecordClassBuilder.java:171 + final Point that = (Point) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(x, that.x) && java.lang.Objects.equals(y, that.y); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(x, y); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Point[" + "x=" + x + "," + "y=" + y + "," + "]"; + return "Point[" + "x=" + x + "," + "y=" + y + "]"; } Point(int x, int y) { diff --git a/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/RecordOverwriting.java b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/RecordOverwriting.java index 91c79505a6..f44d83760a 100644 --- a/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/RecordOverwriting.java +++ b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/RecordOverwriting.java @@ -1,25 +1,19 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class MyRecord extends Record { - + //@ axiom (\forall MyRecord a, b; a.test == b.test; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String test; - public final String test() { - return test; - } - - @Override() - public final boolean hashCode(java.lang.Object o) { - if (this == o) - return true; - if (!(o instanceof MyRecord that)) - return false; - return java.lang.Objects.equals(test, that.test); - return true; + @javax.annotation.processing.Generated("RecordClassBuilder") + public MyRecord(String test) { + //Created by RecordClassBuilder.java:105 + this.test = test; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "MyRecord[" + "test=" + test + "," + "]"; + return "MyRecord[" + "test=" + test + "]"; } public int hashCode() { diff --git a/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/SimpleRecord.java b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/SimpleRecord.java index 46cd08e9b4..75f1bde5cc 100644 --- a/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/SimpleRecord.java +++ b/key.core/pipelineTests/records/expected/06_InstanceAllocationMethodBuilder/SimpleRecord.java @@ -1,30 +1,45 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") public final class SimpleRecord extends Record { - + //@ axiom (\forall SimpleRecord a, b; a.name == b.name; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final nullable String name; + @javax.annotation.processing.Generated("RecordClassBuilder") public final nullable String name() { return name; } + SimpleRecord(String name) { + this.name = name; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof SimpleRecord that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof SimpleRecord)) return false; + //Created by RecordClassBuilder.java:171 + final SimpleRecord that = (SimpleRecord) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(name, that.name); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(name); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "SimpleRecord[" + "name=" + name + "," + "]"; + return "SimpleRecord[" + "name=" + name + "]"; } SimpleRecord(String name) { diff --git a/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/CompactConstructor.java b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/CompactConstructor.java index a3d6e7e007..7c118e6799 100644 --- a/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/CompactConstructor.java +++ b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/CompactConstructor.java @@ -1,36 +1,62 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class Mapping extends Record { - + //@ axiom (\forall Mapping a, b; a.from == b.from&&a.to == b.to; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String from; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String from() { return from; } + @javax.annotation.processing.Generated("RecordClassBuilder") private final String to; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String to() { return to; } + @javax.annotation.processing.Generated("RecordClassBuilder") + public Mapping(String from, String to) { + { + // compact constructor! + from = "abc"; + to = "def"; + } + //Created by RecordClassBuilder.java:105 + this.from = from; + //Created by RecordClassBuilder.java:105 + this.to = to; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Mapping that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Mapping)) return false; + //Created by RecordClassBuilder.java:171 + final Mapping that = (Mapping) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(from, that.from) && java.lang.Objects.equals(to, that.to); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(from, to); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Mapping[" + "from=" + from + "," + "to=" + to + "," + "]"; + return "Mapping[" + "from=" + from + "," + "to=" + to + "]"; } Mapping { @@ -59,11 +85,16 @@ public final non_null String toString() { public static Mapping $allocate(); - public Mapping() { - } - - public void $init() { - super.$init(); + public void $init(String from, String to) { super.$init(); + { + // compact constructor! + from = "abc"; + to = "def"; + } + //Created by RecordClassBuilder.java:105 + this.from = from; + //Created by RecordClassBuilder.java:105 + this.to = to; } } diff --git a/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/InnerRecord.java b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/InnerRecord.java index ecb99c982f..07a283e4e4 100644 --- a/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/InnerRecord.java +++ b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/InnerRecord.java @@ -1,32 +1,51 @@ -class OuterClass { +import java.lang.Object; - @Generated() - final class MyRecord extends Record { +public class OuterClass { + @javax.annotation.processing.Generated("RecordClassBuilder") + final class MyRecord extends Record { + //@ axiom (\forall MyRecord a, b; a.test == b.test; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String test; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String test() { return test; } + @javax.annotation.processing.Generated("RecordClassBuilder") + public MyRecord(String test) { + //Created by RecordClassBuilder.java:105 + this.test = test; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof MyRecord that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof MyRecord)) return false; + //Created by RecordClassBuilder.java:171 + final MyRecord that = (MyRecord) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(test, that.test); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(test); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "MyRecord[" + "test=" + test + "," + "]"; + return "MyRecord[" + "test=" + test + "]"; } @javax.annotation.processing.Generated() @@ -51,13 +70,11 @@ public final non_null String toString() { public static MyRecord $allocate(); - public MyRecord() { - } - - public void $init(OuterClass $ENCLOSING_THIS) { + public void $init(String test, OuterClass $ENCLOSING_THIS) { super.$init(); this.$enclosingThis = $ENCLOSING_THIS; - super.$init(); + //Created by RecordClassBuilder.java:105 + this.test = test; } } diff --git a/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/NotAllowed.java b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/NotAllowed.java index 6f34a562ac..dd32d4fa09 100644 --- a/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/NotAllowed.java +++ b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/NotAllowed.java @@ -1,32 +1,48 @@ //https://mikemybytes.com/2022/02/16/java-records-and-compact-constructors/ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class // package-private Name extends Record { - + //@ axiom (\forall Name a, b; a.name == b.name; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String name; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String name() { return name; } + // was package)' + private Name(String name) { + this.name = name; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Name that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Name)) return false; + //Created by RecordClassBuilder.java:171 + final Name that = (Name) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(name, that.name); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(name); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Name[" + "name=" + name + "," + "]"; + return "Name[" + "name=" + name + "]"; } // was package)' @@ -63,41 +79,65 @@ static Name of(String name) { super.$init(); this.name = name; } + + private void $init(String name) { + super.$init(); + this.name = name; + } } -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class Point extends Record { - + //@ axiom (\forall Point a, b; a.x == b.x&&a.y == b.y; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final int x; + @javax.annotation.processing.Generated("RecordClassBuilder") public final int x() { return x; } + @javax.annotation.processing.Generated("RecordClassBuilder") private final int y; + @javax.annotation.processing.Generated("RecordClassBuilder") public final int y() { return y; } + Point(int x, int y) { + // boring! + this.x = x; + this.y = y; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Point that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Point)) return false; + //Created by RecordClassBuilder.java:171 + final Point that = (Point) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(x, that.x) && java.lang.Objects.equals(y, that.y); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(x, y); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Point[" + "x=" + x + "," + "y=" + y + "," + "]"; + return "Point[" + "x=" + x + "," + "y=" + y + "]"; } Point(int x, int y) { @@ -144,6 +184,13 @@ public final non_null String toString() { this.y = y; } + void $init(int x, int y) { + super.$init(); + // boring! + this.x = x; + this.y = y; + } + void $init(int x) { this.$init(x, 0); } diff --git a/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/RecordOverwriting.java b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/RecordOverwriting.java index 9fcbcb36fa..46ca0ddfa4 100644 --- a/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/RecordOverwriting.java +++ b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/RecordOverwriting.java @@ -1,25 +1,19 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class MyRecord extends Record { - + //@ axiom (\forall MyRecord a, b; a.test == b.test; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String test; - public final String test() { - return test; - } - - @Override() - public final boolean hashCode(java.lang.Object o) { - if (this == o) - return true; - if (!(o instanceof MyRecord that)) - return false; - return java.lang.Objects.equals(test, that.test); - return true; + @javax.annotation.processing.Generated("RecordClassBuilder") + public MyRecord(String test) { + //Created by RecordClassBuilder.java:105 + this.test = test; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "MyRecord[" + "test=" + test + "," + "]"; + return "MyRecord[" + "test=" + test + "]"; } public int hashCode() { @@ -54,11 +48,9 @@ public String test() { public static MyRecord $allocate(); - public MyRecord() { - } - - public void $init() { - super.$init(); + public void $init(String test) { super.$init(); + //Created by RecordClassBuilder.java:105 + this.test = test; } } diff --git a/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/SimpleRecord.java b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/SimpleRecord.java index 4b2bbd1fc1..6470dce239 100644 --- a/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/SimpleRecord.java +++ b/key.core/pipelineTests/records/expected/07_ConstructorNormalformBuilder/SimpleRecord.java @@ -1,30 +1,45 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") public final class SimpleRecord extends Record { - + //@ axiom (\forall SimpleRecord a, b; a.name == b.name; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final nullable String name; + @javax.annotation.processing.Generated("RecordClassBuilder") public final nullable String name() { return name; } + SimpleRecord(String name) { + this.name = name; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof SimpleRecord that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof SimpleRecord)) return false; + //Created by RecordClassBuilder.java:171 + final SimpleRecord that = (SimpleRecord) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(name, that.name); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(name); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "SimpleRecord[" + "name=" + name + "," + "]"; + return "SimpleRecord[" + "name=" + name + "]"; } SimpleRecord(String name) { @@ -55,4 +70,9 @@ public final non_null String toString() { super.$init(); this.name = name; } + + void $init(String name) { + super.$init(); + this.name = name; + } } diff --git a/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/CompactConstructor.java b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/CompactConstructor.java index 3e0c8022d1..7292651b02 100644 --- a/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/CompactConstructor.java +++ b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/CompactConstructor.java @@ -1,36 +1,62 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class Mapping extends Record { - + //@ axiom (\forall Mapping a, b; a.from == b.from&&a.to == b.to; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String from; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String from() { return from; } + @javax.annotation.processing.Generated("RecordClassBuilder") private final String to; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String to() { return to; } + @javax.annotation.processing.Generated("RecordClassBuilder") + public Mapping(String from, String to) { + { + // compact constructor! + from = "abc"; + to = "def"; + } + //Created by RecordClassBuilder.java:105 + this.from = from; + //Created by RecordClassBuilder.java:105 + this.to = to; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Mapping that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Mapping)) return false; + //Created by RecordClassBuilder.java:171 + final Mapping that = (Mapping) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(from, that.from) && java.lang.Objects.equals(to, that.to); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(from, to); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Mapping[" + "from=" + from + "," + "to=" + to + "," + "]"; + return "Mapping[" + "from=" + from + "," + "to=" + to + "]"; } Mapping { @@ -59,12 +85,17 @@ public final non_null String toString() { public static Mapping $allocate(); - public Mapping() { - } - - public void $init() { - super.$init(); + public void $init(String from, String to) { super.$init(); + { + // compact constructor! + from = "abc"; + to = "def"; + } + //Created by RecordClassBuilder.java:105 + this.from = from; + //Created by RecordClassBuilder.java:105 + this.to = to; } static private void $clprepare() { diff --git a/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/InnerRecord.java b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/InnerRecord.java index b821bcf9d0..65f9f021e4 100644 --- a/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/InnerRecord.java +++ b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/InnerRecord.java @@ -1,32 +1,51 @@ -class OuterClass { +import java.lang.Object; - @Generated() - final class MyRecord extends Record { +public class OuterClass { + @javax.annotation.processing.Generated("RecordClassBuilder") + final class MyRecord extends Record { + //@ axiom (\forall MyRecord a, b; a.test == b.test; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String test; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String test() { return test; } + @javax.annotation.processing.Generated("RecordClassBuilder") + public MyRecord(String test) { + //Created by RecordClassBuilder.java:105 + this.test = test; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof MyRecord that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof MyRecord)) return false; + //Created by RecordClassBuilder.java:171 + final MyRecord that = (MyRecord) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(test, that.test); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(test); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "MyRecord[" + "test=" + test + "," + "]"; + return "MyRecord[" + "test=" + test + "]"; } @javax.annotation.processing.Generated() @@ -51,13 +70,11 @@ public final non_null String toString() { public static MyRecord $allocate(); - public MyRecord() { - } - - public void $init(OuterClass $ENCLOSING_THIS) { + public void $init(String test, OuterClass $ENCLOSING_THIS) { super.$init(); this.$enclosingThis = $ENCLOSING_THIS; - super.$init(); + //Created by RecordClassBuilder.java:105 + this.test = test; } static private void $clprepare() { diff --git a/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/NotAllowed.java b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/NotAllowed.java index 29f81df084..07a13a6d5d 100644 --- a/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/NotAllowed.java +++ b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/NotAllowed.java @@ -1,32 +1,48 @@ //https://mikemybytes.com/2022/02/16/java-records-and-compact-constructors/ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class // package-private Name extends Record { - + //@ axiom (\forall Name a, b; a.name == b.name; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String name; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String name() { return name; } + // was package)' + private Name(String name) { + this.name = name; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Name that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Name)) return false; + //Created by RecordClassBuilder.java:171 + final Name that = (Name) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(name, that.name); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(name); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Name[" + "name=" + name + "," + "]"; + return "Name[" + "name=" + name + "]"; } // was package)' @@ -64,43 +80,67 @@ static Name of(String name) { this.name = name; } + private void $init(String name) { + super.$init(); + this.name = name; + } + static private void $clprepare() { } } -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class Point extends Record { - + //@ axiom (\forall Point a, b; a.x == b.x&&a.y == b.y; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final int x; + @javax.annotation.processing.Generated("RecordClassBuilder") public final int x() { return x; } + @javax.annotation.processing.Generated("RecordClassBuilder") private final int y; + @javax.annotation.processing.Generated("RecordClassBuilder") public final int y() { return y; } + Point(int x, int y) { + // boring! + this.x = x; + this.y = y; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Point that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Point)) return false; + //Created by RecordClassBuilder.java:171 + final Point that = (Point) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(x, that.x) && java.lang.Objects.equals(y, that.y); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(x, y); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Point[" + "x=" + x + "," + "y=" + y + "," + "]"; + return "Point[" + "x=" + x + "," + "y=" + y + "]"; } Point(int x, int y) { @@ -147,6 +187,13 @@ public final non_null String toString() { this.y = y; } + void $init(int x, int y) { + super.$init(); + // boring! + this.x = x; + this.y = y; + } + void $init(int x) { this.$init(x, 0); } diff --git a/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/RecordOverwriting.java b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/RecordOverwriting.java index 9008b4f75b..d682e66d50 100644 --- a/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/RecordOverwriting.java +++ b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/RecordOverwriting.java @@ -1,25 +1,19 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class MyRecord extends Record { - + //@ axiom (\forall MyRecord a, b; a.test == b.test; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String test; - public final String test() { - return test; - } - - @Override() - public final boolean hashCode(java.lang.Object o) { - if (this == o) - return true; - if (!(o instanceof MyRecord that)) - return false; - return java.lang.Objects.equals(test, that.test); - return true; + @javax.annotation.processing.Generated("RecordClassBuilder") + public MyRecord(String test) { + //Created by RecordClassBuilder.java:105 + this.test = test; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "MyRecord[" + "test=" + test + "," + "]"; + return "MyRecord[" + "test=" + test + "]"; } public int hashCode() { @@ -54,12 +48,10 @@ public String test() { public static MyRecord $allocate(); - public MyRecord() { - } - - public void $init() { - super.$init(); + public void $init(String test) { super.$init(); + //Created by RecordClassBuilder.java:105 + this.test = test; } static private void $clprepare() { diff --git a/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/SimpleRecord.java b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/SimpleRecord.java index 863d12c480..16178ff19d 100644 --- a/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/SimpleRecord.java +++ b/key.core/pipelineTests/records/expected/08_ClassPreparationMethodBuilder/SimpleRecord.java @@ -1,30 +1,45 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") public final class SimpleRecord extends Record { - + //@ axiom (\forall SimpleRecord a, b; a.name == b.name; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final nullable String name; + @javax.annotation.processing.Generated("RecordClassBuilder") public final nullable String name() { return name; } + SimpleRecord(String name) { + this.name = name; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof SimpleRecord that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof SimpleRecord)) return false; + //Created by RecordClassBuilder.java:171 + final SimpleRecord that = (SimpleRecord) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(name, that.name); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(name); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "SimpleRecord[" + "name=" + name + "," + "]"; + return "SimpleRecord[" + "name=" + name + "]"; } SimpleRecord(String name) { @@ -56,6 +71,11 @@ public final non_null String toString() { this.name = name; } + void $init(String name) { + super.$init(); + this.name = name; + } + static private void $clprepare() { } } diff --git a/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/CompactConstructor.java b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/CompactConstructor.java index 8ca805adbe..2446a12e46 100644 --- a/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/CompactConstructor.java +++ b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/CompactConstructor.java @@ -1,36 +1,62 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class Mapping extends Record { - + //@ axiom (\forall Mapping a, b; a.from == b.from&&a.to == b.to; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String from; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String from() { return from; } + @javax.annotation.processing.Generated("RecordClassBuilder") private final String to; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String to() { return to; } + @javax.annotation.processing.Generated("RecordClassBuilder") + public Mapping(String from, String to) { + { + // compact constructor! + from = "abc"; + to = "def"; + } + //Created by RecordClassBuilder.java:105 + this.from = from; + //Created by RecordClassBuilder.java:105 + this.to = to; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Mapping that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Mapping)) return false; + //Created by RecordClassBuilder.java:171 + final Mapping that = (Mapping) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(from, that.from) && java.lang.Objects.equals(to, that.to); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(from, to); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Mapping[" + "from=" + from + "," + "to=" + to + "," + "]"; + return "Mapping[" + "from=" + from + "," + "to=" + to + "]"; } Mapping { @@ -59,12 +85,17 @@ public final non_null String toString() { public static Mapping $allocate(); - public Mapping() { - } - - public void $init() { - super.$init(); + public void $init(String from, String to) { super.$init(); + { + // compact constructor! + from = "abc"; + to = "def"; + } + //Created by RecordClassBuilder.java:105 + this.from = from; + //Created by RecordClassBuilder.java:105 + this.to = to; } static private void $clprepare() { diff --git a/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/InnerRecord.java b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/InnerRecord.java index e10f4ab934..69d146e7b4 100644 --- a/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/InnerRecord.java +++ b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/InnerRecord.java @@ -1,32 +1,51 @@ -class OuterClass { +import java.lang.Object; - @Generated() - final class MyRecord extends Record { +public class OuterClass { + @javax.annotation.processing.Generated("RecordClassBuilder") + final class MyRecord extends Record { + //@ axiom (\forall MyRecord a, b; a.test == b.test; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String test; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String test() { return test; } + @javax.annotation.processing.Generated("RecordClassBuilder") + public MyRecord(String test) { + //Created by RecordClassBuilder.java:105 + this.test = test; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof MyRecord that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof MyRecord)) return false; + //Created by RecordClassBuilder.java:171 + final MyRecord that = (MyRecord) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(test, that.test); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(test); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "MyRecord[" + "test=" + test + "," + "]"; + return "MyRecord[" + "test=" + test + "]"; } @javax.annotation.processing.Generated() @@ -51,13 +70,11 @@ public final non_null String toString() { public static MyRecord $allocate(); - public MyRecord() { - } - - public void $init(OuterClass $ENCLOSING_THIS) { + public void $init(String test, OuterClass $ENCLOSING_THIS) { super.$init(); this.$enclosingThis = $ENCLOSING_THIS; - super.$init(); + //Created by RecordClassBuilder.java:105 + this.test = test; } static private void $clprepare() { diff --git a/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/NotAllowed.java b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/NotAllowed.java index 5dd9919b37..8ee5991749 100644 --- a/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/NotAllowed.java +++ b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/NotAllowed.java @@ -1,32 +1,48 @@ //https://mikemybytes.com/2022/02/16/java-records-and-compact-constructors/ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class // package-private Name extends Record { - + //@ axiom (\forall Name a, b; a.name == b.name; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String name; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String name() { return name; } + // was package)' + private Name(String name) { + this.name = name; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Name that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Name)) return false; + //Created by RecordClassBuilder.java:171 + final Name that = (Name) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(name, that.name); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(name); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Name[" + "name=" + name + "," + "]"; + return "Name[" + "name=" + name + "]"; } // was package)' @@ -64,6 +80,11 @@ static Name of(String name) { this.name = name; } + private void $init(String name) { + super.$init(); + this.name = name; + } + static private void $clprepare() { } @@ -106,39 +127,58 @@ static Name of(String name) { } } -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class Point extends Record { - + //@ axiom (\forall Point a, b; a.x == b.x&&a.y == b.y; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final int x; + @javax.annotation.processing.Generated("RecordClassBuilder") public final int x() { return x; } + @javax.annotation.processing.Generated("RecordClassBuilder") private final int y; + @javax.annotation.processing.Generated("RecordClassBuilder") public final int y() { return y; } + Point(int x, int y) { + // boring! + this.x = x; + this.y = y; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Point that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Point)) return false; + //Created by RecordClassBuilder.java:171 + final Point that = (Point) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(x, that.x) && java.lang.Objects.equals(y, that.y); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(x, y); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Point[" + "x=" + x + "," + "y=" + y + "," + "]"; + return "Point[" + "x=" + x + "," + "y=" + y + "]"; } Point(int x, int y) { @@ -185,6 +225,13 @@ public final non_null String toString() { this.y = y; } + void $init(int x, int y) { + super.$init(); + // boring! + this.x = x; + this.y = y; + } + void $init(int x) { this.$init(x, 0); } diff --git a/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/RecordOverwriting.java b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/RecordOverwriting.java index 15f8b673eb..2f0a4ce254 100644 --- a/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/RecordOverwriting.java +++ b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/RecordOverwriting.java @@ -1,25 +1,19 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class MyRecord extends Record { - + //@ axiom (\forall MyRecord a, b; a.test == b.test; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String test; - public final String test() { - return test; - } - - @Override() - public final boolean hashCode(java.lang.Object o) { - if (this == o) - return true; - if (!(o instanceof MyRecord that)) - return false; - return java.lang.Objects.equals(test, that.test); - return true; + @javax.annotation.processing.Generated("RecordClassBuilder") + public MyRecord(String test) { + //Created by RecordClassBuilder.java:105 + this.test = test; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "MyRecord[" + "test=" + test + "," + "]"; + return "MyRecord[" + "test=" + test + "]"; } public int hashCode() { @@ -54,12 +48,10 @@ public String test() { public static MyRecord $allocate(); - public MyRecord() { - } - - public void $init() { - super.$init(); + public void $init(String test) { super.$init(); + //Created by RecordClassBuilder.java:105 + this.test = test; } static private void $clprepare() { diff --git a/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/SimpleRecord.java b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/SimpleRecord.java index 9f448392b8..511ec33320 100644 --- a/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/SimpleRecord.java +++ b/key.core/pipelineTests/records/expected/09_ClassInitializeMethodBuilder/SimpleRecord.java @@ -1,30 +1,45 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") public final class SimpleRecord extends Record { - + //@ axiom (\forall SimpleRecord a, b; a.name == b.name; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final nullable String name; + @javax.annotation.processing.Generated("RecordClassBuilder") public final nullable String name() { return name; } + SimpleRecord(String name) { + this.name = name; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof SimpleRecord that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof SimpleRecord)) return false; + //Created by RecordClassBuilder.java:171 + final SimpleRecord that = (SimpleRecord) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(name, that.name); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(name); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "SimpleRecord[" + "name=" + name + "," + "]"; + return "SimpleRecord[" + "name=" + name + "]"; } SimpleRecord(String name) { @@ -56,6 +71,11 @@ public final non_null String toString() { this.name = name; } + void $init(String name) { + super.$init(); + this.name = name; + } + static private void $clprepare() { } diff --git a/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/CompactConstructor.java b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/CompactConstructor.java index 5c2d92d129..91cd17a4ff 100644 --- a/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/CompactConstructor.java +++ b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/CompactConstructor.java @@ -1,36 +1,62 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class Mapping extends Record { - + //@ axiom (\forall Mapping a, b; a.from == b.from&&a.to == b.to; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String from; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String from() { return from; } + @javax.annotation.processing.Generated("RecordClassBuilder") private final String to; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String to() { return to; } + @javax.annotation.processing.Generated("RecordClassBuilder") + public Mapping(String from, String to) { + { + // compact constructor! + from = "abc"; + to = "def"; + } + //Created by RecordClassBuilder.java:105 + this.from = from; + //Created by RecordClassBuilder.java:105 + this.to = to; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Mapping that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Mapping)) return false; + //Created by RecordClassBuilder.java:171 + final Mapping that = (Mapping) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(from, that.from) && java.lang.Objects.equals(to, that.to); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(from, to); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Mapping[" + "from=" + from + "," + "to=" + to + "," + "]"; + return "Mapping[" + "from=" + from + "," + "to=" + to + "]"; } Mapping { @@ -59,12 +85,17 @@ public final non_null String toString() { public static Mapping $allocate(); - public Mapping() { - } - - public void $init() { - super.$init(); + public void $init(String from, String to) { super.$init(); + { + // compact constructor! + from = "abc"; + to = "def"; + } + //Created by RecordClassBuilder.java:105 + this.from = from; + //Created by RecordClassBuilder.java:105 + this.to = to; } static private void $clprepare() { diff --git a/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/InnerRecord.java b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/InnerRecord.java index 807dc0d6d9..7d7cd77982 100644 --- a/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/InnerRecord.java +++ b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/InnerRecord.java @@ -1,32 +1,51 @@ -class OuterClass { +import java.lang.Object; - @Generated() - final class MyRecord extends Record { +public class OuterClass { + @javax.annotation.processing.Generated("RecordClassBuilder") + final class MyRecord extends Record { + //@ axiom (\forall MyRecord a, b; a.test == b.test; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String test; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String test() { return test; } + @javax.annotation.processing.Generated("RecordClassBuilder") + public MyRecord(String test) { + //Created by RecordClassBuilder.java:105 + this.test = test; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof MyRecord that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof MyRecord)) return false; + //Created by RecordClassBuilder.java:171 + final MyRecord that = (MyRecord) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(test, that.test); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(test); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "MyRecord[" + "test=" + test + "," + "]"; + return "MyRecord[" + "test=" + test + "]"; } @javax.annotation.processing.Generated() @@ -51,13 +70,11 @@ public final non_null String toString() { public static MyRecord $allocate(); - public MyRecord() { - } - - public void $init(OuterClass $ENCLOSING_THIS) { + public void $init(String test, OuterClass $ENCLOSING_THIS) { super.$init(); this.$enclosingThis = $ENCLOSING_THIS; - super.$init(); + //Created by RecordClassBuilder.java:105 + this.test = test; } static private void $clprepare() { diff --git a/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/NotAllowed.java b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/NotAllowed.java index e66b7b31da..58c4bca34a 100644 --- a/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/NotAllowed.java +++ b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/NotAllowed.java @@ -1,32 +1,48 @@ //https://mikemybytes.com/2022/02/16/java-records-and-compact-constructors/ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class // package-private Name extends Record { - + //@ axiom (\forall Name a, b; a.name == b.name; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String name; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String name() { return name; } + // was package)' + private Name(String name) { + this.name = name; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Name that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Name)) return false; + //Created by RecordClassBuilder.java:171 + final Name that = (Name) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(name, that.name); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(name); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Name[" + "name=" + name + "," + "]"; + return "Name[" + "name=" + name + "]"; } // was package)' @@ -64,6 +80,11 @@ static Name of(String name) { this.name = name; } + private void $init(String name) { + super.$init(); + this.name = name; + } + static private void $clprepare() { } @@ -118,39 +139,58 @@ static Name of(String name) { } } -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class Point extends Record { - + //@ axiom (\forall Point a, b; a.x == b.x&&a.y == b.y; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final int x; + @javax.annotation.processing.Generated("RecordClassBuilder") public final int x() { return x; } + @javax.annotation.processing.Generated("RecordClassBuilder") private final int y; + @javax.annotation.processing.Generated("RecordClassBuilder") public final int y() { return y; } + Point(int x, int y) { + // boring! + this.x = x; + this.y = y; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Point that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Point)) return false; + //Created by RecordClassBuilder.java:171 + final Point that = (Point) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(x, that.x) && java.lang.Objects.equals(y, that.y); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(x, y); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Point[" + "x=" + x + "," + "y=" + y + "," + "]"; + return "Point[" + "x=" + x + "," + "y=" + y + "]"; } Point(int x, int y) { @@ -197,6 +237,13 @@ public final non_null String toString() { this.y = y; } + void $init(int x, int y) { + super.$init(); + // boring! + this.x = x; + this.y = y; + } + void $init(int x) { this.$init(x, 0); } diff --git a/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/RecordOverwriting.java b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/RecordOverwriting.java index d6b609956e..531758bf19 100644 --- a/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/RecordOverwriting.java +++ b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/RecordOverwriting.java @@ -1,25 +1,19 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class MyRecord extends Record { - + //@ axiom (\forall MyRecord a, b; a.test == b.test; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String test; - public final String test() { - return test; - } - - @Override() - public final boolean hashCode(java.lang.Object o) { - if (this == o) - return true; - if (!(o instanceof MyRecord that)) - return false; - return java.lang.Objects.equals(test, that.test); - return true; + @javax.annotation.processing.Generated("RecordClassBuilder") + public MyRecord(String test) { + //Created by RecordClassBuilder.java:105 + this.test = test; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "MyRecord[" + "test=" + test + "," + "]"; + return "MyRecord[" + "test=" + test + "]"; } public int hashCode() { @@ -54,12 +48,10 @@ public String test() { public static MyRecord $allocate(); - public MyRecord() { - } - - public void $init() { - super.$init(); + public void $init(String test) { super.$init(); + //Created by RecordClassBuilder.java:105 + this.test = test; } static private void $clprepare() { diff --git a/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/SimpleRecord.java b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/SimpleRecord.java index 6fb7731427..8bbe0715f5 100644 --- a/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/SimpleRecord.java +++ b/key.core/pipelineTests/records/expected/10_PrepareObjectBuilder/SimpleRecord.java @@ -1,30 +1,45 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") public final class SimpleRecord extends Record { - + //@ axiom (\forall SimpleRecord a, b; a.name == b.name; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final nullable String name; + @javax.annotation.processing.Generated("RecordClassBuilder") public final nullable String name() { return name; } + SimpleRecord(String name) { + this.name = name; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof SimpleRecord that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof SimpleRecord)) return false; + //Created by RecordClassBuilder.java:171 + final SimpleRecord that = (SimpleRecord) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(name, that.name); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(name); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "SimpleRecord[" + "name=" + name + "," + "]"; + return "SimpleRecord[" + "name=" + name + "]"; } SimpleRecord(String name) { @@ -56,6 +71,11 @@ public final non_null String toString() { this.name = name; } + void $init(String name) { + super.$init(); + this.name = name; + } + static private void $clprepare() { } diff --git a/key.core/pipelineTests/records/expected/11_CreateBuilder/CompactConstructor.java b/key.core/pipelineTests/records/expected/11_CreateBuilder/CompactConstructor.java index 7665b6e1de..1040f61b3e 100644 --- a/key.core/pipelineTests/records/expected/11_CreateBuilder/CompactConstructor.java +++ b/key.core/pipelineTests/records/expected/11_CreateBuilder/CompactConstructor.java @@ -1,36 +1,62 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class Mapping extends Record { - + //@ axiom (\forall Mapping a, b; a.from == b.from&&a.to == b.to; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String from; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String from() { return from; } + @javax.annotation.processing.Generated("RecordClassBuilder") private final String to; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String to() { return to; } + @javax.annotation.processing.Generated("RecordClassBuilder") + public Mapping(String from, String to) { + { + // compact constructor! + from = "abc"; + to = "def"; + } + //Created by RecordClassBuilder.java:105 + this.from = from; + //Created by RecordClassBuilder.java:105 + this.to = to; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Mapping that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Mapping)) return false; + //Created by RecordClassBuilder.java:171 + final Mapping that = (Mapping) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(from, that.from) && java.lang.Objects.equals(to, that.to); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(from, to); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Mapping[" + "from=" + from + "," + "to=" + to + "," + "]"; + return "Mapping[" + "from=" + from + "," + "to=" + to + "]"; } Mapping { @@ -59,12 +85,17 @@ public final non_null String toString() { public static Mapping $allocate(); - public Mapping() { - } - - public void $init() { - super.$init(); + public void $init(String from, String to) { super.$init(); + { + // compact constructor! + from = "abc"; + to = "def"; + } + //Created by RecordClassBuilder.java:105 + this.from = from; + //Created by RecordClassBuilder.java:105 + this.to = to; } static private void $clprepare() { diff --git a/key.core/pipelineTests/records/expected/11_CreateBuilder/InnerRecord.java b/key.core/pipelineTests/records/expected/11_CreateBuilder/InnerRecord.java index 5fa698ccdf..bc83fd17d7 100644 --- a/key.core/pipelineTests/records/expected/11_CreateBuilder/InnerRecord.java +++ b/key.core/pipelineTests/records/expected/11_CreateBuilder/InnerRecord.java @@ -1,32 +1,51 @@ -class OuterClass { +import java.lang.Object; - @Generated() - final class MyRecord extends Record { +public class OuterClass { + @javax.annotation.processing.Generated("RecordClassBuilder") + final class MyRecord extends Record { + //@ axiom (\forall MyRecord a, b; a.test == b.test; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String test; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String test() { return test; } + @javax.annotation.processing.Generated("RecordClassBuilder") + public MyRecord(String test) { + //Created by RecordClassBuilder.java:105 + this.test = test; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof MyRecord that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof MyRecord)) return false; + //Created by RecordClassBuilder.java:171 + final MyRecord that = (MyRecord) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(test, that.test); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(test); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "MyRecord[" + "test=" + test + "," + "]"; + return "MyRecord[" + "test=" + test + "]"; } @javax.annotation.processing.Generated() @@ -51,13 +70,11 @@ public final non_null String toString() { public static MyRecord $allocate(); - public MyRecord() { - } - - public void $init(OuterClass $ENCLOSING_THIS) { + public void $init(String test, OuterClass $ENCLOSING_THIS) { super.$init(); this.$enclosingThis = $ENCLOSING_THIS; - super.$init(); + //Created by RecordClassBuilder.java:105 + this.test = test; } static private void $clprepare() { diff --git a/key.core/pipelineTests/records/expected/11_CreateBuilder/NotAllowed.java b/key.core/pipelineTests/records/expected/11_CreateBuilder/NotAllowed.java index a2e12e31e9..9739ecd772 100644 --- a/key.core/pipelineTests/records/expected/11_CreateBuilder/NotAllowed.java +++ b/key.core/pipelineTests/records/expected/11_CreateBuilder/NotAllowed.java @@ -1,32 +1,48 @@ //https://mikemybytes.com/2022/02/16/java-records-and-compact-constructors/ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class // package-private Name extends Record { - + //@ axiom (\forall Name a, b; a.name == b.name; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String name; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String name() { return name; } + // was package)' + private Name(String name) { + this.name = name; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Name that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Name)) return false; + //Created by RecordClassBuilder.java:171 + final Name that = (Name) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(name, that.name); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(name); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Name[" + "name=" + name + "," + "]"; + return "Name[" + "name=" + name + "]"; } // was package)' @@ -64,6 +80,11 @@ static Name of(String name) { this.name = name; } + private void $init(String name) { + super.$init(); + this.name = name; + } + static private void $clprepare() { } @@ -125,39 +146,58 @@ static Name of(String name) { } } -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class Point extends Record { - + //@ axiom (\forall Point a, b; a.x == b.x&&a.y == b.y; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final int x; + @javax.annotation.processing.Generated("RecordClassBuilder") public final int x() { return x; } + @javax.annotation.processing.Generated("RecordClassBuilder") private final int y; + @javax.annotation.processing.Generated("RecordClassBuilder") public final int y() { return y; } + Point(int x, int y) { + // boring! + this.x = x; + this.y = y; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Point that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Point)) return false; + //Created by RecordClassBuilder.java:171 + final Point that = (Point) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(x, that.x) && java.lang.Objects.equals(y, that.y); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(x, y); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Point[" + "x=" + x + "," + "y=" + y + "," + "]"; + return "Point[" + "x=" + x + "," + "y=" + y + "]"; } Point(int x, int y) { @@ -204,6 +244,13 @@ public final non_null String toString() { this.y = y; } + void $init(int x, int y) { + super.$init(); + // boring! + this.x = x; + this.y = y; + } + void $init(int x) { this.$init(x, 0); } diff --git a/key.core/pipelineTests/records/expected/11_CreateBuilder/RecordOverwriting.java b/key.core/pipelineTests/records/expected/11_CreateBuilder/RecordOverwriting.java index bded70534d..a4e9cd5bd4 100644 --- a/key.core/pipelineTests/records/expected/11_CreateBuilder/RecordOverwriting.java +++ b/key.core/pipelineTests/records/expected/11_CreateBuilder/RecordOverwriting.java @@ -1,25 +1,19 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class MyRecord extends Record { - + //@ axiom (\forall MyRecord a, b; a.test == b.test; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String test; - public final String test() { - return test; - } - - @Override() - public final boolean hashCode(java.lang.Object o) { - if (this == o) - return true; - if (!(o instanceof MyRecord that)) - return false; - return java.lang.Objects.equals(test, that.test); - return true; + @javax.annotation.processing.Generated("RecordClassBuilder") + public MyRecord(String test) { + //Created by RecordClassBuilder.java:105 + this.test = test; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "MyRecord[" + "test=" + test + "," + "]"; + return "MyRecord[" + "test=" + test + "]"; } public int hashCode() { @@ -54,12 +48,10 @@ public String test() { public static MyRecord $allocate(); - public MyRecord() { - } - - public void $init() { - super.$init(); + public void $init(String test) { super.$init(); + //Created by RecordClassBuilder.java:105 + this.test = test; } static private void $clprepare() { diff --git a/key.core/pipelineTests/records/expected/11_CreateBuilder/SimpleRecord.java b/key.core/pipelineTests/records/expected/11_CreateBuilder/SimpleRecord.java index 0281748ffd..cc1f098c03 100644 --- a/key.core/pipelineTests/records/expected/11_CreateBuilder/SimpleRecord.java +++ b/key.core/pipelineTests/records/expected/11_CreateBuilder/SimpleRecord.java @@ -1,30 +1,45 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") public final class SimpleRecord extends Record { - + //@ axiom (\forall SimpleRecord a, b; a.name == b.name; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final nullable String name; + @javax.annotation.processing.Generated("RecordClassBuilder") public final nullable String name() { return name; } + SimpleRecord(String name) { + this.name = name; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof SimpleRecord that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof SimpleRecord)) return false; + //Created by RecordClassBuilder.java:171 + final SimpleRecord that = (SimpleRecord) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(name, that.name); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(name); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "SimpleRecord[" + "name=" + name + "," + "]"; + return "SimpleRecord[" + "name=" + name + "]"; } SimpleRecord(String name) { @@ -56,6 +71,11 @@ public final non_null String toString() { this.name = name; } + void $init(String name) { + super.$init(); + this.name = name; + } + static private void $clprepare() { } diff --git a/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/CompactConstructor.java b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/CompactConstructor.java index 82a4202981..c55b34b780 100644 --- a/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/CompactConstructor.java +++ b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/CompactConstructor.java @@ -1,36 +1,62 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class Mapping extends Record { - + //@ axiom (\forall Mapping a, b; a.from == b.from&&a.to == b.to; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String from; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String from() { return from; } + @javax.annotation.processing.Generated("RecordClassBuilder") private final String to; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String to() { return to; } + @javax.annotation.processing.Generated("RecordClassBuilder") + public Mapping(String from, String to) { + { + // compact constructor! + from = "abc"; + to = "def"; + } + //Created by RecordClassBuilder.java:105 + this.from = from; + //Created by RecordClassBuilder.java:105 + this.to = to; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Mapping that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Mapping)) return false; + //Created by RecordClassBuilder.java:171 + final Mapping that = (Mapping) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(from, that.from) && java.lang.Objects.equals(to, that.to); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(from, to); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Mapping[" + "from=" + from + "," + "to=" + to + "," + "]"; + return "Mapping[" + "from=" + from + "," + "to=" + to + "]"; } Mapping { @@ -59,12 +85,17 @@ public final non_null String toString() { public static Mapping $allocate(); - public Mapping() { - } - - public void $init() { - super.$init(); + public void $init(String from, String to) { super.$init(); + { + // compact constructor! + from = "abc"; + to = "def"; + } + //Created by RecordClassBuilder.java:105 + this.from = from; + //Created by RecordClassBuilder.java:105 + this.to = to; } static private void $clprepare() { diff --git a/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/InnerRecord.java b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/InnerRecord.java index d02a4effc8..c225b125cf 100644 --- a/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/InnerRecord.java +++ b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/InnerRecord.java @@ -1,32 +1,51 @@ -class OuterClass { +import java.lang.Object; - @Generated() - final class MyRecord extends Record { +public class OuterClass { + @javax.annotation.processing.Generated("RecordClassBuilder") + final class MyRecord extends Record { + //@ axiom (\forall MyRecord a, b; a.test == b.test; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String test; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String test() { return test; } + @javax.annotation.processing.Generated("RecordClassBuilder") + public MyRecord(String test) { + //Created by RecordClassBuilder.java:105 + this.test = test; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof MyRecord that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof MyRecord)) return false; + //Created by RecordClassBuilder.java:171 + final MyRecord that = (MyRecord) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(test, that.test); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(test); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "MyRecord[" + "test=" + test + "," + "]"; + return "MyRecord[" + "test=" + test + "]"; } @javax.annotation.processing.Generated() @@ -51,13 +70,11 @@ public final non_null String toString() { public static MyRecord $allocate(); - public MyRecord() { - } - - public void $init(OuterClass $ENCLOSING_THIS) { + public void $init(String test, OuterClass $ENCLOSING_THIS) { super.$init(); this.$enclosingThis = $ENCLOSING_THIS; - super.$init(); + //Created by RecordClassBuilder.java:105 + this.test = test; } static private void $clprepare() { diff --git a/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/NotAllowed.java b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/NotAllowed.java index 83c289fae4..c7e7b9146f 100644 --- a/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/NotAllowed.java +++ b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/NotAllowed.java @@ -1,32 +1,48 @@ //https://mikemybytes.com/2022/02/16/java-records-and-compact-constructors/ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class // package-private Name extends Record { - + //@ axiom (\forall Name a, b; a.name == b.name; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String name; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String name() { return name; } + // was package)' + private Name(String name) { + this.name = name; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Name that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Name)) return false; + //Created by RecordClassBuilder.java:171 + final Name that = (Name) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(name, that.name); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(name); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Name[" + "name=" + name + "," + "]"; + return "Name[" + "name=" + name + "]"; } // was package)' @@ -64,6 +80,11 @@ static Name of(String name) { this.name = name; } + private void $init(String name) { + super.$init(); + this.name = name; + } + static private void $clprepare() { } @@ -137,39 +158,58 @@ static Name of(String name) { } } -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class Point extends Record { - + //@ axiom (\forall Point a, b; a.x == b.x&&a.y == b.y; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final int x; + @javax.annotation.processing.Generated("RecordClassBuilder") public final int x() { return x; } + @javax.annotation.processing.Generated("RecordClassBuilder") private final int y; + @javax.annotation.processing.Generated("RecordClassBuilder") public final int y() { return y; } + Point(int x, int y) { + // boring! + this.x = x; + this.y = y; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Point that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Point)) return false; + //Created by RecordClassBuilder.java:171 + final Point that = (Point) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(x, that.x) && java.lang.Objects.equals(y, that.y); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(x, y); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Point[" + "x=" + x + "," + "y=" + y + "," + "]"; + return "Point[" + "x=" + x + "," + "y=" + y + "]"; } Point(int x, int y) { @@ -216,6 +256,13 @@ public final non_null String toString() { this.y = y; } + void $init(int x, int y) { + super.$init(); + // boring! + this.x = x; + this.y = y; + } + void $init(int x) { this.$init(x, 0); } diff --git a/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/RecordOverwriting.java b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/RecordOverwriting.java index d64c5174b2..b7074319f4 100644 --- a/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/RecordOverwriting.java +++ b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/RecordOverwriting.java @@ -1,25 +1,19 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class MyRecord extends Record { - + //@ axiom (\forall MyRecord a, b; a.test == b.test; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String test; - public final String test() { - return test; - } - - @Override() - public final boolean hashCode(java.lang.Object o) { - if (this == o) - return true; - if (!(o instanceof MyRecord that)) - return false; - return java.lang.Objects.equals(test, that.test); - return true; + @javax.annotation.processing.Generated("RecordClassBuilder") + public MyRecord(String test) { + //Created by RecordClassBuilder.java:105 + this.test = test; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "MyRecord[" + "test=" + test + "," + "]"; + return "MyRecord[" + "test=" + test + "]"; } public int hashCode() { @@ -54,12 +48,10 @@ public String test() { public static MyRecord $allocate(); - public MyRecord() { - } - - public void $init() { - super.$init(); + public void $init(String test) { super.$init(); + //Created by RecordClassBuilder.java:105 + this.test = test; } static private void $clprepare() { diff --git a/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/SimpleRecord.java b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/SimpleRecord.java index b0a09f520b..3898a43666 100644 --- a/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/SimpleRecord.java +++ b/key.core/pipelineTests/records/expected/12_CreateObjectBuilder/SimpleRecord.java @@ -1,30 +1,45 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") public final class SimpleRecord extends Record { - + //@ axiom (\forall SimpleRecord a, b; a.name == b.name; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final nullable String name; + @javax.annotation.processing.Generated("RecordClassBuilder") public final nullable String name() { return name; } + SimpleRecord(String name) { + this.name = name; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof SimpleRecord that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof SimpleRecord)) return false; + //Created by RecordClassBuilder.java:171 + final SimpleRecord that = (SimpleRecord) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(name, that.name); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(name); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "SimpleRecord[" + "name=" + name + "," + "]"; + return "SimpleRecord[" + "name=" + name + "]"; } SimpleRecord(String name) { @@ -56,6 +71,11 @@ public final non_null String toString() { this.name = name; } + void $init(String name) { + super.$init(); + this.name = name; + } + static private void $clprepare() { } diff --git a/key.core/pipelineTests/records/expected/13_LocalClassTransformation/CompactConstructor.java b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/CompactConstructor.java index 82a4202981..c55b34b780 100644 --- a/key.core/pipelineTests/records/expected/13_LocalClassTransformation/CompactConstructor.java +++ b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/CompactConstructor.java @@ -1,36 +1,62 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class Mapping extends Record { - + //@ axiom (\forall Mapping a, b; a.from == b.from&&a.to == b.to; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String from; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String from() { return from; } + @javax.annotation.processing.Generated("RecordClassBuilder") private final String to; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String to() { return to; } + @javax.annotation.processing.Generated("RecordClassBuilder") + public Mapping(String from, String to) { + { + // compact constructor! + from = "abc"; + to = "def"; + } + //Created by RecordClassBuilder.java:105 + this.from = from; + //Created by RecordClassBuilder.java:105 + this.to = to; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Mapping that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Mapping)) return false; + //Created by RecordClassBuilder.java:171 + final Mapping that = (Mapping) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(from, that.from) && java.lang.Objects.equals(to, that.to); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(from, to); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Mapping[" + "from=" + from + "," + "to=" + to + "," + "]"; + return "Mapping[" + "from=" + from + "," + "to=" + to + "]"; } Mapping { @@ -59,12 +85,17 @@ public final non_null String toString() { public static Mapping $allocate(); - public Mapping() { - } - - public void $init() { - super.$init(); + public void $init(String from, String to) { super.$init(); + { + // compact constructor! + from = "abc"; + to = "def"; + } + //Created by RecordClassBuilder.java:105 + this.from = from; + //Created by RecordClassBuilder.java:105 + this.to = to; } static private void $clprepare() { diff --git a/key.core/pipelineTests/records/expected/13_LocalClassTransformation/InnerRecord.java b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/InnerRecord.java index d02a4effc8..c225b125cf 100644 --- a/key.core/pipelineTests/records/expected/13_LocalClassTransformation/InnerRecord.java +++ b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/InnerRecord.java @@ -1,32 +1,51 @@ -class OuterClass { +import java.lang.Object; - @Generated() - final class MyRecord extends Record { +public class OuterClass { + @javax.annotation.processing.Generated("RecordClassBuilder") + final class MyRecord extends Record { + //@ axiom (\forall MyRecord a, b; a.test == b.test; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String test; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String test() { return test; } + @javax.annotation.processing.Generated("RecordClassBuilder") + public MyRecord(String test) { + //Created by RecordClassBuilder.java:105 + this.test = test; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof MyRecord that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof MyRecord)) return false; + //Created by RecordClassBuilder.java:171 + final MyRecord that = (MyRecord) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(test, that.test); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(test); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "MyRecord[" + "test=" + test + "," + "]"; + return "MyRecord[" + "test=" + test + "]"; } @javax.annotation.processing.Generated() @@ -51,13 +70,11 @@ public final non_null String toString() { public static MyRecord $allocate(); - public MyRecord() { - } - - public void $init(OuterClass $ENCLOSING_THIS) { + public void $init(String test, OuterClass $ENCLOSING_THIS) { super.$init(); this.$enclosingThis = $ENCLOSING_THIS; - super.$init(); + //Created by RecordClassBuilder.java:105 + this.test = test; } static private void $clprepare() { diff --git a/key.core/pipelineTests/records/expected/13_LocalClassTransformation/NotAllowed.java b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/NotAllowed.java index 83c289fae4..c7e7b9146f 100644 --- a/key.core/pipelineTests/records/expected/13_LocalClassTransformation/NotAllowed.java +++ b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/NotAllowed.java @@ -1,32 +1,48 @@ //https://mikemybytes.com/2022/02/16/java-records-and-compact-constructors/ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class // package-private Name extends Record { - + //@ axiom (\forall Name a, b; a.name == b.name; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String name; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String name() { return name; } + // was package)' + private Name(String name) { + this.name = name; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Name that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Name)) return false; + //Created by RecordClassBuilder.java:171 + final Name that = (Name) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(name, that.name); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(name); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Name[" + "name=" + name + "," + "]"; + return "Name[" + "name=" + name + "]"; } // was package)' @@ -64,6 +80,11 @@ static Name of(String name) { this.name = name; } + private void $init(String name) { + super.$init(); + this.name = name; + } + static private void $clprepare() { } @@ -137,39 +158,58 @@ static Name of(String name) { } } -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class Point extends Record { - + //@ axiom (\forall Point a, b; a.x == b.x&&a.y == b.y; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final int x; + @javax.annotation.processing.Generated("RecordClassBuilder") public final int x() { return x; } + @javax.annotation.processing.Generated("RecordClassBuilder") private final int y; + @javax.annotation.processing.Generated("RecordClassBuilder") public final int y() { return y; } + Point(int x, int y) { + // boring! + this.x = x; + this.y = y; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Point that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Point)) return false; + //Created by RecordClassBuilder.java:171 + final Point that = (Point) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(x, that.x) && java.lang.Objects.equals(y, that.y); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(x, y); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Point[" + "x=" + x + "," + "y=" + y + "," + "]"; + return "Point[" + "x=" + x + "," + "y=" + y + "]"; } Point(int x, int y) { @@ -216,6 +256,13 @@ public final non_null String toString() { this.y = y; } + void $init(int x, int y) { + super.$init(); + // boring! + this.x = x; + this.y = y; + } + void $init(int x) { this.$init(x, 0); } diff --git a/key.core/pipelineTests/records/expected/13_LocalClassTransformation/RecordOverwriting.java b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/RecordOverwriting.java index d64c5174b2..b7074319f4 100644 --- a/key.core/pipelineTests/records/expected/13_LocalClassTransformation/RecordOverwriting.java +++ b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/RecordOverwriting.java @@ -1,25 +1,19 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class MyRecord extends Record { - + //@ axiom (\forall MyRecord a, b; a.test == b.test; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String test; - public final String test() { - return test; - } - - @Override() - public final boolean hashCode(java.lang.Object o) { - if (this == o) - return true; - if (!(o instanceof MyRecord that)) - return false; - return java.lang.Objects.equals(test, that.test); - return true; + @javax.annotation.processing.Generated("RecordClassBuilder") + public MyRecord(String test) { + //Created by RecordClassBuilder.java:105 + this.test = test; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "MyRecord[" + "test=" + test + "," + "]"; + return "MyRecord[" + "test=" + test + "]"; } public int hashCode() { @@ -54,12 +48,10 @@ public String test() { public static MyRecord $allocate(); - public MyRecord() { - } - - public void $init() { - super.$init(); + public void $init(String test) { super.$init(); + //Created by RecordClassBuilder.java:105 + this.test = test; } static private void $clprepare() { diff --git a/key.core/pipelineTests/records/expected/13_LocalClassTransformation/SimpleRecord.java b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/SimpleRecord.java index b0a09f520b..3898a43666 100644 --- a/key.core/pipelineTests/records/expected/13_LocalClassTransformation/SimpleRecord.java +++ b/key.core/pipelineTests/records/expected/13_LocalClassTransformation/SimpleRecord.java @@ -1,30 +1,45 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") public final class SimpleRecord extends Record { - + //@ axiom (\forall SimpleRecord a, b; a.name == b.name; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final nullable String name; + @javax.annotation.processing.Generated("RecordClassBuilder") public final nullable String name() { return name; } + SimpleRecord(String name) { + this.name = name; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof SimpleRecord that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof SimpleRecord)) return false; + //Created by RecordClassBuilder.java:171 + final SimpleRecord that = (SimpleRecord) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(name, that.name); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(name); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "SimpleRecord[" + "name=" + name + "," + "]"; + return "SimpleRecord[" + "name=" + name + "]"; } SimpleRecord(String name) { @@ -56,6 +71,11 @@ public final non_null String toString() { this.name = name; } + void $init(String name) { + super.$init(); + this.name = name; + } + static private void $clprepare() { } diff --git a/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/CompactConstructor.java b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/CompactConstructor.java index 82a4202981..c55b34b780 100644 --- a/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/CompactConstructor.java +++ b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/CompactConstructor.java @@ -1,36 +1,62 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class Mapping extends Record { - + //@ axiom (\forall Mapping a, b; a.from == b.from&&a.to == b.to; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String from; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String from() { return from; } + @javax.annotation.processing.Generated("RecordClassBuilder") private final String to; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String to() { return to; } + @javax.annotation.processing.Generated("RecordClassBuilder") + public Mapping(String from, String to) { + { + // compact constructor! + from = "abc"; + to = "def"; + } + //Created by RecordClassBuilder.java:105 + this.from = from; + //Created by RecordClassBuilder.java:105 + this.to = to; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Mapping that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Mapping)) return false; + //Created by RecordClassBuilder.java:171 + final Mapping that = (Mapping) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(from, that.from) && java.lang.Objects.equals(to, that.to); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(from, to); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Mapping[" + "from=" + from + "," + "to=" + to + "," + "]"; + return "Mapping[" + "from=" + from + "," + "to=" + to + "]"; } Mapping { @@ -59,12 +85,17 @@ public final non_null String toString() { public static Mapping $allocate(); - public Mapping() { - } - - public void $init() { - super.$init(); + public void $init(String from, String to) { super.$init(); + { + // compact constructor! + from = "abc"; + to = "def"; + } + //Created by RecordClassBuilder.java:105 + this.from = from; + //Created by RecordClassBuilder.java:105 + this.to = to; } static private void $clprepare() { diff --git a/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/InnerRecord.java b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/InnerRecord.java index d02a4effc8..c225b125cf 100644 --- a/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/InnerRecord.java +++ b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/InnerRecord.java @@ -1,32 +1,51 @@ -class OuterClass { +import java.lang.Object; - @Generated() - final class MyRecord extends Record { +public class OuterClass { + @javax.annotation.processing.Generated("RecordClassBuilder") + final class MyRecord extends Record { + //@ axiom (\forall MyRecord a, b; a.test == b.test; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String test; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String test() { return test; } + @javax.annotation.processing.Generated("RecordClassBuilder") + public MyRecord(String test) { + //Created by RecordClassBuilder.java:105 + this.test = test; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof MyRecord that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof MyRecord)) return false; + //Created by RecordClassBuilder.java:171 + final MyRecord that = (MyRecord) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(test, that.test); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(test); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "MyRecord[" + "test=" + test + "," + "]"; + return "MyRecord[" + "test=" + test + "]"; } @javax.annotation.processing.Generated() @@ -51,13 +70,11 @@ public final non_null String toString() { public static MyRecord $allocate(); - public MyRecord() { - } - - public void $init(OuterClass $ENCLOSING_THIS) { + public void $init(String test, OuterClass $ENCLOSING_THIS) { super.$init(); this.$enclosingThis = $ENCLOSING_THIS; - super.$init(); + //Created by RecordClassBuilder.java:105 + this.test = test; } static private void $clprepare() { diff --git a/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/NotAllowed.java b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/NotAllowed.java index 83c289fae4..c7e7b9146f 100644 --- a/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/NotAllowed.java +++ b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/NotAllowed.java @@ -1,32 +1,48 @@ //https://mikemybytes.com/2022/02/16/java-records-and-compact-constructors/ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class // package-private Name extends Record { - + //@ axiom (\forall Name a, b; a.name == b.name; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String name; + @javax.annotation.processing.Generated("RecordClassBuilder") public final String name() { return name; } + // was package)' + private Name(String name) { + this.name = name; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Name that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Name)) return false; + //Created by RecordClassBuilder.java:171 + final Name that = (Name) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(name, that.name); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(name); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Name[" + "name=" + name + "," + "]"; + return "Name[" + "name=" + name + "]"; } // was package)' @@ -64,6 +80,11 @@ static Name of(String name) { this.name = name; } + private void $init(String name) { + super.$init(); + this.name = name; + } + static private void $clprepare() { } @@ -137,39 +158,58 @@ static Name of(String name) { } } -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class Point extends Record { - + //@ axiom (\forall Point a, b; a.x == b.x&&a.y == b.y; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final int x; + @javax.annotation.processing.Generated("RecordClassBuilder") public final int x() { return x; } + @javax.annotation.processing.Generated("RecordClassBuilder") private final int y; + @javax.annotation.processing.Generated("RecordClassBuilder") public final int y() { return y; } + Point(int x, int y) { + // boring! + this.x = x; + this.y = y; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof Point that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof Point)) return false; + //Created by RecordClassBuilder.java:171 + final Point that = (Point) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(x, that.x) && java.lang.Objects.equals(y, that.y); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(x, y); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "Point[" + "x=" + x + "," + "y=" + y + "," + "]"; + return "Point[" + "x=" + x + "," + "y=" + y + "]"; } Point(int x, int y) { @@ -216,6 +256,13 @@ public final non_null String toString() { this.y = y; } + void $init(int x, int y) { + super.$init(); + // boring! + this.x = x; + this.y = y; + } + void $init(int x) { this.$init(x, 0); } diff --git a/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/RecordOverwriting.java b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/RecordOverwriting.java index d64c5174b2..b7074319f4 100644 --- a/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/RecordOverwriting.java +++ b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/RecordOverwriting.java @@ -1,25 +1,19 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") final class MyRecord extends Record { - + //@ axiom (\forall MyRecord a, b; a.test == b.test; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final String test; - public final String test() { - return test; - } - - @Override() - public final boolean hashCode(java.lang.Object o) { - if (this == o) - return true; - if (!(o instanceof MyRecord that)) - return false; - return java.lang.Objects.equals(test, that.test); - return true; + @javax.annotation.processing.Generated("RecordClassBuilder") + public MyRecord(String test) { + //Created by RecordClassBuilder.java:105 + this.test = test; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "MyRecord[" + "test=" + test + "," + "]"; + return "MyRecord[" + "test=" + test + "]"; } public int hashCode() { @@ -54,12 +48,10 @@ public String test() { public static MyRecord $allocate(); - public MyRecord() { - } - - public void $init() { - super.$init(); + public void $init(String test) { super.$init(); + //Created by RecordClassBuilder.java:105 + this.test = test; } static private void $clprepare() { diff --git a/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/SimpleRecord.java b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/SimpleRecord.java index b0a09f520b..3898a43666 100644 --- a/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/SimpleRecord.java +++ b/key.core/pipelineTests/records/expected/14_ConstantStringExpressionEvaluator/SimpleRecord.java @@ -1,30 +1,45 @@ -@Generated() +@javax.annotation.processing.Generated("RecordClassBuilder") public final class SimpleRecord extends Record { - + //@ axiom (\forall SimpleRecord a, b; a.name == b.name; a.equals(b, )); + @javax.annotation.processing.Generated("RecordClassBuilder") private final nullable String name; + @javax.annotation.processing.Generated("RecordClassBuilder") public final nullable String name() { return name; } + SimpleRecord(String name) { + this.name = name; + } + @Override() - public final boolean hashCode(java.lang.Object o) { + @javax.annotation.processing.Generated("RecordClassBuilder") + public final boolean equals(java.lang.Object o) { + //Created by RecordClassBuilder.java:166 if (this == o) return true; - if (!(o instanceof SimpleRecord that)) + //Created by RecordClassBuilder.java:168 + if (!(o instanceof SimpleRecord)) return false; + //Created by RecordClassBuilder.java:171 + final SimpleRecord that = (SimpleRecord) o; + //Created by RecordClassBuilder.java:179 return java.lang.Objects.equals(name, that.name); + //Created by RecordClassBuilder.java:181 return true; } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final int hashCode() { return java.lang.Objects.hash(name); } @Override() + @javax.annotation.processing.Generated("RecordClassBuilder") public final non_null String toString() { - return "SimpleRecord[" + "name=" + name + "," + "]"; + return "SimpleRecord[" + "name=" + name + "]"; } SimpleRecord(String name) { @@ -56,6 +71,11 @@ public final non_null String toString() { this.name = name; } + void $init(String name) { + super.$init(); + this.name = name; + } + static private void $clprepare() { } diff --git a/key.core/pipelineTests/records/input/InnerRecord.java b/key.core/pipelineTests/records/input/InnerRecord.java index 81e05b650c..c49033b240 100644 --- a/key.core/pipelineTests/records/input/InnerRecord.java +++ b/key.core/pipelineTests/records/input/InnerRecord.java @@ -1,3 +1,5 @@ -class OuterClass { +import java.lang.Object; + +public class OuterClass { final record MyRecord(String test) {} } \ No newline at end of file diff --git a/key.core/pipelineTests/records/input/Point3d.java b/key.core/pipelineTests/records/input/Point3d.java new file mode 100644 index 0000000000..31c67aae53 --- /dev/null +++ b/key.core/pipelineTests/records/input/Point3d.java @@ -0,0 +1 @@ +record Point3d(int x, int y, int z) {} \ No newline at end of file diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/SpecialJavaPrinter.java b/key.core/src/main/java/de/uka/ilkd/key/java/SpecialJavaPrinter.java new file mode 100644 index 0000000000..a05d07a707 --- /dev/null +++ b/key.core/src/main/java/de/uka/ilkd/key/java/SpecialJavaPrinter.java @@ -0,0 +1,1333 @@ +package de.uka.ilkd.key.java; + +import com.github.javaparser.ast.Modifier; +import com.github.javaparser.ast.NodeList; +import com.github.javaparser.ast.body.BodyDeclaration; +import com.github.javaparser.ast.body.ConstructorDeclaration; +import com.github.javaparser.ast.body.MethodDeclaration; +import com.github.javaparser.printer.DefaultPrettyPrinterVisitor; +import com.github.javaparser.printer.configuration.PrinterConfiguration; +import com.google.common.base.Strings; +import de.uka.ilkd.key.java.transformations.pipeline.TransformationPipelineServices; +import de.uka.ilkd.key.speclang.jml.pretranslation.*; +import de.uka.ilkd.key.speclang.njml.JmlParser; +import de.uka.ilkd.key.speclang.njml.JmlParserBaseVisitor; +import de.uka.ilkd.key.speclang.njml.LabeledParserRuleContext; +import org.antlr.v4.runtime.ParserRuleContext; +import org.antlr.v4.runtime.Token; +import org.antlr.v4.runtime.tree.ParseTree; +import org.antlr.v4.runtime.tree.RuleNode; +import org.antlr.v4.runtime.tree.TerminalNode; +import org.jspecify.annotations.Nullable; +import org.key_project.util.collection.ImmutableList; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * + * @author Alexander Weigl + * @version 1 (3/30/26) + */ +public class SpecialJavaPrinter extends DefaultPrettyPrinterVisitor { + public SpecialJavaPrinter(PrinterConfiguration configuration) { + super(configuration); + } + + @Override + public void visit(Modifier n, Void arg) { + var isJML = false; + if (n.getKeyword() instanceof Modifier.DefaultKeyword kw) { + isJML = kw.toString().startsWith("JML_"); + } else { + isJML = true; + } + + if (isJML) { + printer.print("/*@ "); + printer.print(n.getKeyword().asString()); + printer.print("*/ "); + } else { + super.visit(n, arg); + } + } + + @Override + public void visit(MethodDeclaration n, Void arg) { + print(TransformationPipelineServices.getSpec(n)); + super.visit(n, arg); + } + + @Override + public void visit(ConstructorDeclaration n, Void arg) { + print(TransformationPipelineServices.getSpec(n)); + super.visit(n, arg); + } + + @Override + protected void printCompactClassMembers(NodeList> members, Void arg) { + print(TransformationPipelineServices.getClassSpec(members.getParentNode().get())); + super.printCompactClassMembers(members, arg); + } + + @Override + protected void printMembers(NodeList> members, Void arg) { + print(TransformationPipelineServices.getClassSpec(members.getParentNode().get())); + super.printMembers(members, arg); + } + + + private void print(List spec) { + for (var construct : spec) { + switch (construct) { + case TextualJMLLoopSpec c -> print(c); + case TextualJMLAssertStatement c -> print(c); + case TextualJMLClassAxiom c -> print(c.getModifiers(), c.getAxiom().first); + case TextualJMLClassInv c -> print(c.getModifiers(), c.getInv()); + case TextualJMLDepends c -> print(c.getModifiers(), c.getDepends()); + case TextualJMLFieldDecl c -> {} + case TextualJMLInitially c -> print(c.getModifiers(), c.getInv().first); + case TextualJMLMergePointDecl c -> print(c.getModifiers(), c.getMergeProc()); + case TextualJMLMethodDecl c -> print(c.getModifiers(), c.getDecl()); + case TextualJMLModifierList c -> print(c.getModifiers()); + case TextualJMLRepresents c -> print(c.getModifiers(), c.getRepresents().first); + case TextualJMLSetStatement c -> print(c.getAssignment()); + case TextualJMLSpecCase c -> print(c); + default -> throw new IllegalStateException("Unexpected value: " + construct); + } + } + } + + private void print(ImmutableList modifiers, ImmutableList depends) { + + } + private void print(TextualJMLSpecCase c) { + + } + + private void print(ImmutableList modifiers, @Nullable ParserRuleContext first) { + if (first == null) return; + var text = first.accept(new ToStringVisitor()); + if (text.contains("\n")) { + printer.print("/*@ "); + print(modifiers); + printer.print(text); + printer.print("\n*/"); + } else { + printer.print("//@ "); + print(modifiers); + printer.print(text); + } + } + + private void print(ImmutableList modifiers) { + for (var modifier : modifiers) { + printer.print(modifier.getParserKeyword().asString()); + } + } + + private void print(@Nullable ParserRuleContext first) { + if (first == null) return; + var text = first.accept(new ToStringVisitor()); + if (text.contains("\n")) { + printer.print("/*@ "); + printer.print(text); + printer.print("\n*/"); + } else { + printer.print("//@ "); + printer.print(text); + } + } + + private void print(TextualJMLAssertStatement c) { + + } + + private void print(TextualJMLLoopSpec c) { + + } +} + + +class ToStringVisitor extends JmlParserBaseVisitor { + public String accept(@Nullable ParseTree c) { + if (c == null) return ""; + return c.accept(this); + } + + public String accept(String prefix, @Nullable ParseTree c) { + if (c == null) return ""; + return prefix + c.accept(this); + } + + public String accept(@Nullable ParseTree c, String suffix) { + if (c == null) return ""; + return c.accept(this) + suffix; + } + + @Override + public String visitAccessible_clause(JmlParser.Accessible_clauseContext ctx) { + return "accessible " + accept(ctx.targetHeap()) + + accept(ctx.lhs, ":") + + accept(ctx.rhs) + + accept(" \\measured_by ", ctx.mby) + + ";"; + } + + @Override + public String visitAdditiveexpr(JmlParser.AdditiveexprContext ctx) { + return accept(ctx.multexpr(), ctx.op); + } + + @Override + public String visitAlso_keyword(JmlParser.Also_keywordContext ctx) { + return super.visitAlso_keyword(ctx); + } + + @Override + public String visitAndexpr(JmlParser.AndexprContext ctx) { + return accept(ctx.equalityexpr(), " & "); + } + + @Override + public String visitArray_dimension(JmlParser.Array_dimensionContext ctx) { + return super.visitArray_dimension(ctx); + } + + @Override + public String visitArray_dimensions(JmlParser.Array_dimensionsContext ctx) { + return super.visitArray_dimensions(ctx); + } + + @Override + public String visitArray_initializer(JmlParser.Array_initializerContext ctx) { + return super.visitArray_initializer(ctx); + } + + @Override + public String visitAssert_statement(JmlParser.Assert_statementContext ctx) { + return super.visitAssert_statement(ctx); + } + + @Override + public String visitAssignable_clause(JmlParser.Assignable_clauseContext ctx) { + return "assignable " + accept(ctx.targetHeap()) + + accept(ctx.storeRefUnion()) + + accept(ctx.STRICTLY_NOTHING()) + + ";"; + } + + private String accept(TerminalNode terminalNode) { + if (terminalNode != null) + return terminalNode.getText(); + return ""; + } + + @Override + public String visitAssume_statement(JmlParser.Assume_statementContext ctx) { + return super.visitAssume_statement(ctx); + } + + @Override + public String visitBeforeexpression(JmlParser.BeforeexpressionContext ctx) { + return super.visitBeforeexpression(ctx); + } + + @Override + public String visitBigint_math_expression(JmlParser.Bigint_math_expressionContext ctx) { + return "\\bigint_math(" + accept(ctx.expression()) + ")"; + } + + @Override + public String visitBlock_loop_specification(JmlParser.Block_loop_specificationContext ctx) { + return super.visitBlock_loop_specification(ctx); + } + + @Override + public String visitBlock_specification(JmlParser.Block_specificationContext ctx) { + return super.visitBlock_specification(ctx); + } + + @Override + public String visitBoundvarmodifiers(JmlParser.BoundvarmodifiersContext ctx) { + return ctx.start.getText(); + } + + @Override + public String visitBreaks_clause(JmlParser.Breaks_clauseContext ctx) { + return super.visitBreaks_clause(ctx); + } + + @Override + public String visitBsumterm(JmlParser.BsumtermContext ctx) { + return "(\\bsum " + + accept(ctx.quantifiedvardecls()) + "; " + + accept(ctx.expression(), "; ") + + ")"; + } + + @Override + public String visitBuiltintype(JmlParser.BuiltintypeContext ctx) { + return ctx.start.getText(); + } + + @Override + public String visitCaptures_clause(JmlParser.Captures_clauseContext ctx) { + return "captures " + + accept(ctx.predornot()) + + ";"; + } + + @Override + public String visitCastexpr(JmlParser.CastexprContext ctx) { + return "(" + accept(ctx.typespec()) + ") " + accept(ctx.unaryexpr()); + } + + @Override + public String visitCharliteral(JmlParser.CharliteralContext ctx) { + return accept(ctx.CHAR_LITERAL()); + } + + @Override + public String visitClass_axiom(JmlParser.Class_axiomContext ctx) { + return "axiom " + accept(ctx.expression()) + ";"; + } + + @Override + public String visitClass_invariant(JmlParser.Class_invariantContext ctx) { + return "invariant " + accept(ctx.expression()) + ";"; + } + + @Override + public String visitClause(JmlParser.ClauseContext ctx) { + return super.visitClause(ctx); + } + + @Override + public String visitClauseEOF(JmlParser.ClauseEOFContext ctx) { + return super.visitClauseEOF(ctx); + } + + @Override + public String visitConditionalexpr(JmlParser.ConditionalexprContext ctx) { + return accept(ctx.equivalenceexpr()) + + (ctx.QUESTIONMARK() != null ? + accept("? ", ctx.conditionalexpr(0)) + accept(" : ", ctx.conditionalexpr(1)) + : ""); + } + + @Override + public String visitConstant(JmlParser.ConstantContext ctx) { + return super.visitConstant(ctx); + } + + @Override + public String visitContinues_clause(JmlParser.Continues_clauseContext ctx) { + return super.visitContinues_clause(ctx); + } + + @Override + public String visitCreateLocset(JmlParser.CreateLocsetContext ctx) { + return super.visitCreateLocset(ctx); + } + + @Override + public String visitDatagroup_clause(JmlParser.Datagroup_clauseContext ctx) { + return super.visitDatagroup_clause(ctx); + } + + @Override + public String visitDebug_statement(JmlParser.Debug_statementContext ctx) { + return super.visitDebug_statement(ctx); + } + + @Override + public String visitDetermines_clause(JmlParser.Determines_clauseContext ctx) { + return super.visitDetermines_clause(ctx); + } + + @Override + public String visitDims(JmlParser.DimsContext ctx) { + return Strings.repeat("[]", ctx.LBRACKET().size()); + } + + @Override + public String visitDiverges_clause(JmlParser.Diverges_clauseContext ctx) { + return "captures " + + accept(ctx.predornot()) + + ";"; + } + + @Override + public String visitDuration_clause(JmlParser.Duration_clauseContext ctx) { + return "duration " + + accept(ctx.predornot()) + + ";"; + } + + @Override + public String visitEnsures_clause(JmlParser.Ensures_clauseContext ctx) { + return "ensures " + accept(ctx.targetHeap()) + + accept(ctx.predornot()) + + ";"; + } + + @Override + public String visitEqualityexpr(JmlParser.EqualityexprContext ctx) { + return accept(ctx.relationalexpr(), " == "); //TODO + } + + @Override + public String visitEquivalenceexpr(JmlParser.EquivalenceexprContext ctx) { + return accept(ctx.impliesexpr(), "<==>"); //TODO + } + + @Override + public String visitExclusiveorexpr(JmlParser.ExclusiveorexprContext ctx) { + return accept(ctx.andexpr(), " ^ "); + } + + @Override + public String visitExpression(JmlParser.ExpressionContext ctx) { + return accept(ctx.conditionalexpr()); + } + + @Override + public String visitExpressionEOF(JmlParser.ExpressionEOFContext ctx) { + return super.visitExpressionEOF(ctx); + } + + @Override + public String visitExpressionlist(JmlParser.ExpressionlistContext ctx) { + return accept(ctx.expression(), ", "); + } + + @Override + public String visitExprList(JmlParser.ExprListContext ctx) { + return super.visitExprList(ctx); + } + + @Override + public String visitFalse_(JmlParser.False_Context ctx) { + return super.visitFalse_(ctx); + } + + @Override + public String visitField_declaration(JmlParser.Field_declarationContext ctx) { + return super.visitField_declaration(ctx); + } + + @Override + public String visitFpOperator(JmlParser.FpOperatorContext ctx) { + return ctx.start.getText(); + } + + @Override + public String visitFractionalliteral(JmlParser.FractionalliteralContext ctx) { + return super.visitFractionalliteral(ctx); + } + + @Override + public String visitHistory_constraint(JmlParser.History_constraintContext ctx) { + return super.visitHistory_constraint(ctx); + } + + @Override + public String visitIdent(JmlParser.IdentContext ctx) { + return oneOf(ctx.IDENT(), ctx.JML_IDENT()); + } + + @Override + public String visitImpliesexpr(JmlParser.ImpliesexprContext ctx) { + return accept(ctx.a) + + accept(" ==> ", ctx.b) + + accept(" <== ", ctx.c, " <== "); + } + + @Override + public String visitImpliesforwardexpr(JmlParser.ImpliesforwardexprContext ctx) { + return accept(ctx.a) + accept(" ==> ", ctx.b); + } + + @Override + public String visitIn_group_clause(JmlParser.In_group_clauseContext ctx) { + return super.visitIn_group_clause(ctx); + } + + @Override + public String visitInclusiveorexpr(JmlParser.InclusiveorexprContext ctx) { + return accept(ctx.exclusiveorexpr(), " | "); + } + + @Override + public String visitInfflowspeclist(JmlParser.InfflowspeclistContext ctx) { + return super.visitInfflowspeclist(ctx); + } + + @Override + public String visitInfinite_union_expr(JmlParser.Infinite_union_exprContext ctx) { + return super.visitInfinite_union_expr(ctx); + } + + @Override + public String visitInitialiser(JmlParser.InitialiserContext ctx) { + return super.visitInitialiser(ctx); + } + + @Override + public String visitInitially_clause(JmlParser.Initially_clauseContext ctx) { + return "initially " + accept(ctx.expression()) + ";"; + } + + @Override + public String visitInstance_of(JmlParser.Instance_ofContext ctx) { + return accept(ctx.shiftexpr()) + " instanceof " + accept(ctx.typespec()); + } + + @Override + public String visitIntegerliteral(JmlParser.IntegerliteralContext ctx) { + return accept(ctx.BINLITERAL()) + + accept(ctx.DECLITERAL()) + + accept(ctx.HEXLITERAL()) + + accept(ctx.OCTLITERAL()); + } + + @Override + public String visitInv(JmlParser.InvContext ctx) { + return super.visitInv(ctx); + } + + @Override + public String visitInv_free(JmlParser.Inv_freeContext ctx) { + return super.visitInv_free(ctx); + } + + @Override + public String visitJava_math_expression(JmlParser.Java_math_expressionContext ctx) { + return "\\java_math(" + + accept(ctx.expression()) + + ")"; + } + + @Override + public String visitJavaliteral(JmlParser.JavaliteralContext ctx) { + return super.visitJavaliteral(ctx); + } + + @Override + public String visitLogicalandexpr(JmlParser.LogicalandexprContext ctx) { + return accept(ctx.inclusiveorexpr(), "&&"); + } + + @Override + public String visitLogicalorexpr(JmlParser.LogicalorexprContext ctx) { + return accept(ctx.logicalandexpr(), "||"); + } + + @Override + public String visitLoop_assignable_clause(JmlParser.Loop_assignable_clauseContext ctx) { + return super.visitLoop_assignable_clause(ctx); + } + + @Override + public String visitLoop_contract_keyword(JmlParser.Loop_contract_keywordContext ctx) { + return super.visitLoop_contract_keyword(ctx); + } + + @Override + public String visitLoop_determines_clause(JmlParser.Loop_determines_clauseContext ctx) { + return super.visitLoop_determines_clause(ctx); + } + + @Override + public String visitLoop_invariant(JmlParser.Loop_invariantContext ctx) { + return super.visitLoop_invariant(ctx); + } + + @Override + public String visitLoop_separates_clause(JmlParser.Loop_separates_clauseContext ctx) { + return super.visitLoop_separates_clause(ctx); + } + + @Override + public String visitLoop_specification(JmlParser.Loop_specificationContext ctx) { + return super.visitLoop_specification(ctx); + } + + @Override + public String visitMapExpression(JmlParser.MapExpressionContext ctx) { + return super.visitMapExpression(ctx); + } + + @Override + public String visitMaps_into_clause(JmlParser.Maps_into_clauseContext ctx) { + return super.visitMaps_into_clause(ctx); + } + + @Override + public String visitMbody_block(JmlParser.Mbody_blockContext ctx) { + return super.visitMbody_block(ctx); + } + + @Override + public String visitMbody_if(JmlParser.Mbody_ifContext ctx) { + return super.visitMbody_if(ctx); + } + + @Override + public String visitMbody_return(JmlParser.Mbody_returnContext ctx) { + return super.visitMbody_return(ctx); + } + + @Override + public String visitMbody_var(JmlParser.Mbody_varContext ctx) { + return super.visitMbody_var(ctx); + } + + @Override + public String visitMeasured_by_clause(JmlParser.Measured_by_clauseContext ctx) { + return "measured_by " + + accept(ctx.predornot(), ", ") + + ";"; + } + + private String accept(List ctxs, String s) { + return ctxs.stream() + .map(this::accept) + .collect(Collectors.joining(s)); + } + + @Override + public String visitMerge_point_statement(JmlParser.Merge_point_statementContext ctx) { + return super.visitMerge_point_statement(ctx); + } + + @Override + public String visitMergeparamsspec(JmlParser.MergeparamsspecContext ctx) { + return super.visitMergeparamsspec(ctx); + } + + @Override + public String visitMethod_declaration(JmlParser.Method_declarationContext ctx) { + return super.visitMethod_declaration(ctx); + } + + @Override + public String visitMethod_specification(JmlParser.Method_specificationContext ctx) { + return super.visitMethod_specification(ctx); + } + + @Override + public String visitMethodlevel_comment(JmlParser.Methodlevel_commentContext ctx) { + return super.visitMethodlevel_comment(ctx); + } + + @Override + public String visitMethodlevel_element(JmlParser.Methodlevel_elementContext ctx) { + return super.visitMethodlevel_element(ctx); + } + + @Override + public String visitModifier(JmlParser.ModifierContext ctx) { + return super.visitModifier(ctx); + } + + @Override + public String visitModifiers(JmlParser.ModifiersContext ctx) { + return super.visitModifiers(ctx); + } + + @Override + public String visitModifiersEOF(JmlParser.ModifiersEOFContext ctx) { + return super.visitModifiersEOF(ctx); + } + + @Override + public String visitMonitors_for_clause(JmlParser.Monitors_for_clauseContext ctx) { + return super.visitMonitors_for_clause(ctx); + } + + @Override + public String visitMultexpr(JmlParser.MultexprContext ctx) { + return accept(ctx.unaryexpr(), ctx.op); + } + + @Override + public String visitName(JmlParser.NameContext ctx) { + return ctx.ident().stream().map(this::accept).collect(Collectors.joining(".")); + } + + @Override + public String visitName_clause(JmlParser.Name_clauseContext ctx) { + return "name " + accept(ctx.SPEC_NAME()); + } + + @Override + public String visitNew_expr(JmlParser.New_exprContext ctx) { + return "new " + accept(ctx.type()) + "(" + accept(ctx.expressionlist(), ", ") + ")"; + } + + @Override + public String visitNowarn_pragma(JmlParser.Nowarn_pragmaContext ctx) { + return super.visitNowarn_pragma(ctx); + } + + @Override + public String visitNull_(JmlParser.Null_Context ctx) { + return super.visitNull_(ctx); + } + + @Override + public String visitOldexpression(JmlParser.OldexpressionContext ctx) { + return super.visitOldexpression(ctx); + } + + @Override + public String visitParam_decl(JmlParser.Param_declContext ctx) { + return super.visitParam_decl(ctx); + } + + @Override + public String visitParam_list(JmlParser.Param_listContext ctx) { + return super.visitParam_list(ctx); + } + + @Override + public String visitPignore1(JmlParser.Pignore1Context ctx) { + return accept(ctx.getChild(0)); + } + + @Override + public String visitPignore2(JmlParser.Pignore2Context ctx) { + return accept(ctx.getChild(0)); + } + + @Override + public String visitPignore3(JmlParser.Pignore3Context ctx) { + return accept(ctx.getChild(0)); + } + + @Override + public String visitPignore4(JmlParser.Pignore4Context ctx) { + return accept(ctx.getChild(0)); + } + + @Override + public String visitPignore5(JmlParser.Pignore5Context ctx) { + return accept(ctx.getChild(0)); + } + + @Override + public String visitPignore6(JmlParser.Pignore6Context ctx) { + return accept(ctx.getChild(0)); + } + + @Override + public String visitPignore7(JmlParser.Pignore7Context ctx) { + return accept(ctx.getChild(0)); + } + + @Override + public String visitPostfixexpr(JmlParser.PostfixexprContext ctx) { + return accept(ctx.primaryexpr()) + accept(ctx.primarysuffix(), ""); + } + + @Override + public String visitPredicate(JmlParser.PredicateContext ctx) { + return accept(ctx.expression()); + } + + @Override + public String visitPredornot(JmlParser.PredornotContext ctx) { + return oneOf(ctx.predicate(), ctx.NOT_SPECIFIED()); + } + + @Override + public String visitPrimaryAllFields(JmlParser.PrimaryAllFieldsContext ctx) { + return super.visitPrimaryAllFields(ctx); + } + + @Override + public String visitPrimaryAllObj(JmlParser.PrimaryAllObjContext ctx) { + return super.visitPrimaryAllObj(ctx); + } + + @Override + public String visitPrimaryBackup(JmlParser.PrimaryBackupContext ctx) { + return super.visitPrimaryBackup(ctx); + } + + @Override + public String visitPrimaryBigintMathExpression(JmlParser.PrimaryBigintMathExpressionContext ctx) { + return accept(ctx.bigint_math_expression()); + + } + + @Override + public String visitPrimaryCreateLocsetSingleton(JmlParser.PrimaryCreateLocsetSingletonContext ctx) { + return super.visitPrimaryCreateLocsetSingleton(ctx); + } + + @Override + public String visitPrimaryDisjoint(JmlParser.PrimaryDisjointContext ctx) { + return super.visitPrimaryDisjoint(ctx); + } + + @Override + public String visitPrimaryDuration(JmlParser.PrimaryDurationContext ctx) { + return super.visitPrimaryDuration(ctx); + } + + @Override + public String visitPrimaryElemtype(JmlParser.PrimaryElemtypeContext ctx) { + return super.visitPrimaryElemtype(ctx); + } + + @Override + public String visitPrimaryEmptySet(JmlParser.PrimaryEmptySetContext ctx) { + return super.visitPrimaryEmptySet(ctx); + } + + @Override + public String visitPrimaryException(JmlParser.PrimaryExceptionContext ctx) { + return super.visitPrimaryException(ctx); + } + + @Override + public String visitPrimaryexpr(JmlParser.PrimaryexprContext ctx) { + return oneOf(ctx.constant(), + ctx.ident(), ctx.inv(), ctx.inv_free(), ctx.true_(), ctx.false_(), ctx.null_(), ctx.jmlprimary(), ctx.new_expr(), ctx.array_initializer()); + } + + private String oneOf(ParseTree... ctxs) { + for (var ctx : ctxs) { + if (ctx != null) return accept(ctx); + } + return ""; + } + + private String oneOf(TerminalNode... ctxs) { + for (var ctx : ctxs) { + if (ctx != null) return accept(ctx); + } + return ""; + } + + @Override + public String visitPrimaryFresh(JmlParser.PrimaryFreshContext ctx) { + return super.visitPrimaryFresh(ctx); + } + + @Override + public String visitPrimaryignore10(JmlParser.Primaryignore10Context ctx) { + return super.visitPrimaryignore10(ctx); + } + + @Override + public String visitPrimaryIndex(JmlParser.PrimaryIndexContext ctx) { + return super.visitPrimaryIndex(ctx); + } + + @Override + public String visitPrimaryInformalDesc(JmlParser.PrimaryInformalDescContext ctx) { + return super.visitPrimaryInformalDesc(ctx); + } + + @Override + public String visitPrimaryIntersect(JmlParser.PrimaryIntersectContext ctx) { + return super.visitPrimaryIntersect(ctx); + } + + @Override + public String visitPrimaryInvFor(JmlParser.PrimaryInvForContext ctx) { + return super.visitPrimaryInvFor(ctx); + } + + @Override + public String visitPrimaryInvFreeFor(JmlParser.PrimaryInvFreeForContext ctx) { + return super.visitPrimaryInvFreeFor(ctx); + } + + @Override + public String visitPrimaryIsInitialised(JmlParser.PrimaryIsInitialisedContext ctx) { + return super.visitPrimaryIsInitialised(ctx); + } + + @Override + public String visitPrimaryJavaMathExpression(JmlParser.PrimaryJavaMathExpressionContext ctx) { + return super.visitPrimaryJavaMathExpression(ctx); + } + + @Override + public String visitPrimaryLblNeg(JmlParser.PrimaryLblNegContext ctx) { + return super.visitPrimaryLblNeg(ctx); + } + + @Override + public String visitPrimaryLblPos(JmlParser.PrimaryLblPosContext ctx) { + return super.visitPrimaryLblPos(ctx); + } + + @Override + public String visitPrimaryLockset(JmlParser.PrimaryLocksetContext ctx) { + return super.visitPrimaryLockset(ctx); + } + + @Override + public String visitPrimaryMapEmpty(JmlParser.PrimaryMapEmptyContext ctx) { + return super.visitPrimaryMapEmpty(ctx); + } + + @Override + public String visitPrimaryMapExpr(JmlParser.PrimaryMapExprContext ctx) { + return super.visitPrimaryMapExpr(ctx); + } + + @Override + public String visitPrimaryNewElemsfrehs(JmlParser.PrimaryNewElemsfrehsContext ctx) { + return super.visitPrimaryNewElemsfrehs(ctx); + } + + @Override + public String visitPrimaryNNE(JmlParser.PrimaryNNEContext ctx) { + return super.visitPrimaryNNE(ctx); + } + + @Override + public String visitPrimaryNotAssigned(JmlParser.PrimaryNotAssignedContext ctx) { + return super.visitPrimaryNotAssigned(ctx); + } + + @Override + public String visitPrimaryNotMod(JmlParser.PrimaryNotModContext ctx) { + return super.visitPrimaryNotMod(ctx); + } + + @Override + public String visitPrimaryParen(JmlParser.PrimaryParenContext ctx) { + return super.visitPrimaryParen(ctx); + } + + @Override + public String visitPrimaryPermission(JmlParser.PrimaryPermissionContext ctx) { + return super.visitPrimaryPermission(ctx); + } + + @Override + public String visitPrimaryReach(JmlParser.PrimaryReachContext ctx) { + return super.visitPrimaryReach(ctx); + } + + @Override + public String visitPrimaryReachLocs(JmlParser.PrimaryReachLocsContext ctx) { + return super.visitPrimaryReachLocs(ctx); + } + + @Override + public String visitPrimaryResult(JmlParser.PrimaryResultContext ctx) { + return super.visitPrimaryResult(ctx); + } + + @Override + public String visitPrimarySafeMathExpression(JmlParser.PrimarySafeMathExpressionContext ctx) { + return super.visitPrimarySafeMathExpression(ctx); + } + + @Override + public String visitPrimarySeq2Map(JmlParser.PrimarySeq2MapContext ctx) { + return super.visitPrimarySeq2Map(ctx); + } + + @Override + public String visitPrimarySetMinux(JmlParser.PrimarySetMinuxContext ctx) { + return super.visitPrimarySetMinux(ctx); + } + + @Override + public String visitPrimarySpace(JmlParser.PrimarySpaceContext ctx) { + return super.visitPrimarySpace(ctx); + } + + @Override + public String visitPrimaryStaticInv(JmlParser.PrimaryStaticInvContext ctx) { + return super.visitPrimaryStaticInv(ctx); + } + + @Override + public String visitPrimaryStaticInvFree(JmlParser.PrimaryStaticInvFreeContext ctx) { + return super.visitPrimaryStaticInvFree(ctx); + } + + @Override + public String visitPrimaryStoreRef(JmlParser.PrimaryStoreRefContext ctx) { + return super.visitPrimaryStoreRef(ctx); + } + + @Override + public String visitPrimaryStringEq(JmlParser.PrimaryStringEqContext ctx) { + return super.visitPrimaryStringEq(ctx); + } + + @Override + public String visitPrimarySubset(JmlParser.PrimarySubsetContext ctx) { + return super.visitPrimarySubset(ctx); + } + + @Override + public String visitPrimarySuffixAccess(JmlParser.PrimarySuffixAccessContext ctx) { + return "." + oneOf(ctx.IDENT(), ctx.TRANSIENT(), ctx.THIS(), ctx.INV(), ctx.INV_FREE(), ctx.MULT()) + + (ctx.LPAREN() != null ? "(" + accept(ctx.expressionlist(), ", ") + ")" : ""); + } + + @Override + public String visitPrimarySuffixArray(JmlParser.PrimarySuffixArrayContext ctx) { + return super.visitPrimarySuffixArray(ctx); + } + + @Override + public String visitPrimarySuffixCall(JmlParser.PrimarySuffixCallContext ctx) { + return super.visitPrimarySuffixCall(ctx); + } + + @Override + public String visitPrimaryTypeOf(JmlParser.PrimaryTypeOfContext ctx) { + return super.visitPrimaryTypeOf(ctx); + } + + @Override + public String visitPrimaryUnion(JmlParser.PrimaryUnionContext ctx) { + return super.visitPrimaryUnion(ctx); + } + + @Override + public String visitPrimaryUnionInf(JmlParser.PrimaryUnionInfContext ctx) { + return super.visitPrimaryUnionInf(ctx); + } + + @Override + public String visitPrimaryValues(JmlParser.PrimaryValuesContext ctx) { + return super.visitPrimaryValues(ctx); + } + + @Override + public String visitPrimaryWorksingSpace(JmlParser.PrimaryWorksingSpaceContext ctx) { + return super.visitPrimaryWorksingSpace(ctx); + } + + @Override + public String visitPrimayTypeSpec(JmlParser.PrimayTypeSpecContext ctx) { + return super.visitPrimayTypeSpec(ctx); + } + + @Override + public String visitQuantifiedvardecls(JmlParser.QuantifiedvardeclsContext ctx) { + return accept(ctx.typespec()) + " " + accept(ctx.quantifiedvariabledeclarator(), ", "); + + } + + @Override + public String visitQuantifiedvariabledeclarator(JmlParser.QuantifiedvariabledeclaratorContext ctx) { + return accept(ctx.IDENT()) + accept(ctx.dims()); + } + + @Override + public String visitQuantifier(JmlParser.QuantifierContext ctx) { + return ctx.start.getText(); + } + + @Override + public String visitReadable_if_clause(JmlParser.Readable_if_clauseContext ctx) { + return super.visitReadable_if_clause(ctx); + } + + @Override + public String visitReferencetype(JmlParser.ReferencetypeContext ctx) { + return accept(ctx.name()); + } + + @Override + public String visitRelational_chain(JmlParser.Relational_chainContext ctx) { + return accept(ctx.shiftexpr(), ctx.op); + } + + @Override + public String visitRelational_lockset(JmlParser.Relational_locksetContext ctx) { + return accept(ctx.shiftexpr()) + " <# " + accept(ctx.postfixexpr()); + } + + @Override + public String visitRelationalexpr(JmlParser.RelationalexprContext ctx) { + return accept(ctx.shiftexpr()) + + accept(ctx.relational_chain()) + + accept(ctx.relational_lockset()) + + accept(ctx.instance_of()) + + accept(ctx.st_expr()); + } + + @Override + public String visitRepresents_clause(JmlParser.Represents_clauseContext ctx) { + return "represents " + accept(ctx.lhs) + + "=" + + accept(ctx.rhs) + + accept(ctx.storeRefUnion()) + + accept("\\such_that", ctx.predicate()) + + ";"; + } + + @Override + public String visitRequires_clause(JmlParser.Requires_clauseContext ctx) { + return "requires " + accept(ctx.targetHeap()) + + accept(ctx.predornot()) + + ";"; + } + + @Override + public String visitReturns_clause(JmlParser.Returns_clauseContext ctx) { + return super.visitReturns_clause(ctx); + } + + @Override + public String visitSafe_math_expression(JmlParser.Safe_math_expressionContext ctx) { + return "\\safe_math(" + + accept(ctx.expression()) + + ")"; + } + + @Override + public String visitSeparates_clause(JmlParser.Separates_clauseContext ctx) { + return "separates " + accept(ctx.sep) + + accept("\n \\declassifies", ctx.decl, ", ") + + accept("\n \\erases", ctx.decl, ", ") + + accept("\n \\new_objects", ctx.decl, ", ") + + ";"; + } + + private String accept(String prefix, List ctxs, String delimiter) { + if (ctxs.isEmpty()) { + return ""; + } + return prefix + accept(ctxs, delimiter); + } + + @Override + public String visitSeqdefterm(JmlParser.SeqdeftermContext ctx) { + return "(\\seqdef " + + accept(ctx.quantifiedvardecls()) + "; " + + accept(ctx.expression(), "; ") + + ")"; + } + + @Override + public String visitSequenceCreate(JmlParser.SequenceCreateContext ctx) { + return super.visitSequenceCreate(ctx); + } + + @Override + public String visitSequenceEmpty(JmlParser.SequenceEmptyContext ctx) { + return super.visitSequenceEmpty(ctx); + } + + @Override + public String visitSequenceFuncs(JmlParser.SequenceFuncsContext ctx) { + return super.visitSequenceFuncs(ctx); + } + + @Override + public String visitSequenceIgnore1(JmlParser.SequenceIgnore1Context ctx) { + return super.visitSequenceIgnore1(ctx); + } + + @Override + public String visitSequenceReplace(JmlParser.SequenceReplaceContext ctx) { + return super.visitSequenceReplace(ctx); + } + + @Override + public String visitSequenceReverse(JmlParser.SequenceReverseContext ctx) { + return super.visitSequenceReverse(ctx); + } + + @Override + public String visitSequenceSub(JmlParser.SequenceSubContext ctx) { + return super.visitSequenceSub(ctx); + } + + @Override + public String visitSet_statement(JmlParser.Set_statementContext ctx) { + return super.visitSet_statement(ctx); + } + + @Override + public String visitShiftexpr(JmlParser.ShiftexprContext ctx) { + return accept(ctx.additiveexpr(), ctx.op); + } + + private String accept(List expr, List op) { + StringBuilder s = new StringBuilder(accept(expr.getFirst())); + for (var i = 1; i < expr.size(); i++) { + s.append(" ").append(op.get(i - 1)).append(" ").append(accept(expr.get(i))); + } + return s.toString(); + } + + @Override + public String visitSignals_clause(JmlParser.Signals_clauseContext ctx) { + return super.visitSignals_clause(ctx); + } + + @Override + public String visitChildren(RuleNode node) { + System.err.println(node.getClass().getSimpleName() + " not implemented " + node.getText()); + return super.visitChildren(node); + } + + @Override + protected String aggregateResult(String aggregate, String nextResult) { + return ((aggregate != null) ? aggregate : "") + + ((nextResult != null) ? nextResult : ""); + } + + @Override + public String visitSignals_only_clause(JmlParser.Signals_only_clauseContext ctx) { + return super.visitSignals_only_clause(ctx); + } + + @Override + public String visitSpec_body(JmlParser.Spec_bodyContext ctx) { + return super.visitSpec_body(ctx); + } + + @Override + public String visitSpec_case(JmlParser.Spec_caseContext ctx) { + return super.visitSpec_case(ctx); + } + + @Override + public String visitSpecquantifiedexpression(JmlParser.SpecquantifiedexpressionContext ctx) { + return "(" + + accept(ctx.quantifier()) + " " + + accept(ctx.boundvarmodifiers()) + + accept(ctx.quantifiedvardecls()) + "; " + + accept(ctx.expression(), "; ") + + ")"; + + } + + @Override + public String visitSt_expr(JmlParser.St_exprContext ctx) { + return accept(ctx.shiftexpr(0)) + + " <: " + + accept(ctx.shiftexpr(1)); + } + + @Override + public String visitStoreref(JmlParser.StorerefContext ctx) { + return super.visitStoreref(ctx); + } + + @Override + public String visitStoreRefExpr(JmlParser.StoreRefExprContext ctx) { + return super.visitStoreRefExpr(ctx); + } + + @Override + public String visitStoreRefIntersect(JmlParser.StoreRefIntersectContext ctx) { + return super.visitStoreRefIntersect(ctx); + } + + @Override + public String visitStoreRefList(JmlParser.StoreRefListContext ctx) { + return super.visitStoreRefList(ctx); + } + + @Override + public String visitStoreRefUnion(JmlParser.StoreRefUnionContext ctx) { + return super.visitStoreRefUnion(ctx); + } + + @Override + public String visitStringliteral(JmlParser.StringliteralContext ctx) { + return super.visitStringliteral(ctx); + } + + @Override + public String visitTargetHeap(JmlParser.TargetHeapContext ctx) { + return super.visitTargetHeap(ctx); + } + + @Override + public String visitTermexpression(JmlParser.TermexpressionContext ctx) { + return super.visitTermexpression(ctx); + } + + @Override + public String visitThis_(JmlParser.This_Context ctx) { + return super.visitThis_(ctx); + } + + @Override + public String visitTransactionUpdated(JmlParser.TransactionUpdatedContext ctx) { + return super.visitTransactionUpdated(ctx); + } + + @Override + public String visitTrue_(JmlParser.True_Context ctx) { + return super.visitTrue_(ctx); + } + + @Override + public String visitType(JmlParser.TypeContext ctx) { + return accept(ctx.TYPE()) + oneOf(ctx.builtintype(), ctx.referencetype()); + } + + @Override + public String visitTypespec(JmlParser.TypespecContext ctx) { + return accept(ctx.type()) + accept(ctx.dims()); + } + + @Override + public String visitUnaryexpr(JmlParser.UnaryexprContext ctx) { + if (ctx.PLUS() != null) + return "+" + accept(ctx.unaryexpr()); + if (ctx.MINUS() != null) + return "-" + accept(ctx.unaryexpr()); + if (ctx.DECLITERAL() != null) + return "-" + accept((ctx.DECLITERAL())); + return accept(ctx.castexpr()) + accept(ctx.unaryexprnotplusminus()); + } + + @Override + public String visitUnaryexprnotplusminus(JmlParser.UnaryexprnotplusminusContext ctx) { + if (ctx.NOT() != null) + return "!" + accept(ctx.unaryexpr()); + if (ctx.BITWISENOT() != null) + return "~" + accept(ctx.unaryexpr()); + return accept(ctx.postfixexpr()); + + } + + @Override + public String visitVariant_function(JmlParser.Variant_functionContext ctx) { + return "decreases " + accept(ctx.expression(), ", "); + } + + @Override + public String visitWhen_clause(JmlParser.When_clauseContext ctx) { + return "when " + + accept(ctx.predornot()) + + ";"; + } + + @Override + public String visitWorking_space_clause(JmlParser.Working_space_clauseContext ctx) { + return "working_space " + + accept(ctx.predornot()) + + ";"; + } + + @Override + public String visitWritable_if_clause(JmlParser.Writable_if_clauseContext ctx) { + return super.visitWritable_if_clause(ctx); + } +} diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/AstFactory.java b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/AstFactory.java index d8420a71b7..1181a160c9 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/AstFactory.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/AstFactory.java @@ -141,4 +141,8 @@ public static T mark(T node) { String.format("Created by %s:%d", next.getFileName(), next.getLineNumber())); return node; } + + public static Expression attributeThis(String field) { + return attribute(new ThisExpr(), field); + } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/JavaTransformer.java b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/JavaTransformer.java index 0d3926d68f..5e78846910 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/JavaTransformer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/JavaTransformer.java @@ -4,12 +4,15 @@ package de.uka.ilkd.key.java.transformations.pipeline; - import com.github.javaparser.ast.CompilationUnit; import com.github.javaparser.ast.Node; import com.github.javaparser.ast.body.TypeDeclaration; +import com.github.javaparser.ast.expr.StringLiteralExpr; +import com.github.javaparser.ast.nodeTypes.NodeWithAnnotations; import org.jspecify.annotations.NullMarked; +import javax.annotation.processing.Generated; + /** * The JavaDL requires some implicit fields, that are available in each * Java class. The name of the implicit fields starts usually with a dollar sign. @@ -84,4 +87,10 @@ public static RuntimeException reportError(Node node, String message, Object... var pos = " at " + path + ":" + line + ":" + col; return new IllegalStateException(String.format(message + pos, args)); } + + protected void addGenerated(NodeWithAnnotations node) { + node.addSingleMemberAnnotation( + Generated.class.getName(), + new StringLiteralExpr(this.getClass().getSimpleName())); + } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/RecordClassBuilder.java b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/RecordClassBuilder.java index 3d19932b24..a49f379fd7 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/RecordClassBuilder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/RecordClassBuilder.java @@ -15,18 +15,18 @@ import com.github.javaparser.ast.type.Type; import org.jspecify.annotations.Nullable; -import javax.annotation.processing.Generated; - import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import static com.github.javaparser.ast.Modifier.DefaultKeyword.*; +import static de.uka.ilkd.key.java.transformations.AstFactory.*; /// This transformation is made to transform any found [RecordDeclaration] into a corresponding /// [ClassOrInterfaceDeclaration]. -/// @see [Java SE 25](https://docs.oracle.com/en/java/javase/25/language/records.html) +/// /// @author weigl +/// @see [Java SE 25](https://docs.oracle.com/en/java/javase/25/language/records.html) /// @since 2026-03-11 public class RecordClassBuilder extends JavaTransformer { public RecordClassBuilder(TransformationPipelineServices pipelineServices) { @@ -45,12 +45,12 @@ private ClassOrInterfaceDeclaration transform(RecordDeclaration recordDeclaratio ClassOrInterfaceDeclaration clazz = new ClassOrInterfaceDeclaration(); clazz.setModifiers(recordDeclaration.getModifiers()); clazz.addModifier(FINAL); - if(clazz.isNestedType() || clazz.isLocalClassDeclaration()) { + if (clazz.isNestedType() || clazz.isLocalClassDeclaration()) { clazz.addModifier(STATIC); // do not have a pointer to the outer this. } clazz.setName(recordDeclaration.getName()); clazz.addExtendedType(java.lang.Record.class); - clazz.addSingleMemberAnnotation(Generated.class, getClass().getName()); + addGenerated(clazz); services.attachTypeSpec(clazz, equalFieldsEqualRecords(recordDeclaration)); @@ -58,11 +58,11 @@ private ClassOrInterfaceDeclaration transform(RecordDeclaration recordDeclaratio for (Parameter parameter : recordDeclaration.getParameters()) { FieldDeclaration field = clazz.addField(parameter.type(), parameter.getNameAsString(), PRIVATE, FINAL); field.getModifiers().addAll(parameter.getModifiers()); - field.addSingleMemberAnnotation(Generated.class, getClass().getName()); + addGenerated(field); // only create a getter public final () { return ;} // unless there is no declaration in the record. - if(recordDeclaration.getMethodsByName(parameter.getNameAsString()).isEmpty()) { + if (recordDeclaration.getMethodsByName(parameter.getNameAsString()).isEmpty()) { MethodDeclaration getter = clazz.addMethod(parameter.getNameAsString()); getter.setType(parameter.type()); getter.addModifier(PUBLIC, FINAL); @@ -72,47 +72,48 @@ private ClassOrInterfaceDeclaration transform(RecordDeclaration recordDeclaratio } } getter.getBody().get().addStatement(new ReturnStmt(parameter.getNameAsExpression())); - getter.addSingleMemberAnnotation(Generated.class, getClass().getName()); + addGenerated(getter); } } - boolean hasNoEquals = recordDeclaration.getMethodsBySignature("equals", "java.lang.Object").isEmpty(); - boolean hasNoHashcode = recordDeclaration.getMethodsBySignature("hashCode").isEmpty(); - - if (hasNoEquals) { - MethodDeclaration equals = clazz.addMethod("hashCode", PUBLIC, FINAL); - equals.addAnnotation(Override.class); - equals.setType(Boolean.TYPE); - Type tObject = StaticJavaParser.parseType("java.lang.Object"); - equals.getParameters().add(new Parameter(tObject, "o")); - BlockStmt body = equals.getBody().get(); - body.addStatement(services.parseStatement("if(this == o) return true;")); - body.addStatement(services.parseStatement("if(!(o instanceof %s that)) return false;".formatted(clazz.getNameAsString()))); + createConstructor(recordDeclaration, clazz); - Expression equalFields = recordDeclaration.getParameters().stream() - .map(it -> callObjects("equals", it.getNameAsExpression(), - new FieldAccessExpr(new NameExpr("that"), it.getNameAsString()))) - .reduce((a, b) -> new BinaryExpr(a, b, BinaryExpr.Operator.AND)) - .orElse(new BooleanLiteralExpr(true)); - body.addStatement(new ReturnStmt(equalFields)); + createEquals(recordDeclaration, clazz); + createHashCode(recordDeclaration, clazz); + createToString(recordDeclaration, clazz); + clazz.getMembers().addAll(recordDeclaration.getMembers()); + return clazz; + } - body.addStatement(new ReturnStmt(new BooleanLiteralExpr(true))); - equals.addSingleMemberAnnotation(Generated.class, getClass().getName()); + private void createConstructor(RecordDeclaration recordDeclaration, ClassOrInterfaceDeclaration clazz) { + String[] paramTypes = recordDeclaration.getParameters().stream() + .map(it -> it.getType().asString()) + .toArray(String[]::new); + var optConstructor = recordDeclaration.getConstructorByParameterTypes(paramTypes); + ConstructorDeclaration fullConstructor; + if (optConstructor.isPresent()) { + fullConstructor = optConstructor.get(); + } else { + fullConstructor = new ConstructorDeclaration(); + fullConstructor.setName(recordDeclaration.getNameAsString()); + fullConstructor.setModifiers(PUBLIC); + addGenerated(fullConstructor); + var body = fullConstructor.getBody().get(); + for (var parameter : recordDeclaration.getParameters()) { + final var p = parameter.clone(); + fullConstructor.addParameter(p); + body.addStatement(assign(attributeThis(p.getNameAsString()), p.getNameAsExpression())); + } } - if (hasNoHashcode) { - MethodDeclaration hashCode = clazz.addMethod("hashCode", PUBLIC, FINAL); - hashCode.addAnnotation(Override.class); - hashCode.setType(Integer.TYPE); - List args = recordDeclaration.getParameters() - .stream().map(NodeWithSimpleName::getNameAsExpression) - .map(it -> (Expression) it) - .toList(); - final Expression call = callObjects("hash", args); - hashCode.getBody().get().addStatement(new ReturnStmt(call)); - hashCode.addSingleMemberAnnotation(Generated.class, getClass().getName()); + for (var compactConstructor : recordDeclaration.getCompactConstructors()) { + fullConstructor.getBody().get().getStatements().add(0, compactConstructor.getBody()); } + clazz.addMember(fullConstructor); + } + + private void createToString(RecordDeclaration recordDeclaration, ClassOrInterfaceDeclaration clazz) { boolean hasNoToString = recordDeclaration.getMethodsBySignature("toString").isEmpty(); if (hasNoToString) { MethodDeclaration toString = clazz.addMethod("toString", PUBLIC, FINAL, JML_NON_NULL); @@ -125,21 +126,65 @@ private ClassOrInterfaceDeclaration transform(RecordDeclaration recordDeclaratio Parameter parameter = parameters.get(i); concatBuilder.addStr(parameter.getNameAsString() + "="); concatBuilder.addVar(parameter.getNameAsString()); - if(i < parameters.size() - 1) { + if (i < parameters.size() - 1) { concatBuilder.addStr(","); } } concatBuilder.addStr("]"); toString.getBody().get().addStatement(new ReturnStmt(concatBuilder.expr)); - toString.addSingleMemberAnnotation(Generated.class, getClass().getName()); + addGenerated(toString); } + } - clazz.getMembers().addAll(recordDeclaration.getMembers()); - return clazz; + private void createHashCode(RecordDeclaration recordDeclaration, ClassOrInterfaceDeclaration clazz) { + boolean hasNoHashcode = recordDeclaration.getMethodsBySignature("hashCode").isEmpty(); + if (hasNoHashcode) { + MethodDeclaration hashCode = clazz.addMethod("hashCode", PUBLIC, FINAL); + hashCode.addAnnotation(Override.class); + hashCode.setType(Integer.TYPE); + List args = recordDeclaration.getParameters() + .stream().map(NodeWithSimpleName::getNameAsExpression) + .map(it -> (Expression) it) + .toList(); + final Expression call = callObjects("hash", args); + hashCode.getBody().get().addStatement(new ReturnStmt(call)); + addGenerated(hashCode); + } + } + + private void createEquals(RecordDeclaration recordDeclaration, ClassOrInterfaceDeclaration clazz) { + boolean hasNoEquals = recordDeclaration.getMethodsBySignature("equals", "java.lang.Object").isEmpty() + && recordDeclaration.getMethodsBySignature("equals", "Object").isEmpty(); + if (hasNoEquals) { + MethodDeclaration equals = clazz.addMethod("equals", PUBLIC, FINAL); + equals.addAnnotation(Override.class); + equals.setType(Boolean.TYPE); + Type tObject = StaticJavaParser.parseType("java.lang.Object"); + equals.getParameters().add(new Parameter(tObject, "o")); + BlockStmt body = equals.getBody().get(); + body.addStatement( + mark(services.parseStatement("if(this == o) return true;"))); + body.addStatement( + mark(services.parseStatement("if(!(o instanceof %s)) return false;".formatted(clazz.getNameAsString())))); + + body.addStatement( + mark(services.parseStatement("final %s that = (%s) o;" + .formatted(clazz.getNameAsString(), clazz.getNameAsString())))); + + Expression equalFields = recordDeclaration.getParameters().stream() + .map(it -> callObjects("equals", it.getNameAsExpression(), + new FieldAccessExpr(new NameExpr("that"), it.getNameAsString()))) + .reduce((a, b) -> new BinaryExpr(a, b, BinaryExpr.Operator.AND)) + .orElse(new BooleanLiteralExpr(true)); + body.addStatement(mark(new ReturnStmt(equalFields))); + + body.addStatement(mark(new ReturnStmt(new BooleanLiteralExpr(true)))); + addGenerated(equals); + } } private static @Nullable String equalFieldsEqualRecords(RecordDeclaration recordDeclaration) { - if(recordDeclaration.getParameters().isEmpty()) { + if (recordDeclaration.getParameters().isEmpty()) { return null; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/TransformationPipelineServices.java b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/TransformationPipelineServices.java index 7ecf80ca49..5daf6832c1 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/TransformationPipelineServices.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/TransformationPipelineServices.java @@ -86,6 +86,29 @@ static void addLoopSpec(Node nextMember, TextualJMLLoopSpec spec) { specList.add(spec); } + + public static List getLoopSpec(Node n) { + if (!n.containsData(JMLTransformer.KEY_LOOP_SPEC)) { + return Collections.emptyList(); + } + return n.getData(JMLTransformer.KEY_LOOP_SPEC); + } + + public static List getClassSpec(Node td) { + if (!td.containsData(JMLTransformer.KEY_CLASS_SPEC)) { + return Collections.emptyList(); + + } + return td.getData(JMLTransformer.KEY_CLASS_SPEC); + } + + public static List getSpec(Node n) { + if (!n.containsData(JMLTransformer.KEY_SPEC_CASE)) { + return Collections.emptyList(); + } + return n.getData(JMLTransformer.KEY_SPEC_CASE); + } + public void addWarning(PositionedString warning) { warnings.add(warning); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/init/ProblemInitializer.java b/key.core/src/main/java/de/uka/ilkd/key/proof/init/ProblemInitializer.java index cdd3c8653d..0c7cf54a79 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/init/ProblemInitializer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/init/ProblemInitializer.java @@ -271,7 +271,7 @@ private void readJava(EnvInput envInput, InitConfig initConfig) throws ProofInpu } catch (IOException e) { throw new ProofInputException("Failed to read file", e); } catch (BuildingExceptions e) { - throw new ProofInputException("Failed to parse file", e); + throw new ProofInputException("Failed to parse file: "+ javaPath, e); } } Path initialFile = envInput.getInitialFile(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/util/ExceptionTools.java b/key.core/src/main/java/de/uka/ilkd/key/util/ExceptionTools.java index 39c7bc8c85..88e38f0d97 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/util/ExceptionTools.java +++ b/key.core/src/main/java/de/uka/ilkd/key/util/ExceptionTools.java @@ -116,7 +116,7 @@ private static String getNiceMessageInternal(IntStream inputStream, * given Throwable can not be successfully converted to a URL and thus no Location can * be created */ - public static Location getLocation(@NonNull Throwable exc) + public static @Nullable Location getLocation(@NonNull Throwable exc) throws MalformedURLException { if (exc instanceof HasLocation) { return ((HasLocation) exc).getLocation(); diff --git a/key.core/src/test/java/KeyJavaPipelineTest.java b/key.core/src/test/java/KeyJavaPipelineTest.java index d808522aef..30a7fd8635 100644 --- a/key.core/src/test/java/KeyJavaPipelineTest.java +++ b/key.core/src/test/java/KeyJavaPipelineTest.java @@ -2,14 +2,13 @@ * KeY is licensed under the GNU General Public License Version 2 * SPDX-License-Identifier: GPL-2.0-only */ +import de.uka.ilkd.key.java.SpecialJavaPrinter; import com.github.javaparser.ParseResult; import com.github.javaparser.Problem; import com.github.javaparser.ast.CompilationUnit; import com.github.javaparser.printer.DefaultPrettyPrinter; -import com.github.javaparser.printer.DefaultPrettyPrinterVisitor; import com.github.javaparser.printer.Printer; import com.github.javaparser.printer.configuration.DefaultPrinterConfiguration; -import com.github.javaparser.printer.configuration.PrinterConfiguration; import com.google.common.truth.Truth; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.transformations.KeYJavaPipeline; @@ -54,7 +53,7 @@ public KeYJavaPipeline createPipelineTest(Path testFolder) throws IOException { js.parseSpecialClasses(); final var jp = js.getProgramFactory().createJavaParser(); - try (var files = Files.list(inputFolder);) { + try (var files = Files.list(inputFolder)) { var cu = new ArrayList(); files.forEach(it -> { try { @@ -132,7 +131,7 @@ private static class DebugOutputTransformer extends JavaTransformer { final Set alreadyWritten = new HashSet<>(); private static final Logger LOGGER = LoggerFactory.getLogger(DebugOutputTransformer.class); private final Printer myPrinter = new DefaultPrettyPrinter( - MyPrintVisitor::new, + SpecialJavaPrinter::new, new DefaultPrinterConfiguration()); @@ -159,9 +158,4 @@ public void apply(CompilationUnit unit) { } } - private static class MyPrintVisitor extends DefaultPrettyPrinterVisitor { - public MyPrintVisitor(PrinterConfiguration configuration) { - super(configuration); - } - } } diff --git a/key.ui/examples/Java/Records/src/Point.java b/key.ui/examples/Java/Records/src/Point.java new file mode 100644 index 0000000000..e919b55be5 --- /dev/null +++ b/key.ui/examples/Java/Records/src/Point.java @@ -0,0 +1,21 @@ +record Point3d(int x, int y, int z) {} + +public class Use { + /*@ normal_behavior ensures true; requires true; */ + public void m() { + Point3d p = new Point3d(1, 2, 3); + + //@ assert p.x() == 1; + //@ assert p.y() == 2; + //@ assert p.z() == 3; + + //@assert p.equals(p); + + Point3d q = new Point3d(p.x, p.y, p.z); + + //@assert p.equals(q); + + //@assert q.equals(p); + + } +} diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/IssueDialog.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/IssueDialog.java index 537e6a814c..ed74eb81c3 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/IssueDialog.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/IssueDialog.java @@ -22,6 +22,7 @@ import javax.swing.text.html.HTML; import javax.swing.text.html.HTMLDocument; +import de.uka.ilkd.key.axiom_abstraction.signanalysis.Pos; import de.uka.ilkd.key.gui.actions.EditSourceFileAction; import de.uka.ilkd.key.gui.actions.SendFeedbackAction; import de.uka.ilkd.key.gui.configuration.Config; @@ -32,13 +33,17 @@ import de.uka.ilkd.key.gui.utilities.GuiUtilities; import de.uka.ilkd.key.gui.utilities.SquigglyUnderlinePainter; import de.uka.ilkd.key.java.Position; +import de.uka.ilkd.key.java.loader.JavaBuildingExceptions; +import de.uka.ilkd.key.java.loader.JavaBuildingIssue; import de.uka.ilkd.key.parser.Location; import de.uka.ilkd.key.pp.LogicPrinter; import de.uka.ilkd.key.speclang.PositionedString; import de.uka.ilkd.key.speclang.SLEnvInput; import de.uka.ilkd.key.util.ExceptionTools; +import de.uka.ilkd.key.util.parsing.BuildingException; import de.uka.ilkd.key.util.parsing.BuildingExceptions; +import de.uka.ilkd.key.util.parsing.BuildingIssue; import org.key_project.util.collection.ImmutableSet; import org.key_project.util.java.IOUtil; import org.key_project.util.java.StringUtil; @@ -562,7 +567,7 @@ public static void showExceptionDialog(Window parent, Throwable exception) { // make sure UI is usable after any exception MainWindow.getInstance().getMediator().startInterface(true); - Set msg = Collections.singleton(extractMessage(exception)); + Set msg = extractMessage(exception); if (exception instanceof BuildingExceptions) { ((BuildingExceptions) exception).getErrors().forEach( it -> LOGGER.info("Error", it)); @@ -604,21 +609,36 @@ public static void showWarningsIfNecessary(Window parent, * @param exception the exception to extract the data from * @return a new PositionedIssueString created from the data */ - private static PositionedIssueString extractMessage(Throwable exception) { + private static Set extractMessage(Throwable exception) { + { // Search for a BuildingException(s) first. + var e = exception; + while (e != null) { + switch (e) { + case BuildingExceptions be -> { + return extractMessages(be); + } + case BuildingException b -> { + return extractMessage(b); + } + case JavaBuildingExceptions b -> { + return extractMessages(b); + } + default -> {} + } + e = e.getCause(); + } + } + try (StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw)) { exception.printStackTrace(pw); String message = exception.getMessage(); String info = sw.toString(); - if (exception instanceof ParseCancellationException) { - exception = exception.getCause(); - } - - if (exception instanceof InputMismatchException ime) { - message = ExceptionTools.getNiceMessage(ime); - } - if (exception instanceof NoViableAltException nvae) { - message = ExceptionTools.getNiceMessage(nvae); + switch (exception) { + case ParseCancellationException e -> exception = exception.getCause(); + case InputMismatchException ime -> message = ExceptionTools.getNiceMessage(ime); + case NoViableAltException nvae -> message = ExceptionTools.getNiceMessage(nvae); + default -> {} } // also add message of the cause to the string if available @@ -633,23 +653,47 @@ private static PositionedIssueString extractMessage(Throwable exception) { Position pos = Position.UNDEFINED; Location location = ExceptionTools.getLocation(exception); if (location != null) { - var loc = location; - if (!loc.getPosition().isNegative()) { - pos = loc.getPosition(); + if (!location.getPosition().isNegative()) { + pos = location.getPosition(); } - if (loc.getFileURI().isPresent()) { - resourceLocation = loc.getFileURI().get(); + if (location.getFileURI().isPresent()) { + resourceLocation = location.getFileURI().get(); } } - return new PositionedIssueString(message == null ? exception.toString() : message, - new Location(resourceLocation, pos), info); + return Collections.singleton(new PositionedIssueString(message == null ? exception.toString() : message, + new Location(resourceLocation, pos), info)); } catch (IOException e) { // We must not suppress the dialog here -> catch and print only to debug stream LOGGER.debug("Creating a Location failed for {}", exception, e); } - return new PositionedIssueString("Constructing the error message failed!"); + return Collections.singleton( + new PositionedIssueString("Constructing the error message failed!")); } + private static Set extractMessages(JavaBuildingExceptions e) { + return e.getIssues().stream().map(IssueDialog::extractMessage).collect(Collectors.toSet()); + } + + private static Set extractMessages(BuildingExceptions e) { + return e.getErrors().stream().map(IssueDialog::extractMessage).collect(Collectors.toSet()); + } + + private static PositionedIssueString extractMessage(BuildingIssue e) { + var ps = e.asPositionedString(); + return new PositionedIssueString(ps.text, ps.location, "", + e.isWarning()? PositionedIssueString.Kind.WARNING : PositionedIssueString.Kind.ERROR); + } + + private static PositionedIssueString extractMessage(JavaBuildingIssue e) { + return new PositionedIssueString(e.getMessage(), new Location(e.getPath(), e.getPosition()), + "", PositionedIssueString.Kind.ERROR); + } + + private static Set extractMessage(BuildingException e) { + return Collections.singleton(new PositionedIssueString(e.getMessage(), e.getLocation(), "", PositionedIssueString.Kind.ERROR)); + } + + private void accept() { if (!critical && chkIgnoreWarnings.isSelected()) { ignoredWarnings.addAll(warnings); From 95780e37f7319ba4e36b22f183747670d6af20a5 Mon Sep 17 00:00:00 2001 From: Alexander Weigl Date: Mon, 30 Mar 2026 20:42:57 +0200 Subject: [PATCH 6/8] more printing --- .../uka/ilkd/key/java/SpecialJavaPrinter.java | 27 ++++++++++++++----- .../pretranslation/TextualJMLSpecCase.java | 4 +++ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/SpecialJavaPrinter.java b/key.core/src/main/java/de/uka/ilkd/key/java/SpecialJavaPrinter.java index a05d07a707..101ceb3468 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/SpecialJavaPrinter.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/SpecialJavaPrinter.java @@ -22,7 +22,6 @@ import org.key_project.util.collection.ImmutableList; import java.util.List; -import java.util.Map; import java.util.stream.Collectors; /** @@ -86,25 +85,41 @@ private void print(List spec) { case TextualJMLClassAxiom c -> print(c.getModifiers(), c.getAxiom().first); case TextualJMLClassInv c -> print(c.getModifiers(), c.getInv()); case TextualJMLDepends c -> print(c.getModifiers(), c.getDepends()); - case TextualJMLFieldDecl c -> {} + case TextualJMLFieldDecl c -> { + } case TextualJMLInitially c -> print(c.getModifiers(), c.getInv().first); case TextualJMLMergePointDecl c -> print(c.getModifiers(), c.getMergeProc()); case TextualJMLMethodDecl c -> print(c.getModifiers(), c.getDecl()); case TextualJMLModifierList c -> print(c.getModifiers()); case TextualJMLRepresents c -> print(c.getModifiers(), c.getRepresents().first); case TextualJMLSetStatement c -> print(c.getAssignment()); - case TextualJMLSpecCase c -> print(c); + case TextualJMLSpecCase c -> print(c.getModifiers(), c); default -> throw new IllegalStateException("Unexpected value: " + construct); } } } private void print(ImmutableList modifiers, ImmutableList depends) { - + printer.print("\n/*@ "); + print(modifiers); + printer.print(" "); + depends.forEach(it -> print(it.first)); + printer.print("*/\n"); + } + + private void print(ImmutableList modifiers, TextualJMLSpecCase specCase) { + printer.print("/*@ "); + print(modifiers); + printer.print(" "); + printer.print(specCase.getBehavior().toString()); + specCase.getClauses().forEach(it -> { + print(it); + printer.print("\n"); + } + ); + printer.print("\n*/"); } - private void print(TextualJMLSpecCase c) { - } private void print(ImmutableList modifiers, @Nullable ParserRuleContext first) { if (first == null) return; diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLSpecCase.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLSpecCase.java index f019303a95..be0993f15c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLSpecCase.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLSpecCase.java @@ -95,6 +95,10 @@ public ImmutableList getDecreases() { return getList(DECREASES); } + public Iterable getClauses() { + return clauses.stream().map(it -> it.ctx.first).collect(Collectors.toList()); + } + /** * Heap-independent clauses */ From ed131ae9db79cae35435104e59e0b08d0fcd7b29 Mon Sep 17 00:00:00 2001 From: Alexander Weigl Date: Wed, 1 Apr 2026 22:42:12 +0200 Subject: [PATCH 7/8] more of everything --- .../uka/ilkd/key/java/SpecialJavaPrinter.java | 212 ++++++++++-------- .../key/java/loader/JavaParserFactory.java | 1 - .../pipeline/JavaTransformer.java | 8 +- .../pipeline/RecordClassBuilder.java | 185 +++++++++++---- .../TransformationPipelineServices.java | 17 +- .../key/proof/init/ProblemInitializer.java | 2 +- .../pretranslation/TextualJMLLoopSpec.java | 5 + .../uka/ilkd/key/speclang/njml/PreParser.java | 15 +- .../de/uka/ilkd/key/proof/rules/javaRules.key | 18 ++ .../src/test/java/KeyJavaPipelineTest.java | 44 ++-- .../java/de/uka/ilkd/key/gui/IssueDialog.java | 25 ++- 11 files changed, 350 insertions(+), 182 deletions(-) diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/SpecialJavaPrinter.java b/key.core/src/main/java/de/uka/ilkd/key/java/SpecialJavaPrinter.java index 101ceb3468..c81003c71c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/SpecialJavaPrinter.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/SpecialJavaPrinter.java @@ -1,5 +1,19 @@ +/* This file is part of KeY - https://key-project.org + * KeY is licensed under the GNU General Public License Version 2 + * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.java; +import java.util.List; +import java.util.stream.Collectors; + +import de.uka.ilkd.key.java.transformations.pipeline.TransformationPipelineServices; +import de.uka.ilkd.key.speclang.jml.pretranslation.*; +import de.uka.ilkd.key.speclang.njml.JmlParser; +import de.uka.ilkd.key.speclang.njml.JmlParserBaseVisitor; +import de.uka.ilkd.key.speclang.njml.LabeledParserRuleContext; + +import org.key_project.util.collection.ImmutableList; + import com.github.javaparser.ast.Modifier; import com.github.javaparser.ast.NodeList; import com.github.javaparser.ast.body.BodyDeclaration; @@ -8,21 +22,12 @@ import com.github.javaparser.printer.DefaultPrettyPrinterVisitor; import com.github.javaparser.printer.configuration.PrinterConfiguration; import com.google.common.base.Strings; -import de.uka.ilkd.key.java.transformations.pipeline.TransformationPipelineServices; -import de.uka.ilkd.key.speclang.jml.pretranslation.*; -import de.uka.ilkd.key.speclang.njml.JmlParser; -import de.uka.ilkd.key.speclang.njml.JmlParserBaseVisitor; -import de.uka.ilkd.key.speclang.njml.LabeledParserRuleContext; import org.antlr.v4.runtime.ParserRuleContext; import org.antlr.v4.runtime.Token; import org.antlr.v4.runtime.tree.ParseTree; import org.antlr.v4.runtime.tree.RuleNode; import org.antlr.v4.runtime.tree.TerminalNode; import org.jspecify.annotations.Nullable; -import org.key_project.util.collection.ImmutableList; - -import java.util.List; -import java.util.stream.Collectors; /** * @@ -99,7 +104,8 @@ private void print(List spec) { } } - private void print(ImmutableList modifiers, ImmutableList depends) { + private void print(ImmutableList modifiers, + ImmutableList depends) { printer.print("\n/*@ "); print(modifiers); printer.print(" "); @@ -113,16 +119,16 @@ private void print(ImmutableList modifiers, TextualJMLSpecCase spec printer.print(" "); printer.print(specCase.getBehavior().toString()); specCase.getClauses().forEach(it -> { - print(it); - printer.print("\n"); - } - ); + print(it); + printer.print("\n"); + }); printer.print("\n*/"); } private void print(ImmutableList modifiers, @Nullable ParserRuleContext first) { - if (first == null) return; + if (first == null) + return; var text = first.accept(new ToStringVisitor()); if (text.contains("\n")) { printer.print("/*@ "); @@ -143,7 +149,8 @@ private void print(ImmutableList modifiers) { } private void print(@Nullable ParserRuleContext first) { - if (first == null) return; + if (first == null) + return; var text = first.accept(new ToStringVisitor()); if (text.contains("\n")) { printer.print("/*@ "); @@ -156,38 +163,48 @@ private void print(@Nullable ParserRuleContext first) { } private void print(TextualJMLAssertStatement c) { - + printer.print("//@ assert " + c.getContext().accept(new ToStringVisitor()) + ";\n"); } - private void print(TextualJMLLoopSpec c) { - + private void print(TextualJMLLoopSpec specCase) { + printer.print("/*@ "); + print(specCase.getModifiers()); + printer.print(" "); + specCase.getClauses().forEach(it -> { + print(it); + printer.print("\n"); + }); + printer.print("\n*/"); } } class ToStringVisitor extends JmlParserBaseVisitor { public String accept(@Nullable ParseTree c) { - if (c == null) return ""; + if (c == null) + return ""; return c.accept(this); } public String accept(String prefix, @Nullable ParseTree c) { - if (c == null) return ""; + if (c == null) + return ""; return prefix + c.accept(this); } public String accept(@Nullable ParseTree c, String suffix) { - if (c == null) return ""; + if (c == null) + return ""; return c.accept(this) + suffix; } @Override public String visitAccessible_clause(JmlParser.Accessible_clauseContext ctx) { return "accessible " + accept(ctx.targetHeap()) - + accept(ctx.lhs, ":") - + accept(ctx.rhs) - + accept(" \\measured_by ", ctx.mby) - + ";"; + + accept(ctx.lhs, ":") + + accept(ctx.rhs) + + accept(" \\measured_by ", ctx.mby) + + ";"; } @Override @@ -228,9 +245,9 @@ public String visitAssert_statement(JmlParser.Assert_statementContext ctx) { @Override public String visitAssignable_clause(JmlParser.Assignable_clauseContext ctx) { return "assignable " + accept(ctx.targetHeap()) - + accept(ctx.storeRefUnion()) - + accept(ctx.STRICTLY_NOTHING()) - + ";"; + + accept(ctx.storeRefUnion()) + + accept(ctx.STRICTLY_NOTHING()) + + ";"; } private String accept(TerminalNode terminalNode) { @@ -277,9 +294,9 @@ public String visitBreaks_clause(JmlParser.Breaks_clauseContext ctx) { @Override public String visitBsumterm(JmlParser.BsumtermContext ctx) { return "(\\bsum " - + accept(ctx.quantifiedvardecls()) + "; " - + accept(ctx.expression(), "; ") - + ")"; + + accept(ctx.quantifiedvardecls()) + "; " + + accept(ctx.expression(), "; ") + + ")"; } @Override @@ -290,8 +307,8 @@ public String visitBuiltintype(JmlParser.BuiltintypeContext ctx) { @Override public String visitCaptures_clause(JmlParser.Captures_clauseContext ctx) { return "captures " - + accept(ctx.predornot()) - + ";"; + + accept(ctx.predornot()) + + ";"; } @Override @@ -327,9 +344,10 @@ public String visitClauseEOF(JmlParser.ClauseEOFContext ctx) { @Override public String visitConditionalexpr(JmlParser.ConditionalexprContext ctx) { return accept(ctx.equivalenceexpr()) - + (ctx.QUESTIONMARK() != null ? - accept("? ", ctx.conditionalexpr(0)) + accept(" : ", ctx.conditionalexpr(1)) - : ""); + + (ctx.QUESTIONMARK() != null + ? accept("? ", ctx.conditionalexpr(0)) + + accept(" : ", ctx.conditionalexpr(1)) + : ""); } @Override @@ -370,32 +388,32 @@ public String visitDims(JmlParser.DimsContext ctx) { @Override public String visitDiverges_clause(JmlParser.Diverges_clauseContext ctx) { return "captures " - + accept(ctx.predornot()) - + ";"; + + accept(ctx.predornot()) + + ";"; } @Override public String visitDuration_clause(JmlParser.Duration_clauseContext ctx) { return "duration " - + accept(ctx.predornot()) - + ";"; + + accept(ctx.predornot()) + + ";"; } @Override public String visitEnsures_clause(JmlParser.Ensures_clauseContext ctx) { return "ensures " + accept(ctx.targetHeap()) - + accept(ctx.predornot()) - + ";"; + + accept(ctx.predornot()) + + ";"; } @Override public String visitEqualityexpr(JmlParser.EqualityexprContext ctx) { - return accept(ctx.relationalexpr(), " == "); //TODO + return accept(ctx.relationalexpr(), " == "); // TODO } @Override public String visitEquivalenceexpr(JmlParser.EquivalenceexprContext ctx) { - return accept(ctx.impliesexpr(), "<==>"); //TODO + return accept(ctx.impliesexpr(), "<==>"); // TODO } @Override @@ -521,8 +539,8 @@ public String visitInv_free(JmlParser.Inv_freeContext ctx) { @Override public String visitJava_math_expression(JmlParser.Java_math_expressionContext ctx) { return "\\java_math(" - + accept(ctx.expression()) - + ")"; + + accept(ctx.expression()) + + ")"; } @Override @@ -603,8 +621,8 @@ public String visitMbody_var(JmlParser.Mbody_varContext ctx) { @Override public String visitMeasured_by_clause(JmlParser.Measured_by_clauseContext ctx) { return "measured_by " - + accept(ctx.predornot(), ", ") - + ";"; + + accept(ctx.predornot(), ", ") + + ";"; } private String accept(List ctxs, String s) { @@ -774,13 +792,15 @@ public String visitPrimaryBackup(JmlParser.PrimaryBackupContext ctx) { } @Override - public String visitPrimaryBigintMathExpression(JmlParser.PrimaryBigintMathExpressionContext ctx) { + public String visitPrimaryBigintMathExpression( + JmlParser.PrimaryBigintMathExpressionContext ctx) { return accept(ctx.bigint_math_expression()); } @Override - public String visitPrimaryCreateLocsetSingleton(JmlParser.PrimaryCreateLocsetSingletonContext ctx) { + public String visitPrimaryCreateLocsetSingleton( + JmlParser.PrimaryCreateLocsetSingletonContext ctx) { return super.visitPrimaryCreateLocsetSingleton(ctx); } @@ -812,19 +832,22 @@ public String visitPrimaryException(JmlParser.PrimaryExceptionContext ctx) { @Override public String visitPrimaryexpr(JmlParser.PrimaryexprContext ctx) { return oneOf(ctx.constant(), - ctx.ident(), ctx.inv(), ctx.inv_free(), ctx.true_(), ctx.false_(), ctx.null_(), ctx.jmlprimary(), ctx.new_expr(), ctx.array_initializer()); + ctx.ident(), ctx.inv(), ctx.inv_free(), ctx.true_(), ctx.false_(), ctx.null_(), + ctx.jmlprimary(), ctx.new_expr(), ctx.array_initializer()); } private String oneOf(ParseTree... ctxs) { for (var ctx : ctxs) { - if (ctx != null) return accept(ctx); + if (ctx != null) + return accept(ctx); } return ""; } private String oneOf(TerminalNode... ctxs) { for (var ctx : ctxs) { - if (ctx != null) return accept(ctx); + if (ctx != null) + return accept(ctx); } return ""; } @@ -991,8 +1014,9 @@ public String visitPrimarySubset(JmlParser.PrimarySubsetContext ctx) { @Override public String visitPrimarySuffixAccess(JmlParser.PrimarySuffixAccessContext ctx) { - return "." + oneOf(ctx.IDENT(), ctx.TRANSIENT(), ctx.THIS(), ctx.INV(), ctx.INV_FREE(), ctx.MULT()) - + (ctx.LPAREN() != null ? "(" + accept(ctx.expressionlist(), ", ") + ")" : ""); + return "." + + oneOf(ctx.IDENT(), ctx.TRANSIENT(), ctx.THIS(), ctx.INV(), ctx.INV_FREE(), ctx.MULT()) + + (ctx.LPAREN() != null ? "(" + accept(ctx.expressionlist(), ", ") + ")" : ""); } @Override @@ -1042,7 +1066,8 @@ public String visitQuantifiedvardecls(JmlParser.QuantifiedvardeclsContext ctx) { } @Override - public String visitQuantifiedvariabledeclarator(JmlParser.QuantifiedvariabledeclaratorContext ctx) { + public String visitQuantifiedvariabledeclarator( + JmlParser.QuantifiedvariabledeclaratorContext ctx) { return accept(ctx.IDENT()) + accept(ctx.dims()); } @@ -1083,18 +1108,18 @@ public String visitRelationalexpr(JmlParser.RelationalexprContext ctx) { @Override public String visitRepresents_clause(JmlParser.Represents_clauseContext ctx) { return "represents " + accept(ctx.lhs) - + "=" - + accept(ctx.rhs) - + accept(ctx.storeRefUnion()) - + accept("\\such_that", ctx.predicate()) - + ";"; + + "=" + + accept(ctx.rhs) + + accept(ctx.storeRefUnion()) + + accept("\\such_that", ctx.predicate()) + + ";"; } @Override public String visitRequires_clause(JmlParser.Requires_clauseContext ctx) { return "requires " + accept(ctx.targetHeap()) - + accept(ctx.predornot()) - + ";"; + + accept(ctx.predornot()) + + ";"; } @Override @@ -1105,17 +1130,17 @@ public String visitReturns_clause(JmlParser.Returns_clauseContext ctx) { @Override public String visitSafe_math_expression(JmlParser.Safe_math_expressionContext ctx) { return "\\safe_math(" - + accept(ctx.expression()) - + ")"; + + accept(ctx.expression()) + + ")"; } @Override public String visitSeparates_clause(JmlParser.Separates_clauseContext ctx) { return "separates " + accept(ctx.sep) - + accept("\n \\declassifies", ctx.decl, ", ") - + accept("\n \\erases", ctx.decl, ", ") - + accept("\n \\new_objects", ctx.decl, ", ") - + ";"; + + accept("\n \\declassifies", ctx.decl, ", ") + + accept("\n \\erases", ctx.decl, ", ") + + accept("\n \\new_objects", ctx.decl, ", ") + + ";"; } private String accept(String prefix, List ctxs, String delimiter) { @@ -1128,9 +1153,9 @@ private String accept(String prefix, List ctxs, String deli @Override public String visitSeqdefterm(JmlParser.SeqdeftermContext ctx) { return "(\\seqdef " - + accept(ctx.quantifiedvardecls()) + "; " - + accept(ctx.expression(), "; ") - + ")"; + + accept(ctx.quantifiedvardecls()) + "; " + + accept(ctx.expression(), "; ") + + ")"; } @Override @@ -1205,7 +1230,9 @@ protected String aggregateResult(String aggregate, String nextResult) { @Override public String visitSignals_only_clause(JmlParser.Signals_only_clauseContext ctx) { - return super.visitSignals_only_clause(ctx); + return accept(ctx.SIGNALS_ONLY()) + " " + + accept(ctx.referencetype(), ", ") + + ";"; } @Override @@ -1221,19 +1248,19 @@ public String visitSpec_case(JmlParser.Spec_caseContext ctx) { @Override public String visitSpecquantifiedexpression(JmlParser.SpecquantifiedexpressionContext ctx) { return "(" + - accept(ctx.quantifier()) + " " - + accept(ctx.boundvarmodifiers()) - + accept(ctx.quantifiedvardecls()) + "; " - + accept(ctx.expression(), "; ") - + ")"; + accept(ctx.quantifier()) + " " + + accept(ctx.boundvarmodifiers()) + + accept(ctx.quantifiedvardecls()) + "; " + + accept(ctx.expression(), "; ") + + ")"; } @Override public String visitSt_expr(JmlParser.St_exprContext ctx) { return accept(ctx.shiftexpr(0)) - + " <: " - + accept(ctx.shiftexpr(1)); + + " <: " + + accept(ctx.shiftexpr(1)); } @Override @@ -1263,27 +1290,28 @@ public String visitStoreRefUnion(JmlParser.StoreRefUnionContext ctx) { @Override public String visitStringliteral(JmlParser.StringliteralContext ctx) { - return super.visitStringliteral(ctx); + return ctx.getText(); } @Override public String visitTargetHeap(JmlParser.TargetHeapContext ctx) { - return super.visitTargetHeap(ctx); + return ctx.SPECIAL_IDENT().stream().map(it -> "<%s>".formatted(it.getSymbol().getText())) + .collect(Collectors.joining()); } @Override public String visitTermexpression(JmlParser.TermexpressionContext ctx) { - return super.visitTermexpression(ctx); + return accept(ctx.expression()); } @Override public String visitThis_(JmlParser.This_Context ctx) { - return super.visitThis_(ctx); + return "this"; } @Override public String visitTransactionUpdated(JmlParser.TransactionUpdatedContext ctx) { - return super.visitTransactionUpdated(ctx); + return ctx.getText(); } @Override @@ -1330,19 +1358,21 @@ public String visitVariant_function(JmlParser.Variant_functionContext ctx) { @Override public String visitWhen_clause(JmlParser.When_clauseContext ctx) { return "when " - + accept(ctx.predornot()) - + ";"; + + accept(ctx.predornot()) + + ";"; } @Override public String visitWorking_space_clause(JmlParser.Working_space_clauseContext ctx) { return "working_space " - + accept(ctx.predornot()) - + ";"; + + accept(ctx.predornot()) + + ";"; } @Override public String visitWritable_if_clause(JmlParser.Writable_if_clauseContext ctx) { - return super.visitWritable_if_clause(ctx); + return "writeable_if " + + accept(ctx.expression()) + + ";"; } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/loader/JavaParserFactory.java b/key.core/src/main/java/de/uka/ilkd/key/java/loader/JavaParserFactory.java index 09e540a9a3..a47df45f6f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/loader/JavaParserFactory.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/loader/JavaParserFactory.java @@ -28,7 +28,6 @@ import com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/JavaTransformer.java b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/JavaTransformer.java index 5e78846910..83bd948105 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/JavaTransformer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/JavaTransformer.java @@ -4,6 +4,8 @@ package de.uka.ilkd.key.java.transformations.pipeline; +import javax.annotation.processing.Generated; + import com.github.javaparser.ast.CompilationUnit; import com.github.javaparser.ast.Node; import com.github.javaparser.ast.body.TypeDeclaration; @@ -11,8 +13,6 @@ import com.github.javaparser.ast.nodeTypes.NodeWithAnnotations; import org.jspecify.annotations.NullMarked; -import javax.annotation.processing.Generated; - /** * The JavaDL requires some implicit fields, that are available in each * Java class. The name of the implicit fields starts usually with a dollar sign. @@ -90,7 +90,7 @@ public static RuntimeException reportError(Node node, String message, Object... protected void addGenerated(NodeWithAnnotations node) { node.addSingleMemberAnnotation( - Generated.class.getName(), - new StringLiteralExpr(this.getClass().getSimpleName())); + Generated.class.getName(), + new StringLiteralExpr(this.getClass().getSimpleName())); } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/RecordClassBuilder.java b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/RecordClassBuilder.java index a49f379fd7..915cbdee9a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/RecordClassBuilder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/RecordClassBuilder.java @@ -3,24 +3,26 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.java.transformations.pipeline; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + import com.github.javaparser.StaticJavaParser; import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.Modifier; import com.github.javaparser.ast.NodeList; import com.github.javaparser.ast.body.*; import com.github.javaparser.ast.expr.*; import com.github.javaparser.ast.key.JmlDocModifier; import com.github.javaparser.ast.nodeTypes.NodeWithSimpleName; -import com.github.javaparser.ast.stmt.BlockStmt; import com.github.javaparser.ast.stmt.ReturnStmt; +import com.github.javaparser.ast.type.PrimitiveType; import com.github.javaparser.ast.type.Type; import org.jspecify.annotations.Nullable; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - import static com.github.javaparser.ast.Modifier.DefaultKeyword.*; -import static de.uka.ilkd.key.java.transformations.AstFactory.*; +import static de.uka.ilkd.key.java.transformations.AstFactory.assign; +import static de.uka.ilkd.key.java.transformations.AstFactory.attributeThis; /// This transformation is made to transform any found [RecordDeclaration] into a corresponding /// [ClassOrInterfaceDeclaration]. @@ -52,11 +54,9 @@ private ClassOrInterfaceDeclaration transform(RecordDeclaration recordDeclaratio clazz.addExtendedType(java.lang.Record.class); addGenerated(clazz); - services.attachTypeSpec(clazz, - equalFieldsEqualRecords(recordDeclaration)); - for (Parameter parameter : recordDeclaration.getParameters()) { - FieldDeclaration field = clazz.addField(parameter.type(), parameter.getNameAsString(), PRIVATE, FINAL); + FieldDeclaration field = + clazz.addField(parameter.type(), parameter.getNameAsString(), PRIVATE, FINAL); field.getModifiers().addAll(parameter.getModifiers()); addGenerated(field); @@ -71,21 +71,50 @@ private ClassOrInterfaceDeclaration transform(RecordDeclaration recordDeclaratio getter.getModifiers().add(mod.clone()); } } - getter.getBody().get().addStatement(new ReturnStmt(parameter.getNameAsExpression())); + getter.getBody().get() + .addStatement(new ReturnStmt(parameter.getNameAsExpression())); addGenerated(getter); } } createConstructor(recordDeclaration, clazz); - createEquals(recordDeclaration, clazz); - createHashCode(recordDeclaration, clazz); + var generated = + createEquals(recordDeclaration, clazz) && createHashCode(recordDeclaration, clazz); + + if (generated) { + services.attachTypeSpec(clazz, + equalFieldsEqualRecords(recordDeclaration)); + + services.attachTypeSpec(clazz, + "public static invariant_free (\\forall %s a; a.equals(a));" + .formatted(recordDeclaration.getNameAsString())); + + services.attachTypeSpec(clazz, + "public static invariant_free (\\forall %s a,b; a.equals(b); b.equals(a));" + .formatted(recordDeclaration.getNameAsString())); + + services.attachTypeSpec(clazz, + "public static invariant_free (\\forall %s a,b,c; a.equals(b) && b.equals(c); a.equals(c));" + .formatted(recordDeclaration.getNameAsString())); + + services.attachTypeSpec(clazz, + "public static invariant_free (\\forall %s a,b; a.equals(b); a.hashCode() == b.hashCode());" + .formatted(recordDeclaration.getNameAsString())); + + services.attachTypeSpec(clazz, + "public static invariant_free (\\forall %s a,b; a.hashCode() != b.hashCode(); !a.equals(b));" + .formatted(recordDeclaration.getNameAsString())); + } + createToString(recordDeclaration, clazz); + clazz.getMembers().addAll(recordDeclaration.getMembers()); return clazz; } - private void createConstructor(RecordDeclaration recordDeclaration, ClassOrInterfaceDeclaration clazz) { + private void createConstructor(RecordDeclaration recordDeclaration, + ClassOrInterfaceDeclaration clazz) { String[] paramTypes = recordDeclaration.getParameters().stream() .map(it -> it.getType().asString()) .toArray(String[]::new); @@ -102,8 +131,21 @@ private void createConstructor(RecordDeclaration recordDeclaration, ClassOrInter for (var parameter : recordDeclaration.getParameters()) { final var p = parameter.clone(); fullConstructor.addParameter(p); - body.addStatement(assign(attributeThis(p.getNameAsString()), p.getNameAsExpression())); + body.addStatement( + assign(attributeThis(p.getNameAsString()), p.getNameAsExpression())); } + + var fieldParamEqual = recordDeclaration.getParameters() + .stream() + .map(NodeWithSimpleName::getNameAsString) + .map(it -> "ensures this.%s == %s;".formatted(it, it)) + .collect(Collectors.joining("\n")); + services.attachSpec(fullConstructor, """ + public normal_behavior + requires true; + %s + """.formatted(fieldParamEqual)); + } for (var compactConstructor : recordDeclaration.getCompactConstructors()) { @@ -113,7 +155,8 @@ private void createConstructor(RecordDeclaration recordDeclaration, ClassOrInter clazz.addMember(fullConstructor); } - private void createToString(RecordDeclaration recordDeclaration, ClassOrInterfaceDeclaration clazz) { + private void createToString(RecordDeclaration recordDeclaration, + ClassOrInterfaceDeclaration clazz) { boolean hasNoToString = recordDeclaration.getMethodsBySignature("toString").isEmpty(); if (hasNoToString) { MethodDeclaration toString = clazz.addMethod("toString", PUBLIC, FINAL, JML_NON_NULL); @@ -136,7 +179,8 @@ private void createToString(RecordDeclaration recordDeclaration, ClassOrInterfac } } - private void createHashCode(RecordDeclaration recordDeclaration, ClassOrInterfaceDeclaration clazz) { + private boolean createHashCode(RecordDeclaration recordDeclaration, + ClassOrInterfaceDeclaration clazz) { boolean hasNoHashcode = recordDeclaration.getMethodsBySignature("hashCode").isEmpty(); if (hasNoHashcode) { MethodDeclaration hashCode = clazz.addMethod("hashCode", PUBLIC, FINAL); @@ -147,40 +191,91 @@ private void createHashCode(RecordDeclaration recordDeclaration, ClassOrInterfac .map(it -> (Expression) it) .toList(); final Expression call = callObjects("hash", args); - hashCode.getBody().get().addStatement(new ReturnStmt(call)); + // hashCode.getBody().get().addStatement(new ReturnStmt(call)); + hashCode.setBody(null); addGenerated(hashCode); + + services.attachSpec(hashCode, """ + public normal_behavior + ensures true; requires true; + assignable \\strictly_nothing; + """); } + return hasNoHashcode; } - private void createEquals(RecordDeclaration recordDeclaration, ClassOrInterfaceDeclaration clazz) { - boolean hasNoEquals = recordDeclaration.getMethodsBySignature("equals", "java.lang.Object").isEmpty() - && recordDeclaration.getMethodsBySignature("equals", "Object").isEmpty(); + private boolean createEquals(RecordDeclaration recordDeclaration, + ClassOrInterfaceDeclaration clazz) { + boolean hasNoEquals = + recordDeclaration.getMethodsBySignature("equals", "java.lang.Object").isEmpty() + && recordDeclaration.getMethodsBySignature("equals", "Object").isEmpty(); if (hasNoEquals) { MethodDeclaration equals = clazz.addMethod("equals", PUBLIC, FINAL); equals.addAnnotation(Override.class); equals.setType(Boolean.TYPE); Type tObject = StaticJavaParser.parseType("java.lang.Object"); - equals.getParameters().add(new Parameter(tObject, "o")); - BlockStmt body = equals.getBody().get(); - body.addStatement( - mark(services.parseStatement("if(this == o) return true;"))); - body.addStatement( - mark(services.parseStatement("if(!(o instanceof %s)) return false;".formatted(clazz.getNameAsString())))); - - body.addStatement( - mark(services.parseStatement("final %s that = (%s) o;" - .formatted(clazz.getNameAsString(), clazz.getNameAsString())))); - - Expression equalFields = recordDeclaration.getParameters().stream() - .map(it -> callObjects("equals", it.getNameAsExpression(), - new FieldAccessExpr(new NameExpr("that"), it.getNameAsString()))) - .reduce((a, b) -> new BinaryExpr(a, b, BinaryExpr.Operator.AND)) - .orElse(new BooleanLiteralExpr(true)); - body.addStatement(mark(new ReturnStmt(equalFields))); - - body.addStatement(mark(new ReturnStmt(new BooleanLiteralExpr(true)))); + var mods = new NodeList<>(new Modifier(JML_NULLABLE)); + equals.getParameters().add(new Parameter(mods, tObject, new SimpleName("o"))); + equals.setBody(null); + + + services.attachSpec(equals, """ + public normal_behavior + requires true; + ensures ( + (this == o) //equality of identity + || (o instanceof %s && o != null && %s) + || (o instanceof %s && o != null && %s) + ) <==> \\result; + ensures hashCode() != o.hashCode() ==> !\\result; + ensures o == null ==> !\\result; + assignable \\strictly_nothing; + """.formatted( + recordDeclaration.getNameAsString(), + recordDeclaration.getParameters().stream() + .map(NodeWithSimpleName::getNameAsString) + .map(it -> "this.%s==((%s)o).%s".formatted(it, + recordDeclaration.getNameAsString(), it)) + .collect(Collectors.joining(" && ")), + recordDeclaration.getNameAsString(), + recordDeclaration.getParameters().stream() + .map(it -> { + String pname = it.getNameAsString(); + if (it.getType() instanceof PrimitiveType) + return "(%s == ((%s)o).%s)".formatted(pname, + recordDeclaration.getNameAsString(), pname); + else + return "( this.%s != null ? (this.%s.equals(((%s)o).%s)) : (o.%s == null))" + .formatted(pname, pname, + recordDeclaration.getNameAsString(), pname, pname); + }) + .collect(Collectors.joining(" && ")))); + + /* + * Nobody only contract: + * BlockStmt body = equals.getBody().get(); + * body.addStatement( + * mark(services.parseStatement("if(this == o) return true;"))); + * body.addStatement( + * mark(services.parseStatement("if(!(o instanceof %s)) return false;".formatted(clazz. + * getNameAsString())))); + * + * body.addStatement( + * mark(services.parseStatement("final %s that = (%s) o;" + * .formatted(clazz.getNameAsString(), clazz.getNameAsString())))); + * + * Expression equalFields = recordDeclaration.getParameters().stream() + * .map(it -> callObjects("equals", it.getNameAsExpression(), + * new FieldAccessExpr(new NameExpr("that"), it.getNameAsString()))) + * .reduce((a, b) -> new BinaryExpr(a, b, BinaryExpr.Operator.AND)) + * .orElse(new BooleanLiteralExpr(true)); + * body.addStatement(mark(new ReturnStmt(equalFields))); + * + * body.addStatement(mark(new ReturnStmt(new BooleanLiteralExpr(true)))); + */ addGenerated(equals); } + return hasNoEquals; } private static @Nullable String equalFieldsEqualRecords(RecordDeclaration recordDeclaration) { @@ -193,10 +288,9 @@ private void createEquals(RecordDeclaration recordDeclaration, ClassOrInterfaceD .map(it -> "a.%s == b.%s".formatted(it, it)) .collect(Collectors.joining(" && ")); - return "public axiom (\\forall %s a,b; %s; a.equals(b));".formatted( - recordDeclaration.getNameAsString(), - identityOfFields - ); + return "public invariant_free (\\forall %s a,b; %s; a.equals(b));".formatted( + recordDeclaration.getNameAsString(), + identityOfFields); } private Expression callObjects(String method, Expression... exprs) { @@ -204,7 +298,8 @@ private Expression callObjects(String method, Expression... exprs) { } private Expression callObjects(String method, List exprs) { - var objects = new FieldAccessExpr(new FieldAccessExpr(new NameExpr("java"), "lang"), "Objects"); + var objects = + new FieldAccessExpr(new FieldAccessExpr(new NameExpr("java"), "lang"), "Objects"); return new MethodCallExpr(objects, method, new NodeList<>(exprs)); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/TransformationPipelineServices.java b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/TransformationPipelineServices.java index 5daf6832c1..6637822ff3 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/TransformationPipelineServices.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/TransformationPipelineServices.java @@ -10,11 +10,10 @@ import de.uka.ilkd.key.java.transformations.ConstantExpressionEvaluator; import de.uka.ilkd.key.java.transformations.EvaluationException; import de.uka.ilkd.key.speclang.PositionedString; - import de.uka.ilkd.key.speclang.jml.pretranslation.TextualJMLConstruct; import de.uka.ilkd.key.speclang.jml.pretranslation.TextualJMLLoopSpec; import de.uka.ilkd.key.speclang.njml.PreParser; -import org.jspecify.annotations.NonNull; + import org.key_project.util.collection.ImmutableList; import com.github.javaparser.JavaParser; @@ -32,6 +31,7 @@ import com.github.javaparser.resolution.model.SymbolReference; import com.github.javaparser.resolution.types.ResolvedReferenceType; import com.github.javaparser.resolution.types.ResolvedType; +import org.jspecify.annotations.NonNull; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; import org.slf4j.Logger; @@ -260,6 +260,7 @@ public List> getUsages( /// i = j + 5; /// } /// ``` + /// /// @param cd the TypeDeclaration of which the initializers have to be collected /// @return the list of copy assignments and method references realizing the initializers.` public NodeList getInitializers(ClassOrInterfaceDeclaration cd) { @@ -343,12 +344,22 @@ public Statement parseStatement(String code) { } public void attachTypeSpec(TypeDeclaration clazz, @Nullable String spec) { - if(spec==null) return; + if (spec == null) + return; PreParser pp = getPreParser(); ImmutableList specification = pp.parseClassLevel(spec); specification.forEach(it -> addClassSpec(clazz, it)); } + public void attachSpec(Node node, @Nullable String spec) { + if (spec == null) + return; + PreParser pp = getPreParser(); + ImmutableList specification = pp.parseClassLevel(spec); + specification.forEach(it -> addSpec(node, it)); + LOGGER.info("Generated specification {} for {}", spec, node); + } + /** * Cache of important data. This is done mainly for performance reasons. diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/init/ProblemInitializer.java b/key.core/src/main/java/de/uka/ilkd/key/proof/init/ProblemInitializer.java index 0c7cf54a79..5ccb57aa1a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/init/ProblemInitializer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/init/ProblemInitializer.java @@ -271,7 +271,7 @@ private void readJava(EnvInput envInput, InitConfig initConfig) throws ProofInpu } catch (IOException e) { throw new ProofInputException("Failed to read file", e); } catch (BuildingExceptions e) { - throw new ProofInputException("Failed to parse file: "+ javaPath, e); + throw new ProofInputException("Failed to parse file: " + javaPath, e); } } Path initialFile = envInput.getInitialFile(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLLoopSpec.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLLoopSpec.java index 5c1747d18d..fc5a4216e4 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLLoopSpec.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/pretranslation/TextualJMLLoopSpec.java @@ -13,6 +13,7 @@ import org.key_project.util.collection.ImmutableList; import org.key_project.util.collection.ImmutableSLList; +import org.antlr.v4.runtime.ParserRuleContext; import org.jspecify.annotations.Nullable; /** @@ -22,6 +23,10 @@ public final class TextualJMLLoopSpec extends TextualJMLConstruct { private LabeledParserRuleContext variant = null; private final ArrayList clauses = new ArrayList<>(16); + public Set getClauses() { + return clauses.stream().map(it -> it.ctx.first).collect(Collectors.toSet()); + } + /** * Heap-dependent clauses * Note that the name 'assignable' is kept here for legacy reasons. diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/PreParser.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/PreParser.java index ae9160ed76..3754a120cf 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/PreParser.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/PreParser.java @@ -6,6 +6,7 @@ import java.net.URI; import java.util.ArrayList; import java.util.List; +import java.util.function.Supplier; import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.parser.Location; @@ -30,10 +31,16 @@ public class PreParser { * Parses a JML constructs on class level, e.g., invariants and methods contracts, and returns a * parse tree. */ - public ImmutableList parseClassLevel(JmlLexer lexer) { + public ImmutableList parseClassLevel(JmlLexer lexer, + @Nullable Supplier lines) { JmlParser p = JmlFacade.createParser(lexer); JmlParser.Classlevel_commentsContext ctx = p.classlevel_comments(); - p.getErrorReporter().throwException(); + if (lines != null) { + p.getErrorReporter().throwException(lines); + } else { + p.getErrorReporter().throwException(); + } + jmlCheck(ctx); TextualTranslator translator = new TextualTranslator( ProofIndependentSettings.DEFAULT_INSTANCE.getTermLabelSettings().getUseOriginLabels()); @@ -62,7 +69,7 @@ private void jmlCheck(ParserRuleContext ctx) { * parse tree. */ public ImmutableList parseClassLevel(String content) { - return parseClassLevel(JmlFacade.createLexer(content)); + return parseClassLevel(JmlFacade.createLexer(content), () -> content.split("\n")); } /** @@ -106,7 +113,7 @@ public ImmutableList parseClassLevel(String concatenatedCom */ private ImmutableList parseClassLevel(PositionedString positionedString) { JmlLexer lexer = JmlFacade.createLexer(positionedString); - return parseClassLevel(lexer); + return parseClassLevel(lexer, () -> positionedString.getText().split("\n")); } /** diff --git a/key.core/src/main/resources/de/uka/ilkd/key/proof/rules/javaRules.key b/key.core/src/main/resources/de/uka/ilkd/key/proof/rules/javaRules.key index 92f0af37bd..97257fcb1b 100644 --- a/key.core/src/main/resources/de/uka/ilkd/key/proof/rules/javaRules.key +++ b/key.core/src/main/resources/de/uka/ilkd/key/proof/rules/javaRules.key @@ -433,6 +433,24 @@ \displayname "variableDeclaration" }; + /* + variableDeclarationNullable { + \find(\modality{#allmodal}{.. nullable #t #v0; ...}\endmodality (post)) + \replacewith(\modality{#allmodal}{.. ...}\endmodality (post)) + \addprogvars(#v0) + \heuristics(simplify_prog, simplify_prog_subset) + \displayname "variableDeclaration" + }; + + variableDeclarationNullableAssign { + \find(\modality{#allmodal}{.. nullable #t #v0 = #vi; ...}\endmodality (post)) + \replacewith(\modality{#allmodal}{.. nullable #t #v0; #v0 = #vi; ...}\endmodality (post)) + \heuristics(simplify_prog, simplify_prog_subset) + \displayname "ghostDeclaration" + }; + */ + + variableDeclarationGhostAssign { \find(\modality{#allmodal}{.. ghost #t #v0 = #vi; ...}\endmodality (post)) \replacewith(\modality{#allmodal}{.. ghost #t #v0; #v0 = #vi; ...}\endmodality (post)) diff --git a/key.core/src/test/java/KeyJavaPipelineTest.java b/key.core/src/test/java/KeyJavaPipelineTest.java index 30a7fd8635..f373b874b1 100644 --- a/key.core/src/test/java/KeyJavaPipelineTest.java +++ b/key.core/src/test/java/KeyJavaPipelineTest.java @@ -1,8 +1,24 @@ /* This file is part of KeY - https://key-project.org * KeY is licensed under the GNU General Public License Version 2 * SPDX-License-Identifier: GPL-2.0-only */ +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Stream; +import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.SpecialJavaPrinter; +import de.uka.ilkd.key.java.transformations.KeYJavaPipeline; +import de.uka.ilkd.key.java.transformations.pipeline.JavaTransformer; +import de.uka.ilkd.key.java.transformations.pipeline.TransformationPipelineServices; +import de.uka.ilkd.key.nparser.NamespaceBuilder; +import de.uka.ilkd.key.proof.init.JavaProfile; + import com.github.javaparser.ParseResult; import com.github.javaparser.Problem; import com.github.javaparser.ast.CompilationUnit; @@ -10,28 +26,12 @@ import com.github.javaparser.printer.Printer; import com.github.javaparser.printer.configuration.DefaultPrinterConfiguration; import com.google.common.truth.Truth; -import de.uka.ilkd.key.java.Services; -import de.uka.ilkd.key.java.transformations.KeYJavaPipeline; -import de.uka.ilkd.key.java.transformations.pipeline.JavaTransformer; -import de.uka.ilkd.key.java.transformations.pipeline.TransformationPipelineServices; -import de.uka.ilkd.key.nparser.NamespaceBuilder; -import de.uka.ilkd.key.proof.init.JavaProfile; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DynamicTest; import org.junit.jupiter.api.TestFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; -import java.util.stream.Stream; - import static org.junit.jupiter.api.Assertions.assertNotNull; /** @@ -71,15 +71,15 @@ public KeYJavaPipeline createPipelineTest(Path testFolder) throws IOException { } }); var tservices = - new TransformationPipelineServices(services.getJavaService().getProgramFactory(), - new TransformationPipelineServices.TransformerCache(cu)); + new TransformationPipelineServices(services.getJavaService().getProgramFactory(), + new TransformationPipelineServices.TransformerCache(cu)); var kjp = KeYJavaPipeline.createDefault(tservices); var kjp2 = new KeYJavaPipeline(tservices); var cnt = 0; for (JavaTransformer step : kjp.getSteps()) { kjp2.add(step); final var file = testFolder.resolve("actual").resolve( - String.format("%02d_%s", ++cnt, step.getClass().getSimpleName())); + String.format("%02d_%s", ++cnt, step.getClass().getSimpleName())); kjp2.add(new DebugOutputTransformer(file, tservices)); } return kjp2; @@ -111,7 +111,7 @@ private Stream generatePipelineTests(Path testFolder) throws IOExce return Files.walk(expected) .filter(Files::isRegularFile) .map(it -> DynamicTest.dynamicTest(it.toString(), - () -> checkEqualFile(it, expected, actual))); + () -> checkEqualFile(it, expected, actual))); } private void checkEqualFile(Path expectedFile, Path expectedFolder, Path actualFolder) @@ -131,8 +131,8 @@ private static class DebugOutputTransformer extends JavaTransformer { final Set alreadyWritten = new HashSet<>(); private static final Logger LOGGER = LoggerFactory.getLogger(DebugOutputTransformer.class); private final Printer myPrinter = new DefaultPrettyPrinter( - SpecialJavaPrinter::new, - new DefaultPrinterConfiguration()); + SpecialJavaPrinter::new, + new DefaultPrinterConfiguration()); public DebugOutputTransformer(Path s, TransformationPipelineServices services) { diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/IssueDialog.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/IssueDialog.java index ed74eb81c3..e7784b14dd 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/IssueDialog.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/IssueDialog.java @@ -22,7 +22,6 @@ import javax.swing.text.html.HTML; import javax.swing.text.html.HTMLDocument; -import de.uka.ilkd.key.axiom_abstraction.signanalysis.Pos; import de.uka.ilkd.key.gui.actions.EditSourceFileAction; import de.uka.ilkd.key.gui.actions.SendFeedbackAction; import de.uka.ilkd.key.gui.configuration.Config; @@ -42,8 +41,8 @@ import de.uka.ilkd.key.util.ExceptionTools; import de.uka.ilkd.key.util.parsing.BuildingException; import de.uka.ilkd.key.util.parsing.BuildingExceptions; - import de.uka.ilkd.key.util.parsing.BuildingIssue; + import org.key_project.util.collection.ImmutableSet; import org.key_project.util.java.IOUtil; import org.key_project.util.java.StringUtil; @@ -610,8 +609,8 @@ public static void showWarningsIfNecessary(Window parent, * @return a new PositionedIssueString created from the data */ private static Set extractMessage(Throwable exception) { - { // Search for a BuildingException(s) first. - var e = exception; + { // Search for a BuildingException(s) first. + var e = exception; while (e != null) { switch (e) { case BuildingExceptions be -> { @@ -623,7 +622,8 @@ private static Set extractMessage(Throwable exception) { case JavaBuildingExceptions b -> { return extractMessages(b); } - default -> {} + default -> { + } } e = e.getCause(); } @@ -638,7 +638,8 @@ private static Set extractMessage(Throwable exception) { case ParseCancellationException e -> exception = exception.getCause(); case InputMismatchException ime -> message = ExceptionTools.getNiceMessage(ime); case NoViableAltException nvae -> message = ExceptionTools.getNiceMessage(nvae); - default -> {} + default -> { + } } // also add message of the cause to the string if available @@ -660,14 +661,15 @@ private static Set extractMessage(Throwable exception) { resourceLocation = location.getFileURI().get(); } } - return Collections.singleton(new PositionedIssueString(message == null ? exception.toString() : message, + return Collections.singleton( + new PositionedIssueString(message == null ? exception.toString() : message, new Location(resourceLocation, pos), info)); } catch (IOException e) { // We must not suppress the dialog here -> catch and print only to debug stream LOGGER.debug("Creating a Location failed for {}", exception, e); } return Collections.singleton( - new PositionedIssueString("Constructing the error message failed!")); + new PositionedIssueString("Constructing the error message failed!")); } private static Set extractMessages(JavaBuildingExceptions e) { @@ -681,16 +683,17 @@ private static Set extractMessages(BuildingExceptions e) private static PositionedIssueString extractMessage(BuildingIssue e) { var ps = e.asPositionedString(); return new PositionedIssueString(ps.text, ps.location, "", - e.isWarning()? PositionedIssueString.Kind.WARNING : PositionedIssueString.Kind.ERROR); + e.isWarning() ? PositionedIssueString.Kind.WARNING : PositionedIssueString.Kind.ERROR); } private static PositionedIssueString extractMessage(JavaBuildingIssue e) { return new PositionedIssueString(e.getMessage(), new Location(e.getPath(), e.getPosition()), - "", PositionedIssueString.Kind.ERROR); + "", PositionedIssueString.Kind.ERROR); } private static Set extractMessage(BuildingException e) { - return Collections.singleton(new PositionedIssueString(e.getMessage(), e.getLocation(), "", PositionedIssueString.Kind.ERROR)); + return Collections.singleton(new PositionedIssueString(e.getMessage(), e.getLocation(), "", + PositionedIssueString.Kind.ERROR)); } From 41fe34a07583af0ed3cc300f486fb55a1dddbdf8 Mon Sep 17 00:00:00 2001 From: Alexander Weigl Date: Thu, 2 Apr 2026 09:44:52 +0200 Subject: [PATCH 8/8] assumption --- key.core/src/main/antlr4/JmlLexer.g4 | 1 + key.core/src/main/antlr4/JmlParser.g4 | 4 +- .../pipeline/RecordClassBuilder.java | 28 +++++----- .../TransformationPipelineServices.java | 53 +++++++++++-------- .../ilkd/key/speclang/njml/Translator.java | 16 +++++- 5 files changed, 65 insertions(+), 37 deletions(-) diff --git a/key.core/src/main/antlr4/JmlLexer.g4 b/key.core/src/main/antlr4/JmlLexer.g4 index 8b4eb5880c..fc7f144bd3 100644 --- a/key.core/src/main/antlr4/JmlLexer.g4 +++ b/key.core/src/main/antlr4/JmlLexer.g4 @@ -485,6 +485,7 @@ CHAR_LITERAL: fragment OCT_CHAR: (('0'|'1'|'2'|'3') OCTDIGIT OCTDIGIT) | (OCTDIGIT OCTDIGIT) | OCTDIGIT; +KEY_TERM : '`' ~([`])* '`'; STRING_LITERAL: '"' -> pushMode(string),more; E_WS: [ \t\n\r\u000c@]+ -> channel(HIDDEN), type(WS); INFORMAL_DESCRIPTION: '(*' ( '*' ~')' | ~'*' )* '*)'; diff --git a/key.core/src/main/antlr4/JmlParser.g4 b/key.core/src/main/antlr4/JmlParser.g4 index ca53956c31..174acbf433 100644 --- a/key.core/src/main/antlr4/JmlParser.g4 +++ b/key.core/src/main/antlr4/JmlParser.g4 @@ -376,6 +376,7 @@ jmlprimary | SUBSET LPAREN storeref COMMA storeref RPAREN #primarySubset | NEWELEMSFRESH LPAREN storeref RPAREN #primaryNewElemsfrehs | sequence #primaryignore10 + | KEY_TERM #keyTerm ; sequence @@ -408,5 +409,4 @@ type: builtintype | referencetype | TYPE; referencetype: name; builtintype: BYTE | SHORT | INT | LONG | BOOLEAN | VOID | BIGINT | REAL | LOCSET | SEQ | FREE; name: ident (DOT ident)*; -quantifiedvariabledeclarator: IDENT dims?; - +quantifiedvariabledeclarator: IDENT dims?; \ No newline at end of file diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/RecordClassBuilder.java b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/RecordClassBuilder.java index 915cbdee9a..8da99d9ce3 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/RecordClassBuilder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/RecordClassBuilder.java @@ -14,10 +14,12 @@ import com.github.javaparser.ast.body.*; import com.github.javaparser.ast.expr.*; import com.github.javaparser.ast.key.JmlDocModifier; +import com.github.javaparser.ast.key.KeYMarkerStatement; import com.github.javaparser.ast.nodeTypes.NodeWithSimpleName; import com.github.javaparser.ast.stmt.ReturnStmt; import com.github.javaparser.ast.type.PrimitiveType; import com.github.javaparser.ast.type.Type; +import de.uka.ilkd.key.java.transformations.MarkerStatementHelper; import org.jspecify.annotations.Nullable; import static com.github.javaparser.ast.Modifier.DefaultKeyword.*; @@ -134,24 +136,24 @@ private void createConstructor(RecordDeclaration recordDeclaration, body.addStatement( assign(attributeThis(p.getNameAsString()), p.getNameAsExpression())); } - - var fieldParamEqual = recordDeclaration.getParameters() - .stream() - .map(NodeWithSimpleName::getNameAsString) - .map(it -> "ensures this.%s == %s;".formatted(it, it)) - .collect(Collectors.joining("\n")); - services.attachSpec(fullConstructor, """ - public normal_behavior - requires true; - %s - """.formatted(fieldParamEqual)); - } for (var compactConstructor : recordDeclaration.getCompactConstructors()) { fullConstructor.getBody().get().getStatements().add(0, compactConstructor.getBody()); } + var type = recordDeclaration.getNameAsString(); + var marker = new KeYMarkerStatement(MarkerStatementHelper.KIND_ASSUME); + var fieldParamEqual = recordDeclaration.getParameters() + .stream() + .map(NodeWithSimpleName::getNameAsString) + .map(it -> "(`int::select(heap, self, %s::#%s)` == this.%s)".formatted(type, it, it)) + .collect(Collectors.joining(" && ")); + + services.attachExpr(marker, + "//@ assume %s;".formatted(fieldParamEqual)); + fullConstructor.getBody().get().addStatement(marker); + clazz.addMember(fullConstructor); } @@ -214,7 +216,7 @@ private boolean createEquals(RecordDeclaration recordDeclaration, equals.addAnnotation(Override.class); equals.setType(Boolean.TYPE); Type tObject = StaticJavaParser.parseType("java.lang.Object"); - var mods = new NodeList<>(new Modifier(JML_NULLABLE)); + var mods = new NodeList(/*new Modifier(JML_NULLABLE)*/); equals.getParameters().add(new Parameter(mods, tObject, new SimpleName("o"))); equals.setBody(null); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/TransformationPipelineServices.java b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/TransformationPipelineServices.java index 6637822ff3..10444b2a52 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/TransformationPipelineServices.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/transformations/pipeline/TransformationPipelineServices.java @@ -3,19 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.java.transformations.pipeline; -import java.util.*; -import java.util.stream.Collectors; - -import de.uka.ilkd.key.java.loader.JavaParserFactory; -import de.uka.ilkd.key.java.transformations.ConstantExpressionEvaluator; -import de.uka.ilkd.key.java.transformations.EvaluationException; -import de.uka.ilkd.key.speclang.PositionedString; -import de.uka.ilkd.key.speclang.jml.pretranslation.TextualJMLConstruct; -import de.uka.ilkd.key.speclang.jml.pretranslation.TextualJMLLoopSpec; -import de.uka.ilkd.key.speclang.njml.PreParser; - -import org.key_project.util.collection.ImmutableList; - import com.github.javaparser.JavaParser; import com.github.javaparser.ast.CompilationUnit; import com.github.javaparser.ast.Modifier; @@ -31,12 +18,27 @@ import com.github.javaparser.resolution.model.SymbolReference; import com.github.javaparser.resolution.types.ResolvedReferenceType; import com.github.javaparser.resolution.types.ResolvedType; +import de.uka.ilkd.key.java.Position; +import de.uka.ilkd.key.java.loader.JavaParserFactory; +import de.uka.ilkd.key.java.transformations.ConstantExpressionEvaluator; +import de.uka.ilkd.key.java.transformations.EvaluationException; +import de.uka.ilkd.key.speclang.PositionedString; +import de.uka.ilkd.key.speclang.jml.pretranslation.TextualJMLAssertStatement; +import de.uka.ilkd.key.speclang.jml.pretranslation.TextualJMLConstruct; +import de.uka.ilkd.key.speclang.jml.pretranslation.TextualJMLLoopSpec; +import de.uka.ilkd.key.speclang.njml.PreParser; import org.jspecify.annotations.NonNull; import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.Nullable; +import org.key_project.util.collection.ImmutableList; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.*; +import java.util.stream.Collectors; + +import static de.uka.ilkd.key.java.transformations.MarkerStatementHelper.KEY_EXPR; + /** * @author Alexander Weigl * @version 1 (11/2/21) @@ -44,7 +46,7 @@ @NullMarked public class TransformationPipelineServices { private static final Logger LOGGER = - LoggerFactory.getLogger(TransformationPipelineServices.class); + LoggerFactory.getLogger(TransformationPipelineServices.class); private final TransformerCache cache; @@ -53,7 +55,7 @@ public class TransformationPipelineServices { private List warnings = new ArrayList<>(8); public TransformationPipelineServices(JavaParserFactory javaParserFactory, - TransformerCache cache) { + TransformerCache cache) { this.cache = cache; this.javaParserFactory = javaParserFactory; } @@ -139,7 +141,7 @@ public String getId(TypeDeclaration td) { * according to JLS Sect. 4.5.5 * * @return the default value of the given type - * according to JLS Sect. 4.5.5 + * according to JLS Sect. 4.5.5 */ public Expression getDefaultValue(Type type) { if (type instanceof ReferenceType) { @@ -270,7 +272,7 @@ public NodeList getInitializers(ClassOrInterfaceDeclaration cd) { if (member instanceof InitializerDeclaration init && !init.isStatic()) { String name = - PipelineConstants.OBJECT_INITIALIZER_IDENTIFIER + objectInitializerCount; + PipelineConstants.OBJECT_INITIALIZER_IDENTIFIER + objectInitializerCount; var initializerMethod = cd.addMethod(name, Modifier.DefaultKeyword.PRIVATE); initializerMethod.setBody(init.getBody().clone()); initializerMethod.setParentNode(cd); @@ -282,9 +284,9 @@ public NodeList getInitializers(ClassOrInterfaceDeclaration cd) { if (variable.getInitializer().isPresent()) { Expression fieldInit = variable.getInitializer().get(); final var access = new FieldAccessExpr( - new ThisExpr(), new NodeList<>(), variable.getName()); + new ThisExpr(), new NodeList<>(), variable.getName()); var fieldCopy = - new AssignExpr(access, fieldInit.clone(), AssignExpr.Operator.ASSIGN); + new AssignExpr(access, fieldInit.clone(), AssignExpr.Operator.ASSIGN); result.add(new ExpressionStmt(fieldCopy)); } } @@ -317,8 +319,7 @@ public Expression getDefaultValue(ResolvedType type) { case "int", "byte", "short" -> new IntegerLiteralExpr("0"); case "char" -> new CharLiteralExpr("0"); case "float", "double" -> new DoubleLiteralExpr("0.0"); - default -> - throw new IllegalStateException("Unexpected value: " + name.toLowerCase()); + default -> throw new IllegalStateException("Unexpected value: " + name.toLowerCase()); }; } @@ -360,6 +361,16 @@ public void attachSpec(Node node, @Nullable String spec) { LOGGER.info("Generated specification {} for {}", spec, node); } + public void attachExpr(Node node, @Nullable String spec) { + if (spec == null) + return; + PreParser pp = getPreParser(); + ImmutableList specification = pp.parseMethodLevel(spec, null, Position.UNDEFINED); + TextualJMLAssertStatement expr = (TextualJMLAssertStatement) specification.get(0); + node.setData(KEY_EXPR, expr.getContext()); + LOGGER.info("Generated specification {} for {}", spec, node); + } + /** * Cache of important data. This is done mainly for performance reasons. diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/Translator.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/Translator.java index 4b72d14739..7002da54ea 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/Translator.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/njml/Translator.java @@ -20,6 +20,7 @@ import de.uka.ilkd.key.logic.*; import de.uka.ilkd.key.logic.op.*; import de.uka.ilkd.key.logic.sort.ArraySort; +import de.uka.ilkd.key.nparser.KeyIO; import de.uka.ilkd.key.proof.OpReplacer; import de.uka.ilkd.key.speclang.ClassAxiom; import de.uka.ilkd.key.speclang.Contract; @@ -247,7 +248,6 @@ private String createSignatureString(ImmutableList signature) { } // region expression - @Override public KeYJavaType visitBuiltintype(JmlParser.BuiltintypeContext ctx) { if (ctx.BYTE() != null) { @@ -755,6 +755,20 @@ public Object visitAdditiveexpr(JmlParser.AdditiveexprContext ctx) { return result; } + + @Override + public SLExpression visitKeyTerm(JmlParser.KeyTermContext ctx) { + var key = ctx.KEY_TERM().getText(); + key = key.substring(1, key.length() - 1); + var nss = services.getNamespaces().copyWithParent(); + nss.programVariables().add(selfVar); + nss.programVariables().add(excVar); + var keyIO = new KeyIO(services, nss); + + var term = keyIO.parseExpression(key); + return new SLExpression(term); + } + @Override public Object visitMultexpr(JmlParser.MultexprContext ctx) { List exprs = mapOf(ctx.unaryexpr());