diff options
7 files changed, 136 insertions, 100 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleGetter.java b/src/core/lombok/eclipse/handlers/HandleGetter.java index 7f788c5d..760c595e 100644 --- a/src/core/lombok/eclipse/handlers/HandleGetter.java +++ b/src/core/lombok/eclipse/handlers/HandleGetter.java @@ -49,6 +49,8 @@ import org.eclipse.jdt.internal.compiler.ast.ArrayTypeReference; import org.eclipse.jdt.internal.compiler.ast.Assignment; import org.eclipse.jdt.internal.compiler.ast.BinaryExpression; import org.eclipse.jdt.internal.compiler.ast.Block; +import org.eclipse.jdt.internal.compiler.ast.CastExpression; +import org.eclipse.jdt.internal.compiler.ast.ConditionalExpression; import org.eclipse.jdt.internal.compiler.ast.EqualExpression; import org.eclipse.jdt.internal.compiler.ast.Expression; import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration; @@ -67,6 +69,7 @@ import org.eclipse.jdt.internal.compiler.ast.SynchronizedStatement; import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; import org.eclipse.jdt.internal.compiler.ast.TypeReference; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; +import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; import org.mangosdk.spi.ProviderFor; /** @@ -286,7 +289,6 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> { } private static final char[][] AR = fromQualifiedName("java.util.concurrent.atomic.AtomicReference"); - private static final TypeReference[][] AR_PARAMS = new TypeReference[5][]; private static final java.util.Map<String, char[][]> TYPE_MAP; static { @@ -305,41 +307,54 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> { private static char[] valueName = "value".toCharArray(); private static char[] actualValueName = "actualValue".toCharArray(); + private static final int PARENTHESIZED = (1 << ASTNode.ParenthesizedSHIFT) & ASTNode.ParenthesizedMASK; + private Statement[] createLazyGetterBody(ASTNode source, EclipseNode fieldNode) { /* - java.util.concurrent.atomic.AtomicReference<ValueType> value = this.fieldName.get(); + java.lang.Object value = this.fieldName.get(); if (value == null) { synchronized (this.fieldName) { value = this.fieldName.get(); if (value == null) { - final ValueType actualValue = new ValueType(); - value = new java.util.concurrent.atomic.AtomicReference<ValueType>(actualValue); + final RawValueType actualValue = INITIALIZER_EXPRESSION; + [IF PRIMITIVE] + value = actualValue; + [ELSE] + value = actualValue == null ? this.fieldName : actualValue; + [END IF] this.fieldName.set(value); } } } - return value.get(); + [IF PRIMITIVE] + return (BoxedValueType) value; + [ELSE] + return (BoxedValueType) (value == this.fieldName ? null : value); + [END IF] */ FieldDeclaration field = (FieldDeclaration) fieldNode.get(); int pS = source.sourceStart, pE = source.sourceEnd; long p = (long)pS << 32 | pE; - TypeReference componentType = copyType(field.type, source); + TypeReference rawComponentType = copyType(field.type, source); + TypeReference boxedComponentType = null; + boolean isPrimitive = false; if (field.type instanceof SingleTypeReference && !(field.type instanceof ArrayTypeReference)) { char[][] newType = TYPE_MAP.get(new String(((SingleTypeReference)field.type).token)); if (newType != null) { - componentType = new QualifiedTypeReference(newType, poss(source, 3)); + boxedComponentType = new QualifiedTypeReference(newType, poss(source, 3)); + isPrimitive = true; } } + if (boxedComponentType == null) boxedComponentType = copyType(field.type, source); + boxedComponentType.sourceStart = pS; boxedComponentType.sourceEnd = boxedComponentType.statementEnd = pE; Statement[] statements = new Statement[3]; - /* java.util.concurrent.atomic.AtomicReference<ValueType> value = this.fieldName.get(); */ { + /* java.lang.Object value = this.fieldName.get(); */ { LocalDeclaration valueDecl = new LocalDeclaration(valueName, pS, pE); - TypeReference[][] typeParams = AR_PARAMS.clone(); - typeParams[4] = new TypeReference[] {copyType(componentType, source)}; - valueDecl.type = new ParameterizedQualifiedTypeReference(AR, typeParams, 0, poss(source, 5)); + valueDecl.type = new QualifiedTypeReference(TypeConstants.JAVA_LANG_OBJECT, poss(source, 3)); valueDecl.type.sourceStart = pS; valueDecl.type.sourceEnd = valueDecl.type.statementEnd = pE; MessageSend getter = new MessageSend(); @@ -356,8 +371,12 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> { synchronized (this.fieldName) { value = this.fieldName.get(); if (value == null) { - final ValueType actualValue = new ValueType(); - value = new java.util.concurrent.atomic.AtomicReference<ValueType>(actualValue); + final ValueType actualValue = INITIALIZER_EXPRESSION; + [IF PRIMITIVE] + value = actualValue; + [ELSE] + value = actualValue == null ? this.fieldName : actualValue; + [END IF] this.fieldName.set(value); } } @@ -383,28 +402,37 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> { EqualExpression innerCond = new EqualExpression( new SingleNameReference(valueName, p), new NullLiteral(pS, pE), BinaryExpression.EQUAL_EQUAL); + innerCond.sourceStart = pS; innerCond.sourceEnd = innerCond.statementEnd = pE; Block innerThen = new Block(0); innerThen.statements = new Statement[3]; - /* final ValueType actualValue = new ValueType(); */ { + /* final ValueType actualValue = INITIALIZER_EXPRESSION */ { LocalDeclaration actualValueDecl = new LocalDeclaration(actualValueName, pS, pE); - actualValueDecl.type = copyType(field.type, source); + actualValueDecl.type = rawComponentType; actualValueDecl.type.sourceStart = pS; actualValueDecl.type.sourceEnd = actualValueDecl.type.statementEnd = pE; actualValueDecl.initialization = field.initialization; actualValueDecl.modifiers = ClassFileConstants.AccFinal; innerThen.statements[0] = actualValueDecl; } - /* value = new java.util.concurrent.atomic.AtomicReference<ValueType>(actualValue); */ { - AllocationExpression create = new AllocationExpression(); - create.sourceStart = pS; create.sourceEnd = create.statementEnd = pE; - TypeReference[][] typeParams = AR_PARAMS.clone(); - typeParams[4] = new TypeReference[] {copyType(componentType, source)}; - create.type = new ParameterizedQualifiedTypeReference(AR, typeParams, 0, poss(source, 5)); - create.type.sourceStart = pS; create.type.sourceEnd = create.type.statementEnd = pE; - create.arguments = new Expression[] {new SingleNameReference(actualValueName, p)}; - Assignment innerAssign = new Assignment(new SingleNameReference(valueName, p), create, pE); - innerAssign.sourceStart = pS; innerAssign.statementEnd = innerAssign.sourceEnd = pE; - - innerThen.statements[1] = innerAssign; + /* [IF PRIMITIVE] value = actualValue; */ { + if (isPrimitive) { + Assignment innerAssign = new Assignment(new SingleNameReference(valueName, p), new SingleNameReference(actualValueName, p), pE); + innerAssign.sourceStart = pS; innerAssign.statementEnd = innerAssign.sourceEnd = pE; + innerThen.statements[1] = innerAssign; + } + } + /* [ELSE] value = actualValue == null ? this.fieldName : actualValue; */ { + if (!isPrimitive) { + EqualExpression avIsNull = new EqualExpression( + new SingleNameReference(actualValueName, p), new NullLiteral(pS, pE), + BinaryExpression.EQUAL_EQUAL); + avIsNull.sourceStart = pS; avIsNull.sourceEnd = avIsNull.statementEnd = pE; + Expression fieldRef = createFieldAccessor(fieldNode, FieldAccess.ALWAYS_FIELD, source); + ConditionalExpression ternary = new ConditionalExpression(avIsNull, fieldRef, new SingleNameReference(actualValueName, p)); + ternary.sourceStart = pS; ternary.sourceEnd = ternary.statementEnd = pE; + Assignment innerAssign = new Assignment(new SingleNameReference(valueName, p), ternary, pE); + innerAssign.sourceStart = pS; innerAssign.statementEnd = innerAssign.sourceEnd = pE; + innerThen.statements[1] = innerAssign; + } } /* this.fieldName.set(value); */ { @@ -428,26 +456,34 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> { statements[1] = ifStatement; } - /* return value.get(); */ { - MessageSend getter = new MessageSend(); - getter.sourceStart = pS; getter.sourceEnd = getter.statementEnd = pE; - getter.selector = new char[] {'g', 'e', 't'}; - getter.receiver = new SingleNameReference(valueName, p); - - statements[2] = new ReturnStatement(getter, pS, pE); + /* [IF PRIMITIVE] return (BoxedValueType)value; */ { + if (isPrimitive) { + CastExpression cast = makeCastExpression(new SingleNameReference(valueName, p), boxedComponentType, source); + statements[2] = new ReturnStatement(cast, pS, pE); + } + } + /* [ELSE] return (BoxedValueType)(value == this.fieldName ? null : value); */ { + if (!isPrimitive) { + EqualExpression vIsThisFieldName = new EqualExpression( + new SingleNameReference(valueName, p), createFieldAccessor(fieldNode, FieldAccess.ALWAYS_FIELD, source), + BinaryExpression.EQUAL_EQUAL); + vIsThisFieldName.sourceStart = pS; vIsThisFieldName.sourceEnd = vIsThisFieldName.statementEnd = pE; + ConditionalExpression ternary = new ConditionalExpression(vIsThisFieldName, new NullLiteral(pS, pE), new SingleNameReference(valueName, p)); + ternary.sourceStart = pS; ternary.sourceEnd = ternary.statementEnd = pE; + ternary.bits |= PARENTHESIZED; + CastExpression cast = makeCastExpression(ternary, boxedComponentType, source); + statements[2] = new ReturnStatement(cast, pS, pE); + } } - // update the field type and init last - /* private final java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<ValueType> fieldName = new java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<ValueType>>(); */ { - - LocalDeclaration first = (LocalDeclaration) statements[0]; - TypeReference innerType = copyType(first.type, source); - - TypeReference[][] typeParams = AR_PARAMS.clone(); - typeParams[4] = new TypeReference[] {copyType(innerType, source)}; + /* private final java.util.concurrent.atomic.AtomicReference<java.lang.Object> fieldName = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); */ { + TypeReference innerType = new QualifiedTypeReference(TypeConstants.JAVA_LANG_OBJECT, poss(source, 3)); + TypeReference[][] typeParams = new TypeReference[5][]; + typeParams[4] = new TypeReference[] {innerType}; TypeReference type = new ParameterizedQualifiedTypeReference(AR, typeParams, 0, poss(source, 5)); + // Some magic here type.sourceStart = -1; type.sourceEnd = -2; diff --git a/src/core/lombok/javac/handlers/HandleGetter.java b/src/core/lombok/javac/handlers/HandleGetter.java index 0385a235..413404c0 100644 --- a/src/core/lombok/javac/handlers/HandleGetter.java +++ b/src/core/lombok/javac/handlers/HandleGetter.java @@ -308,7 +308,7 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> { synchronized (this.fieldName) { value = this.fieldName.get(); if (value == null) { - RawValueType actualValue = INITIALIZER_EXPRESSION; + final RawValueType actualValue = INITIALIZER_EXPRESSION; [IF PRIMITIVE] value = actualValue; [ELSE] @@ -361,7 +361,7 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> { /* if (value == null) { */ { ListBuffer<JCStatement> innerIfStatements = ListBuffer.lb(); - /* RawValueType actualValue = INITIALIZER_EXPRESSION; */ { + /* final RawValueType actualValue = INITIALIZER_EXPRESSION; */ { innerIfStatements.append(maker.VarDef(maker.Modifiers(Flags.FINAL), actualValueName, copyOfRawFieldType, field.init)); } /* [IF primitive] value = actualValue; */ { diff --git a/test/transform/resource/after-ecj/DelegateOnGetter.java b/test/transform/resource/after-ecj/DelegateOnGetter.java index 4eab3791..59f6a3b8 100644 --- a/test/transform/resource/after-ecj/DelegateOnGetter.java +++ b/test/transform/resource/after-ecj/DelegateOnGetter.java @@ -5,12 +5,12 @@ class DelegateOnGetter { void setList(java.util.ArrayList<java.lang.String> list); int getInt(); } - private final @Delegate @Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<Bar>> bar = new java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<Bar>>(); + private final @Delegate @Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.lang.Object> bar = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); DelegateOnGetter() { super(); } public @Delegate @java.lang.SuppressWarnings("all") Bar getBar() { - java.util.concurrent.atomic.AtomicReference<Bar> value = this.bar.get(); + java.lang.Object value = this.bar.get(); if ((value == null)) { synchronized (this.bar) @@ -28,12 +28,12 @@ class DelegateOnGetter { return 42; } }; - value = new java.util.concurrent.atomic.AtomicReference<Bar>(actualValue); + value = ((actualValue == null) ? this.bar : actualValue); this.bar.set(value); } } } - return value.get(); + return (Bar) ((value == this.bar) ? null : value); } public @java.lang.SuppressWarnings("all") int getInt() { return this.getBar().getInt(); diff --git a/test/transform/resource/after-ecj/GetterLazy.java b/test/transform/resource/after-ecj/GetterLazy.java index 0f5027b9..8394f58d 100644 --- a/test/transform/resource/after-ecj/GetterLazy.java +++ b/test/transform/resource/after-ecj/GetterLazy.java @@ -4,12 +4,12 @@ class GetterLazy { super(); } } - private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<ValueType>> fieldName = new java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<ValueType>>(); + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.lang.Object> fieldName = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); GetterLazy() { super(); } public @java.lang.SuppressWarnings("all") ValueType getFieldName() { - java.util.concurrent.atomic.AtomicReference<ValueType> value = this.fieldName.get(); + java.lang.Object value = this.fieldName.get(); if ((value == null)) { synchronized (this.fieldName) @@ -18,11 +18,11 @@ class GetterLazy { if ((value == null)) { final ValueType actualValue = new ValueType(); - value = new java.util.concurrent.atomic.AtomicReference<ValueType>(actualValue); + value = ((actualValue == null) ? this.fieldName : actualValue); this.fieldName.set(value); } } } - return value.get(); + return (ValueType) ((value == this.fieldName) ? null : value); } } diff --git a/test/transform/resource/after-ecj/GetterLazyBoolean.java b/test/transform/resource/after-ecj/GetterLazyBoolean.java index 8c890827..a51b164f 100644 --- a/test/transform/resource/after-ecj/GetterLazyBoolean.java +++ b/test/transform/resource/after-ecj/GetterLazyBoolean.java @@ -1,6 +1,6 @@ @lombok.EqualsAndHashCode(of = "booleanValue") @lombok.ToString(of = "booleanValue") class GetterLazyBoolean { - private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<java.lang.Boolean>> booleanValue = new java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<java.lang.Boolean>>(); - private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<java.lang.Boolean>> otherBooleanValue = new java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<java.lang.Boolean>>(); + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.lang.Object> booleanValue = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.lang.Object> otherBooleanValue = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); GetterLazyBoolean() { super(); } @@ -8,7 +8,7 @@ return true; } public @java.lang.SuppressWarnings("all") boolean isBooleanValue() { - java.util.concurrent.atomic.AtomicReference<java.lang.Boolean> value = this.booleanValue.get(); + java.lang.Object value = this.booleanValue.get(); if ((value == null)) { synchronized (this.booleanValue) @@ -17,15 +17,15 @@ if ((value == null)) { final boolean actualValue = calculateBoolean(); - value = new java.util.concurrent.atomic.AtomicReference<java.lang.Boolean>(actualValue); + value = actualValue; this.booleanValue.set(value); } } } - return value.get(); + return (java.lang.Boolean) value; } public @java.lang.SuppressWarnings("all") boolean isOtherBooleanValue() { - java.util.concurrent.atomic.AtomicReference<java.lang.Boolean> value = this.otherBooleanValue.get(); + java.lang.Object value = this.otherBooleanValue.get(); if ((value == null)) { synchronized (this.otherBooleanValue) @@ -34,12 +34,12 @@ if ((value == null)) { final boolean actualValue = (! calculateBoolean()); - value = new java.util.concurrent.atomic.AtomicReference<java.lang.Boolean>(actualValue); + value = actualValue; this.otherBooleanValue.set(value); } } } - return value.get(); + return (java.lang.Boolean) value; } public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) { if ((o == this)) diff --git a/test/transform/resource/after-ecj/GetterLazyEahcToString.java b/test/transform/resource/after-ecj/GetterLazyEahcToString.java index 1ca848af..db2d4fcf 100644 --- a/test/transform/resource/after-ecj/GetterLazyEahcToString.java +++ b/test/transform/resource/after-ecj/GetterLazyEahcToString.java @@ -1,11 +1,11 @@ @lombok.EqualsAndHashCode(doNotUseGetters = true) @lombok.ToString(doNotUseGetters = true) class GetterLazyEahcToString { - private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<String>> value = new java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<String>>(); + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.lang.Object> value = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); private final @lombok.Getter String value2 = ""; GetterLazyEahcToString() { super(); } public @java.lang.SuppressWarnings("all") String getValue() { - java.util.concurrent.atomic.AtomicReference<String> value = this.value.get(); + java.lang.Object value = this.value.get(); if ((value == null)) { synchronized (this.value) @@ -14,12 +14,12 @@ if ((value == null)) { final String actualValue = ""; - value = new java.util.concurrent.atomic.AtomicReference<String>(actualValue); + value = ((actualValue == null) ? this.value : actualValue); this.value.set(value); } } } - return value.get(); + return (String) ((value == this.value) ? null : value); } public @java.lang.SuppressWarnings("all") String getValue2() { return this.value2; diff --git a/test/transform/resource/after-ecj/GetterLazyNative.java b/test/transform/resource/after-ecj/GetterLazyNative.java index b67abfc9..db70f2f4 100644 --- a/test/transform/resource/after-ecj/GetterLazyNative.java +++ b/test/transform/resource/after-ecj/GetterLazyNative.java @@ -1,18 +1,18 @@ class GetterLazyNative { - private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<java.lang.Boolean>> booleanField = new java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<java.lang.Boolean>>(); - private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<java.lang.Byte>> byteField = new java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<java.lang.Byte>>(); - private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<java.lang.Short>> shortField = new java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<java.lang.Short>>(); - private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<java.lang.Integer>> intField = new java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<java.lang.Integer>>(); - private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<java.lang.Long>> longField = new java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<java.lang.Long>>(); - private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<java.lang.Float>> floatField = new java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<java.lang.Float>>(); - private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<java.lang.Double>> doubleField = new java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<java.lang.Double>>(); - private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<java.lang.Character>> charField = new java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<java.lang.Character>>(); - private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<int[]>> intArrayField = new java.util.concurrent.atomic.AtomicReference<java.util.concurrent.atomic.AtomicReference<int[]>>(); + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.lang.Object> booleanField = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.lang.Object> byteField = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.lang.Object> shortField = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.lang.Object> intField = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.lang.Object> longField = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.lang.Object> floatField = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.lang.Object> doubleField = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.lang.Object> charField = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.lang.Object> intArrayField = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); GetterLazyNative() { super(); } public @java.lang.SuppressWarnings("all") boolean isBooleanField() { - java.util.concurrent.atomic.AtomicReference<java.lang.Boolean> value = this.booleanField.get(); + java.lang.Object value = this.booleanField.get(); if ((value == null)) { synchronized (this.booleanField) @@ -21,15 +21,15 @@ class GetterLazyNative { if ((value == null)) { final boolean actualValue = true; - value = new java.util.concurrent.atomic.AtomicReference<java.lang.Boolean>(actualValue); + value = actualValue; this.booleanField.set(value); } } } - return value.get(); + return (java.lang.Boolean) value; } public @java.lang.SuppressWarnings("all") byte getByteField() { - java.util.concurrent.atomic.AtomicReference<java.lang.Byte> value = this.byteField.get(); + java.lang.Object value = this.byteField.get(); if ((value == null)) { synchronized (this.byteField) @@ -38,15 +38,15 @@ class GetterLazyNative { if ((value == null)) { final byte actualValue = 1; - value = new java.util.concurrent.atomic.AtomicReference<java.lang.Byte>(actualValue); + value = actualValue; this.byteField.set(value); } } } - return value.get(); + return (java.lang.Byte) value; } public @java.lang.SuppressWarnings("all") short getShortField() { - java.util.concurrent.atomic.AtomicReference<java.lang.Short> value = this.shortField.get(); + java.lang.Object value = this.shortField.get(); if ((value == null)) { synchronized (this.shortField) @@ -55,15 +55,15 @@ class GetterLazyNative { if ((value == null)) { final short actualValue = 1; - value = new java.util.concurrent.atomic.AtomicReference<java.lang.Short>(actualValue); + value = actualValue; this.shortField.set(value); } } } - return value.get(); + return (java.lang.Short) value; } public @java.lang.SuppressWarnings("all") int getIntField() { - java.util.concurrent.atomic.AtomicReference<java.lang.Integer> value = this.intField.get(); + java.lang.Object value = this.intField.get(); if ((value == null)) { synchronized (this.intField) @@ -72,15 +72,15 @@ class GetterLazyNative { if ((value == null)) { final int actualValue = 1; - value = new java.util.concurrent.atomic.AtomicReference<java.lang.Integer>(actualValue); + value = actualValue; this.intField.set(value); } } } - return value.get(); + return (java.lang.Integer) value; } public @java.lang.SuppressWarnings("all") long getLongField() { - java.util.concurrent.atomic.AtomicReference<java.lang.Long> value = this.longField.get(); + java.lang.Object value = this.longField.get(); if ((value == null)) { synchronized (this.longField) @@ -89,15 +89,15 @@ class GetterLazyNative { if ((value == null)) { final long actualValue = 1; - value = new java.util.concurrent.atomic.AtomicReference<java.lang.Long>(actualValue); + value = actualValue; this.longField.set(value); } } } - return value.get(); + return (java.lang.Long) value; } public @java.lang.SuppressWarnings("all") float getFloatField() { - java.util.concurrent.atomic.AtomicReference<java.lang.Float> value = this.floatField.get(); + java.lang.Object value = this.floatField.get(); if ((value == null)) { synchronized (this.floatField) @@ -106,15 +106,15 @@ class GetterLazyNative { if ((value == null)) { final float actualValue = 1.0f; - value = new java.util.concurrent.atomic.AtomicReference<java.lang.Float>(actualValue); + value = actualValue; this.floatField.set(value); } } } - return value.get(); + return (java.lang.Float) value; } public @java.lang.SuppressWarnings("all") double getDoubleField() { - java.util.concurrent.atomic.AtomicReference<java.lang.Double> value = this.doubleField.get(); + java.lang.Object value = this.doubleField.get(); if ((value == null)) { synchronized (this.doubleField) @@ -123,15 +123,15 @@ class GetterLazyNative { if ((value == null)) { final double actualValue = 1.0; - value = new java.util.concurrent.atomic.AtomicReference<java.lang.Double>(actualValue); + value = actualValue; this.doubleField.set(value); } } } - return value.get(); + return (java.lang.Double) value; } public @java.lang.SuppressWarnings("all") char getCharField() { - java.util.concurrent.atomic.AtomicReference<java.lang.Character> value = this.charField.get(); + java.lang.Object value = this.charField.get(); if ((value == null)) { synchronized (this.charField) @@ -140,15 +140,15 @@ class GetterLazyNative { if ((value == null)) { final char actualValue = '1'; - value = new java.util.concurrent.atomic.AtomicReference<java.lang.Character>(actualValue); + value = actualValue; this.charField.set(value); } } } - return value.get(); + return (java.lang.Character) value; } public @java.lang.SuppressWarnings("all") int[] getIntArrayField() { - java.util.concurrent.atomic.AtomicReference<int[]> value = this.intArrayField.get(); + java.lang.Object value = this.intArrayField.get(); if ((value == null)) { synchronized (this.intArrayField) @@ -157,11 +157,11 @@ class GetterLazyNative { if ((value == null)) { final int[] actualValue = new int[]{1}; - value = new java.util.concurrent.atomic.AtomicReference<int[]>(actualValue); + value = ((actualValue == null) ? this.intArrayField : actualValue); this.intArrayField.set(value); } } } - return value.get(); + return (int[]) ((value == this.intArrayField) ? null : value); } } |