@@ -11149,4 +11149,101 @@ record SecondExampleRecord() {
1114911149 "ElementType cannot be resolved to a variable\n " +
1115011150 "----------\n " );
1115111151}
11152+ // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/4551
11153+ // ECJ fails on Record used within Enum in Annotation
11154+ public void testIssue4551_2 () throws Exception {
11155+ this .runConformTest (
11156+ new String [] {
11157+ "mypackage/Test.java" ,
11158+ """
11159+ package mypackage;
11160+
11161+
11162+ import java.lang.annotation.Target;
11163+ import java.lang.reflect.Method;
11164+ import java.lang.reflect.Modifier;
11165+
11166+ import static java.lang.annotation.ElementType.*;
11167+ import java.lang.annotation.Retention;
11168+ import java.lang.annotation.RetentionPolicy;
11169+ import java.math.BigDecimal;
11170+
11171+ import static mypackage.Test.TOPIC;
11172+
11173+
11174+ public record Test(
11175+ @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED)
11176+ @JsonProperty("test") BigDecimal test
11177+
11178+ ) {
11179+ public static final String TOPIC = "test";
11180+
11181+ public static void main(String[] args) {
11182+ Method[] methods = Test.class.getDeclaredMethods();
11183+
11184+ for (Method method : methods) {
11185+ // Get modifiers, return type, and name
11186+ String modifiers = Modifier.toString(method.getModifiers());
11187+ String returnType = method.getReturnType().getSimpleName();
11188+ String name = method.getName();
11189+
11190+ // Get parameter types
11191+ Class<?>[] params = method.getParameterTypes();
11192+ StringBuilder paramList = new StringBuilder();
11193+ for (int i = 0; i < params.length; i++) {
11194+ if (i > 0) paramList.append(", ");
11195+ paramList.append(params[i].getSimpleName());
11196+ }
11197+
11198+ // Print it out
11199+ System.out.printf("%s %s %s(%s)%n", modifiers, returnType, name, paramList);
11200+ }
11201+ }
11202+ }
11203+
11204+
11205+ @Target({FIELD, METHOD, PARAMETER, TYPE, ANNOTATION_TYPE})
11206+ @Retention(RetentionPolicy.RUNTIME)
11207+ @interface Schema {
11208+ enum RequiredMode {
11209+ AUTO,
11210+ REQUIRED,
11211+ NOT_REQUIRED;
11212+ }
11213+ static enum AccessMode {
11214+ AUTO,
11215+ READ_ONLY,
11216+ WRITE_ONLY,
11217+ READ_WRITE;
11218+ }
11219+ String name() default "";
11220+ String title() default "";
11221+ String description() default "";
11222+ Class<?> implementation() default Void.class;
11223+ AccessMode accessMode() default AccessMode.AUTO;
11224+ RequiredMode requiredMode() default RequiredMode.AUTO;
11225+ boolean hidden() default false;
11226+ // … many more elements …
11227+ }
11228+
11229+ @Target({ANNOTATION_TYPE, FIELD, METHOD, PARAMETER})
11230+ @Retention(RetentionPolicy.RUNTIME)
11231+ @interface JsonProperty {
11232+ String value() default "";
11233+ boolean required() default false;
11234+ int index() default -1;
11235+ String defaultValue() default "";
11236+ // Access access() default Access.AUTO;
11237+ String namespace() default "";
11238+ // …
11239+ }
11240+ """ ,
11241+ },
11242+ "public static void main(String[])\n " +
11243+ "public final boolean equals(Object)\n " +
11244+ "public final String toString()\n " +
11245+ "public final int hashCode()\n " +
11246+ "public BigDecimal test()" );
11247+
11248+ }
1115211249}
0 commit comments