From 0d75d56fcef943d1a35f1169386830066371c12d Mon Sep 17 00:00:00 2001 From: peichhorn Date: Sun, 13 Nov 2011 09:02:55 +0100 Subject: Eclipse/JavacHandlerUtil.injectField(...) inserts the new fields after the enum constants. Also the new fields are ordered in the same way the method injectField() gets invoked. --- .../resource/after-delombok/InjectField.java | 59 ++++++++++++++++++++++ .../resource/after-delombok/SynchronizedPlain.java | 8 +-- 2 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 test/transform/resource/after-delombok/InjectField.java (limited to 'test/transform/resource/after-delombok') diff --git a/test/transform/resource/after-delombok/InjectField.java b/test/transform/resource/after-delombok/InjectField.java new file mode 100644 index 00000000..a9b4b1c4 --- /dev/null +++ b/test/transform/resource/after-delombok/InjectField.java @@ -0,0 +1,59 @@ +import java.util.logging.Level; + +enum InjectField1 { + A, + B; + + private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(InjectField1.class.getName()); + @java.lang.SuppressWarnings("all") + private final java.lang.Object $lock = new java.lang.Object[0]; + @java.lang.SuppressWarnings("all") + private static final java.lang.Object $LOCK = new java.lang.Object[0]; + + private static final String LOG_MESSAGE = "static initializer"; + + private String fieldA; + + static { + log.log(Level.FINE, LOG_MESSAGE); + } + + private String fieldB; + + void generateLockField() { + synchronized (this.$lock) { + System.out.println("lock field"); + } + } + + static void generateStaticLockField() { + synchronized (InjectField1.$LOCK) { + System.out.println("static lock field"); + } + } +} + +class InjectField2 { + private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(InjectField2.class.getName()); + @java.lang.SuppressWarnings("all") + private final java.lang.Object $lock = new java.lang.Object[0]; + + private static final String LOG_MESSAGE = "static initializer"; + + static { + log.log(Level.FINE, LOG_MESSAGE); + } + + void generateLockField() { + synchronized (this.$lock) { + System.out.println("lock field"); + } + } +} + +class InjectField3 { + private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(InjectField3.class.getName()); + static { + log.log(Level.FINE, "static initializer"); + } +} \ No newline at end of file diff --git a/test/transform/resource/after-delombok/SynchronizedPlain.java b/test/transform/resource/after-delombok/SynchronizedPlain.java index 695a3089..1a065085 100644 --- a/test/transform/resource/after-delombok/SynchronizedPlain.java +++ b/test/transform/resource/after-delombok/SynchronizedPlain.java @@ -1,4 +1,6 @@ class SynchronizedPlain1 { + @java.lang.SuppressWarnings("all") + private final java.lang.Object $lock = new java.lang.Object[0]; void test() { synchronized (this.$lock) { System.out.println("one"); @@ -9,10 +11,10 @@ class SynchronizedPlain1 { System.out.println("two"); } } - @java.lang.SuppressWarnings("all") - private final java.lang.Object $lock = new java.lang.Object[0]; } class SynchronizedPlain2 { + @java.lang.SuppressWarnings("all") + private static final java.lang.Object $LOCK = new java.lang.Object[0]; static void test() { synchronized (SynchronizedPlain2.$LOCK) { System.out.println("three"); @@ -23,6 +25,4 @@ class SynchronizedPlain2 { System.out.println("four"); } } - @java.lang.SuppressWarnings("all") - private static final java.lang.Object $LOCK = new java.lang.Object[0]; } \ No newline at end of file -- cgit