diff options
19 files changed, 161 insertions, 39 deletions
diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java index bdb88299..25999e85 100644 --- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java +++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java @@ -1904,7 +1904,8 @@ public class EclipseHandlerUtil { return typeNode.add(type, Kind.TYPE); } - private static final char[] ALL = "all".toCharArray(); + static final char[] ALL = "all".toCharArray(); + static final char[] UNCHECKED = "unchecked".toCharArray(); private static final char[] JUSTIFICATION = "justification".toCharArray(); private static final char[] GENERATED_CODE = "generated code".toCharArray(); private static final char[] LOMBOK = "lombok".toCharArray(); @@ -1934,7 +1935,7 @@ public class EclipseHandlerUtil { return result; } - private static Annotation[] addAnnotation(ASTNode source, Annotation[] originalAnnotationArray, char[][] annotationTypeFqn, ASTNode arg) { + static Annotation[] addAnnotation(ASTNode source, Annotation[] originalAnnotationArray, char[][] annotationTypeFqn, ASTNode arg) { char[] simpleName = annotationTypeFqn[annotationTypeFqn.length - 1]; if (originalAnnotationArray != null) for (Annotation ann : originalAnnotationArray) { diff --git a/src/core/lombok/eclipse/handlers/HandleGetter.java b/src/core/lombok/eclipse/handlers/HandleGetter.java index 7ba84cdc..58401ac1 100644 --- a/src/core/lombok/eclipse/handlers/HandleGetter.java +++ b/src/core/lombok/eclipse/handlers/HandleGetter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2019 The Project Lombok Authors. + * Copyright (C) 2009-2020 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -46,6 +46,7 @@ import lombok.eclipse.agent.PatchDelegate; import org.eclipse.jdt.internal.compiler.ast.ASTNode; import org.eclipse.jdt.internal.compiler.ast.AllocationExpression; import org.eclipse.jdt.internal.compiler.ast.Annotation; +import org.eclipse.jdt.internal.compiler.ast.ArrayInitializer; import org.eclipse.jdt.internal.compiler.ast.ArrayTypeReference; import org.eclipse.jdt.internal.compiler.ast.Assignment; import org.eclipse.jdt.internal.compiler.ast.BinaryExpression; @@ -66,6 +67,7 @@ import org.eclipse.jdt.internal.compiler.ast.ReturnStatement; import org.eclipse.jdt.internal.compiler.ast.SingleNameReference; import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference; import org.eclipse.jdt.internal.compiler.ast.Statement; +import org.eclipse.jdt.internal.compiler.ast.StringLiteral; import org.eclipse.jdt.internal.compiler.ast.SynchronizedStatement; import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; import org.eclipse.jdt.internal.compiler.ast.TypeReference; @@ -241,8 +243,10 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> { TypeReference returnType = copyType(((FieldDeclaration) fieldNode.get()).type, source); Statement[] statements; + boolean addSuppressWarningsUnchecked = false; if (lazy) { statements = createLazyGetterBody(source, fieldNode); + addSuppressWarningsUnchecked = true; } else { statements = createSimpleGetterBody(source, fieldNode); } @@ -276,6 +280,14 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> { deprecated); } + if (addSuppressWarningsUnchecked) { + ArrayInitializer arr = new ArrayInitializer(); + arr.expressions = new Expression[2]; + arr.expressions[0] = new StringLiteral(ALL, 0, 0, 0); + arr.expressions[1] = new StringLiteral(UNCHECKED, 0, 0, 0); + method.annotations = addAnnotation(source, method.annotations, TypeConstants.JAVA_LANG_SUPPRESSWARNINGS, arr); + } + method.traverse(new SetGeneratedByVisitor(source), parent.scope); return method; } diff --git a/src/core/lombok/javac/handlers/HandleGetter.java b/src/core/lombok/javac/handlers/HandleGetter.java index 681865df..8615d572 100644 --- a/src/core/lombok/javac/handlers/HandleGetter.java +++ b/src/core/lombok/javac/handlers/HandleGetter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2019 The Project Lombok Authors. + * Copyright (C) 2009-2020 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -38,6 +38,7 @@ import lombok.Getter; import lombok.core.AST.Kind; import lombok.core.AnnotationValues; import lombok.core.configuration.CheckerFrameworkVersion; +import lombok.delombok.LombokOptionsFactory; import lombok.javac.JavacAnnotationHandler; import lombok.javac.JavacNode; import lombok.javac.JavacTreeMaker; @@ -231,9 +232,11 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> { List<JCStatement> statements; JCTree toClearOfMarkers = null; + boolean addSuppressWarningsUnchecked = false; if (lazy && !inNetbeansEditor(field)) { toClearOfMarkers = fieldNode.init; statements = createLazyGetterBody(treeMaker, field, source); + addSuppressWarningsUnchecked = LombokOptionsFactory.getDelombokOptions(field.getContext()).getFormatPreferences().generateSuppressWarnings(); } else { statements = createSimpleGetterBody(treeMaker, field); } @@ -252,11 +255,15 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> { if (isFieldDeprecated(field)) annsOnMethod = annsOnMethod.prepend(treeMaker.Annotation(genJavaLangTypeRef(field, "Deprecated"), List.<JCExpression>nil())); JCMethodDecl decl = recursiveSetGeneratedBy(treeMaker.MethodDef(treeMaker.Modifiers(access, annsOnMethod), methodName, methodType, - methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue), source, field.getContext()); + methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue), source, field.getContext()); if (toClearOfMarkers != null) recursiveSetGeneratedBy(toClearOfMarkers, null, null); decl.mods.annotations = decl.mods.annotations.appendList(delegates); + if (addSuppressWarningsUnchecked) { + addAnnotation(decl.mods, field, source.pos, source, field.getContext(), "java.lang.SuppressWarnings", treeMaker.NewArray(null, List.<JCExpression>nil(), List.<JCExpression>of(treeMaker.Literal("all"), treeMaker.Literal("unchecked")))); + } + copyJavadoc(field, decl, CopyJavadoc.GETTER); return decl; } @@ -418,7 +425,7 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> { /* private final java.util.concurrent.atomic.AtomicReference<Object> fieldName = new java.util.concurrent.atomic.AtomicReference<Object>(); */ { field.vartype = recursiveSetGeneratedBy( - maker.TypeApply(chainDotsString(fieldNode, AR), List.<JCExpression>of(genJavaLangTypeRef(fieldNode, "Object"))), source, fieldNode.getContext()); + maker.TypeApply(chainDotsString(fieldNode, AR), List.<JCExpression>of(genJavaLangTypeRef(fieldNode, "Object"))), source, fieldNode.getContext()); field.init = recursiveSetGeneratedBy(maker.NewClass(null, NIL_EXPRESSION, copyType(maker, field), NIL_EXPRESSION, null), source, fieldNode.getContext()); } diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index 3ec9f159..2fbc32b6 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -1247,7 +1247,19 @@ public class JavacHandlerUtil { public static void addSuppressWarningsAll(JCModifiers mods, JavacNode node, int pos, JCTree source, Context context) { if (!LombokOptionsFactory.getDelombokOptions(context).getFormatPreferences().generateSuppressWarnings()) return; - addAnnotation(mods, node, pos, source, context, "java.lang.SuppressWarnings", node.getTreeMaker().Literal("all")); + + boolean addJLSuppress = true; + + for (JCAnnotation ann : mods.annotations) { + JCTree type = ann.getAnnotationType(); + Name n = null; + if (type instanceof JCIdent) n = ((JCIdent) type).name; + else if (type instanceof JCFieldAccess) n = ((JCFieldAccess) type).name; + if (n != null && n.contentEquals("SuppressWarnings")) { + addJLSuppress = false; + } + } + if (addJLSuppress) addAnnotation(mods, node, pos, source, context, "java.lang.SuppressWarnings", node.getTreeMaker().Literal("all")); if (Boolean.TRUE.equals(node.getAst().readConfiguration(ConfigurationKeys.ADD_FINDBUGS_SUPPRESSWARNINGS_ANNOTATIONS))) { JavacTreeMaker maker = node.getTreeMaker(); diff --git a/test/transform/resource/after-delombok/DelegateOnGetter.java b/test/transform/resource/after-delombok/DelegateOnGetter.java index f41259df..edf1641b 100644 --- a/test/transform/resource/after-delombok/DelegateOnGetter.java +++ b/test/transform/resource/after-delombok/DelegateOnGetter.java @@ -4,7 +4,7 @@ class DelegateOnGetter { void setList(java.util.ArrayList<java.lang.String> list); int getInt(); } - @java.lang.SuppressWarnings("all") + @java.lang.SuppressWarnings({"all", "unchecked"}) public Bar getBar() { java.lang.Object value = this.bar.get(); if (value == null) { diff --git a/test/transform/resource/after-delombok/GetterLazy.java b/test/transform/resource/after-delombok/GetterLazy.java index 25a71848..1e30f94b 100644 --- a/test/transform/resource/after-delombok/GetterLazy.java +++ b/test/transform/resource/after-delombok/GetterLazy.java @@ -2,7 +2,7 @@ class GetterLazy { static class ValueType { } private final java.util.concurrent.atomic.AtomicReference<java.lang.Object> fieldName = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); - @java.lang.SuppressWarnings("all") + @java.lang.SuppressWarnings({"all", "unchecked"}) public ValueType getFieldName() { java.lang.Object value = this.fieldName.get(); if (value == null) { diff --git a/test/transform/resource/after-delombok/GetterLazyBoolean.java b/test/transform/resource/after-delombok/GetterLazyBoolean.java index 3ca127e3..5b1f19dc 100644 --- a/test/transform/resource/after-delombok/GetterLazyBoolean.java +++ b/test/transform/resource/after-delombok/GetterLazyBoolean.java @@ -31,7 +31,7 @@ class GetterLazyBoolean { public java.lang.String toString() { return "GetterLazyBoolean(booleanValue=" + this.isBooleanValue() + ")"; } - @java.lang.SuppressWarnings("all") + @java.lang.SuppressWarnings({"all", "unchecked"}) public boolean isBooleanValue() { java.lang.Object value = this.booleanValue.get(); if (value == null) { @@ -46,7 +46,7 @@ class GetterLazyBoolean { } return (java.lang.Boolean) value; } - @java.lang.SuppressWarnings("all") + @java.lang.SuppressWarnings({"all", "unchecked"}) public boolean isOtherBooleanValue() { java.lang.Object value = this.otherBooleanValue.get(); if (value == null) { diff --git a/test/transform/resource/after-delombok/GetterLazyEahcToString.java b/test/transform/resource/after-delombok/GetterLazyEahcToString.java index e0a0f6b2..bec89818 100644 --- a/test/transform/resource/after-delombok/GetterLazyEahcToString.java +++ b/test/transform/resource/after-delombok/GetterLazyEahcToString.java @@ -44,9 +44,7 @@ class GetterLazyEahcToString { return "GetterLazyEahcToString(value=" + this.getValue() + ", value2=" + this.value2 + ")"; } - @java.lang.SuppressWarnings("all") - - + @java.lang.SuppressWarnings({"all", "unchecked"}) public String getValue() { java.lang.Object value = this.value.get(); if (value == null) { diff --git a/test/transform/resource/after-delombok/GetterLazyGenerics.java b/test/transform/resource/after-delombok/GetterLazyGenerics.java new file mode 100644 index 00000000..5e92cda7 --- /dev/null +++ b/test/transform/resource/after-delombok/GetterLazyGenerics.java @@ -0,0 +1,37 @@ +class GetterLazyGenerics<E> { + private final java.util.concurrent.atomic.AtomicReference<java.lang.Object> field = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); + private final java.util.concurrent.atomic.AtomicReference<java.lang.Object> field2 = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); + public static <E> E getAny() { + return null; + } + @java.lang.SuppressWarnings({"all", "unchecked"}) + public E getField() { + java.lang.Object value = this.field.get(); + if (value == null) { + synchronized (this.field) { + value = this.field.get(); + if (value == null) { + final E actualValue = getAny(); + value = actualValue == null ? this.field : actualValue; + this.field.set(value); + } + } + } + return (E) (value == this.field ? null : value); + } + @java.lang.SuppressWarnings({"all", "unchecked"}) + public long getField2() { + java.lang.Object value = this.field2.get(); + if (value == null) { + synchronized (this.field2) { + value = this.field2.get(); + if (value == null) { + final long actualValue = System.currentTimeMillis(); + value = actualValue; + this.field2.set(value); + } + } + } + return (java.lang.Long) value; + } +}
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/GetterLazyNative.java b/test/transform/resource/after-delombok/GetterLazyNative.java index b9d471ff..f43d5490 100644 --- a/test/transform/resource/after-delombok/GetterLazyNative.java +++ b/test/transform/resource/after-delombok/GetterLazyNative.java @@ -8,7 +8,7 @@ class GetterLazyNative { private final java.util.concurrent.atomic.AtomicReference<java.lang.Object> doubleField = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); private final java.util.concurrent.atomic.AtomicReference<java.lang.Object> charField = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); private final java.util.concurrent.atomic.AtomicReference<java.lang.Object> intArrayField = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); - @java.lang.SuppressWarnings("all") + @java.lang.SuppressWarnings({"all", "unchecked"}) public boolean isBooleanField() { java.lang.Object value = this.booleanField.get(); if (value == null) { @@ -23,7 +23,7 @@ class GetterLazyNative { } return (java.lang.Boolean) value; } - @java.lang.SuppressWarnings("all") + @java.lang.SuppressWarnings({"all", "unchecked"}) public byte getByteField() { java.lang.Object value = this.byteField.get(); if (value == null) { @@ -38,7 +38,7 @@ class GetterLazyNative { } return (java.lang.Byte) value; } - @java.lang.SuppressWarnings("all") + @java.lang.SuppressWarnings({"all", "unchecked"}) public short getShortField() { java.lang.Object value = this.shortField.get(); if (value == null) { @@ -53,7 +53,7 @@ class GetterLazyNative { } return (java.lang.Short) value; } - @java.lang.SuppressWarnings("all") + @java.lang.SuppressWarnings({"all", "unchecked"}) public int getIntField() { java.lang.Object value = this.intField.get(); if (value == null) { @@ -68,7 +68,7 @@ class GetterLazyNative { } return (java.lang.Integer) value; } - @java.lang.SuppressWarnings("all") + @java.lang.SuppressWarnings({"all", "unchecked"}) public long getLongField() { java.lang.Object value = this.longField.get(); if (value == null) { @@ -83,7 +83,7 @@ class GetterLazyNative { } return (java.lang.Long) value; } - @java.lang.SuppressWarnings("all") + @java.lang.SuppressWarnings({"all", "unchecked"}) public float getFloatField() { java.lang.Object value = this.floatField.get(); if (value == null) { @@ -98,7 +98,7 @@ class GetterLazyNative { } return (java.lang.Float) value; } - @java.lang.SuppressWarnings("all") + @java.lang.SuppressWarnings({"all", "unchecked"}) public double getDoubleField() { java.lang.Object value = this.doubleField.get(); if (value == null) { @@ -113,7 +113,7 @@ class GetterLazyNative { } return (java.lang.Double) value; } - @java.lang.SuppressWarnings("all") + @java.lang.SuppressWarnings({"all", "unchecked"}) public char getCharField() { java.lang.Object value = this.charField.get(); if (value == null) { @@ -128,7 +128,7 @@ class GetterLazyNative { } return (java.lang.Character) value; } - @java.lang.SuppressWarnings("all") + @java.lang.SuppressWarnings({"all", "unchecked"}) public int[] getIntArrayField() { java.lang.Object value = this.intArrayField.get(); if (value == null) { diff --git a/test/transform/resource/after-delombok/GetterLazyTransient.java b/test/transform/resource/after-delombok/GetterLazyTransient.java index 49093ed1..0fd85621 100644 --- a/test/transform/resource/after-delombok/GetterLazyTransient.java +++ b/test/transform/resource/after-delombok/GetterLazyTransient.java @@ -2,7 +2,7 @@ class GetterLazyTransient { private final java.util.concurrent.atomic.AtomicReference<java.lang.Object> nonTransientField = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); private final transient int transientField = 2; private final transient int nonLazyTransientField = 3; - @java.lang.SuppressWarnings("all") + @java.lang.SuppressWarnings({"all", "unchecked"}) public int getNonTransientField() { java.lang.Object value = this.nonTransientField.get(); if (value == null) { diff --git a/test/transform/resource/after-ecj/DelegateOnGetter.java b/test/transform/resource/after-ecj/DelegateOnGetter.java index 59f6a3b8..f2b9a6cd 100644 --- a/test/transform/resource/after-ecj/DelegateOnGetter.java +++ b/test/transform/resource/after-ecj/DelegateOnGetter.java @@ -9,7 +9,7 @@ class DelegateOnGetter { DelegateOnGetter() { super(); } - public @Delegate @java.lang.SuppressWarnings("all") Bar getBar() { + public @Delegate @java.lang.SuppressWarnings({"all", "unchecked"}) Bar getBar() { java.lang.Object value = this.bar.get(); if ((value == null)) { diff --git a/test/transform/resource/after-ecj/GetterLazy.java b/test/transform/resource/after-ecj/GetterLazy.java index 8394f58d..b4567f04 100644 --- a/test/transform/resource/after-ecj/GetterLazy.java +++ b/test/transform/resource/after-ecj/GetterLazy.java @@ -8,7 +8,7 @@ class GetterLazy { GetterLazy() { super(); } - public @java.lang.SuppressWarnings("all") ValueType getFieldName() { + public @java.lang.SuppressWarnings({"all", "unchecked"}) ValueType getFieldName() { java.lang.Object value = this.fieldName.get(); if ((value == null)) { diff --git a/test/transform/resource/after-ecj/GetterLazyBoolean.java b/test/transform/resource/after-ecj/GetterLazyBoolean.java index 174389e8..ad319755 100644 --- a/test/transform/resource/after-ecj/GetterLazyBoolean.java +++ b/test/transform/resource/after-ecj/GetterLazyBoolean.java @@ -7,7 +7,7 @@ private static boolean calculateBoolean() { return true; } - public @java.lang.SuppressWarnings("all") boolean isBooleanValue() { + public @java.lang.SuppressWarnings({"all", "unchecked"}) boolean isBooleanValue() { java.lang.Object value = this.booleanValue.get(); if ((value == null)) { @@ -24,7 +24,7 @@ } return (java.lang.Boolean) value; } - public @java.lang.SuppressWarnings("all") boolean isOtherBooleanValue() { + public @java.lang.SuppressWarnings({"all", "unchecked"}) boolean isOtherBooleanValue() { java.lang.Object value = this.otherBooleanValue.get(); if ((value == null)) { diff --git a/test/transform/resource/after-ecj/GetterLazyEahcToString.java b/test/transform/resource/after-ecj/GetterLazyEahcToString.java index e66a9c2e..5197f4e1 100644 --- a/test/transform/resource/after-ecj/GetterLazyEahcToString.java +++ b/test/transform/resource/after-ecj/GetterLazyEahcToString.java @@ -4,7 +4,7 @@ GetterLazyEahcToString() { super(); } - public @java.lang.SuppressWarnings("all") String getValue() { + public @java.lang.SuppressWarnings({"all", "unchecked"}) String getValue() { java.lang.Object value = this.value.get(); if ((value == null)) { diff --git a/test/transform/resource/after-ecj/GetterLazyGenerics.java b/test/transform/resource/after-ecj/GetterLazyGenerics.java new file mode 100644 index 00000000..67ef5543 --- /dev/null +++ b/test/transform/resource/after-ecj/GetterLazyGenerics.java @@ -0,0 +1,44 @@ +class GetterLazyGenerics<E> { + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.lang.Object> field = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.lang.Object> field2 = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); + GetterLazyGenerics() { + super(); + } + public static <E>E getAny() { + return null; + } + public @java.lang.SuppressWarnings({"all", "unchecked"}) E getField() { + java.lang.Object value = this.field.get(); + if ((value == null)) + { + synchronized (this.field) + { + value = this.field.get(); + if ((value == null)) + { + final E actualValue = getAny(); + value = ((actualValue == null) ? this.field : actualValue); + this.field.set(value); + } + } + } + return (E) ((value == this.field) ? null : value); + } + public @java.lang.SuppressWarnings({"all", "unchecked"}) long getField2() { + java.lang.Object value = this.field2.get(); + if ((value == null)) + { + synchronized (this.field2) + { + value = this.field2.get(); + if ((value == null)) + { + final long actualValue = System.currentTimeMillis(); + value = actualValue; + this.field2.set(value); + } + } + } + return (java.lang.Long) value; + } +}
\ No newline at end of file diff --git a/test/transform/resource/after-ecj/GetterLazyNative.java b/test/transform/resource/after-ecj/GetterLazyNative.java index db70f2f4..7808068e 100644 --- a/test/transform/resource/after-ecj/GetterLazyNative.java +++ b/test/transform/resource/after-ecj/GetterLazyNative.java @@ -11,7 +11,7 @@ class GetterLazyNative { GetterLazyNative() { super(); } - public @java.lang.SuppressWarnings("all") boolean isBooleanField() { + public @java.lang.SuppressWarnings({"all", "unchecked"}) boolean isBooleanField() { java.lang.Object value = this.booleanField.get(); if ((value == null)) { @@ -28,7 +28,7 @@ class GetterLazyNative { } return (java.lang.Boolean) value; } - public @java.lang.SuppressWarnings("all") byte getByteField() { + public @java.lang.SuppressWarnings({"all", "unchecked"}) byte getByteField() { java.lang.Object value = this.byteField.get(); if ((value == null)) { @@ -45,7 +45,7 @@ class GetterLazyNative { } return (java.lang.Byte) value; } - public @java.lang.SuppressWarnings("all") short getShortField() { + public @java.lang.SuppressWarnings({"all", "unchecked"}) short getShortField() { java.lang.Object value = this.shortField.get(); if ((value == null)) { @@ -62,7 +62,7 @@ class GetterLazyNative { } return (java.lang.Short) value; } - public @java.lang.SuppressWarnings("all") int getIntField() { + public @java.lang.SuppressWarnings({"all", "unchecked"}) int getIntField() { java.lang.Object value = this.intField.get(); if ((value == null)) { @@ -79,7 +79,7 @@ class GetterLazyNative { } return (java.lang.Integer) value; } - public @java.lang.SuppressWarnings("all") long getLongField() { + public @java.lang.SuppressWarnings({"all", "unchecked"}) long getLongField() { java.lang.Object value = this.longField.get(); if ((value == null)) { @@ -96,7 +96,7 @@ class GetterLazyNative { } return (java.lang.Long) value; } - public @java.lang.SuppressWarnings("all") float getFloatField() { + public @java.lang.SuppressWarnings({"all", "unchecked"}) float getFloatField() { java.lang.Object value = this.floatField.get(); if ((value == null)) { @@ -113,7 +113,7 @@ class GetterLazyNative { } return (java.lang.Float) value; } - public @java.lang.SuppressWarnings("all") double getDoubleField() { + public @java.lang.SuppressWarnings({"all", "unchecked"}) double getDoubleField() { java.lang.Object value = this.doubleField.get(); if ((value == null)) { @@ -130,7 +130,7 @@ class GetterLazyNative { } return (java.lang.Double) value; } - public @java.lang.SuppressWarnings("all") char getCharField() { + public @java.lang.SuppressWarnings({"all", "unchecked"}) char getCharField() { java.lang.Object value = this.charField.get(); if ((value == null)) { @@ -147,7 +147,7 @@ class GetterLazyNative { } return (java.lang.Character) value; } - public @java.lang.SuppressWarnings("all") int[] getIntArrayField() { + public @java.lang.SuppressWarnings({"all", "unchecked"}) int[] getIntArrayField() { java.lang.Object value = this.intArrayField.get(); if ((value == null)) { diff --git a/test/transform/resource/after-ecj/GetterLazyTransient.java b/test/transform/resource/after-ecj/GetterLazyTransient.java index 3ffd9b69..7e5f4a41 100644 --- a/test/transform/resource/after-ecj/GetterLazyTransient.java +++ b/test/transform/resource/after-ecj/GetterLazyTransient.java @@ -5,7 +5,7 @@ class GetterLazyTransient { GetterLazyTransient() { super(); } - public @java.lang.SuppressWarnings("all") int getNonTransientField() { + public @java.lang.SuppressWarnings({"all", "unchecked"}) int getNonTransientField() { java.lang.Object value = this.nonTransientField.get(); if ((value == null)) { diff --git a/test/transform/resource/before/GetterLazyGenerics.java b/test/transform/resource/before/GetterLazyGenerics.java new file mode 100644 index 00000000..50ca1c33 --- /dev/null +++ b/test/transform/resource/before/GetterLazyGenerics.java @@ -0,0 +1,11 @@ +class GetterLazyGenerics<E> { + @lombok.Getter(lazy=true) + private final E field = getAny(); + + @lombok.Getter(lazy=true) + private final long field2 = System.currentTimeMillis(); + + public static <E> E getAny() { + return null; + } +}
\ No newline at end of file |