[Closes #928] @Value no longer makes uninitialized static fields final

This commit is contained in:
Roel Spilker committed 2015-09-24 00:28:57 +02:00
1 parent 1bc73d7703
commit 9fbc226e09
6 files changed
+66 -4

No files matched your search

+1 -1
View File
@@ -2,7 +2,7 @@ Lombok Changelog
----------------
### v1.16.7 "Edgy Guinea Pig"
* New edge
* BUGFIX: `@Value` and `@FieldDefaults` no longer make uninitialized static fields final. [Issue #928](https://github.com/rzwitserloot/lombok/issues/928).
### v1.16.6 (August 18th, 2015)
* FEATURE: `@Helper` can be placed on method-local inner classes to make all methods in the class accessible to the rest of the method. [Full documentation](https://projectlombok.org/features/experimental/Helper.html).
@@ -96,7 +96,9 @@ public class HandleFieldDefaults extends EclipseAnnotationHandler<FieldDefaults>
if (makeFinal && (field.modifiers & ClassFileConstants.AccFinal) == 0) {
if (!hasAnnotation(NonFinal.class, fieldNode)) {
field.modifiers |= ClassFileConstants.AccFinal;
if ((field.modifiers & ClassFileConstants.AccStatic) == 0 || field.initialization != null) {
field.modifiers |= ClassFileConstants.AccFinal;
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2012-2014 The Project Lombok Authors.
* Copyright (C) 2012-2015 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
@@ -90,7 +90,9 @@ public class HandleFieldDefaults extends JavacAnnotationHandler<FieldDefaults> {
if (makeFinal && (field.mods.flags & Flags.FINAL) == 0) {
if (!hasAnnotationAndDeleteIfNeccessary(NonFinal.class, fieldNode)) {
field.mods.flags |= Flags.FINAL;
if ((field.mods.flags & Flags.STATIC) == 0 || field.init != null) {
field.mods.flags |= Flags.FINAL;
}
}
}
@@ -0,0 +1,29 @@
final class ValueStaticField {
private static int x;
private static final String PASSWORD = "Ken sent me";
@java.lang.SuppressWarnings("all")
@javax.annotation.Generated("lombok")
public ValueStaticField() {
}
@java.lang.Override
@java.lang.SuppressWarnings("all")
@javax.annotation.Generated("lombok")
public boolean equals(final java.lang.Object o) {
if (o == this) return true;
if (!(o instanceof ValueStaticField)) return false;
return true;
}
@java.lang.Override
@java.lang.SuppressWarnings("all")
@javax.annotation.Generated("lombok")
public int hashCode() {
int result = 1;
return result;
}
@java.lang.Override
@java.lang.SuppressWarnings("all")
@javax.annotation.Generated("lombok")
public java.lang.String toString() {
return "ValueStaticField()";
}
}
@@ -0,0 +1,24 @@
import lombok.Value;
final @Value class ValueStaticField {
private static int x;
private static final String PASSWORD = "Ken sent me";
<clinit>() {
}
public @java.lang.Override @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") boolean equals(final java.lang.Object o) {
if ((o == this))
return true;
if ((! (o instanceof ValueStaticField)))
return false;
return true;
}
public @java.lang.Override @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") int hashCode() {
int result = 1;
return result;
}
public @java.lang.Override @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") java.lang.String toString() {
return "ValueStaticField()";
}
public @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") ValueStaticField() {
super();
}
}
@@ -0,0 +1,5 @@
import lombok.Value;
@Value class ValueStaticField {
static int x;
static String PASSWORD = "Ken sent me";
}