aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/lombok/bytecode/ClassFileMetaData.java13
-rw-r--r--test/bytecode/resource/Foo.java3
-rw-r--r--test/bytecode/src/lombok/bytecode/TestClassFileMetaData.java1
3 files changed, 9 insertions, 8 deletions
diff --git a/src/core/lombok/bytecode/ClassFileMetaData.java b/src/core/lombok/bytecode/ClassFileMetaData.java
index 794705cb..68b8bb7d 100644
--- a/src/core/lombok/bytecode/ClassFileMetaData.java
+++ b/src/core/lombok/bytecode/ClassFileMetaData.java
@@ -214,6 +214,7 @@ public class ClassFileMetaData {
* Checks if the constant pool contains the provided string constant, which implies the constant is used somewhere in the code.
*
* NB: String literals get concatenated by the compiler.
+ * NB2: This method does NOT do any kind of normalization.
*/
public boolean containsStringConstant(String value) {
int index = findUtf8(value);
@@ -282,25 +283,23 @@ public class ClassFileMetaData {
private long readLong(int index) {
int pos = offsets[index];
- return ((long)read32(pos)) << 32 | read32(pos + 4);
+ return ((long)read32(pos)) << 32 | (read32(pos + 4) & 0x00000000FFFFFFFFL);
}
private double readDouble(int index) {
- int pos = offsets[index];
- long bits = ((long)read32(pos)) << 32 | (read32(pos + 4) & 0x00000000FFFFFFFF);
- return Double.longBitsToDouble(bits);
+ return Double.longBitsToDouble(readLong(index));
}
- private long readInteger(int index) {
+ private int readInteger(int index) {
return read32(offsets[index]);
}
private float readFloat(int index) {
- return Float.intBitsToFloat(read32(offsets[index]));
+ return Float.intBitsToFloat(readInteger(index));
}
private int read32(int pos) {
- return (byteCode[pos] & 0xFF) << 24 | (byteCode[pos + 1] & 0xFF) << 16 | (byteCode[pos + 2] & 0xFF) << 8 | (byteCode[pos + 3] &0xFF);
+ return (byteCode[pos] & 0xFF) << 24 | (byteCode[pos + 1] & 0xFF) << 16 | (byteCode[pos + 2] & 0xFF) << 8 | (byteCode[pos + 3] & 0xFF);
}
/**
diff --git a/test/bytecode/resource/Foo.java b/test/bytecode/resource/Foo.java
index 2726026c..a7bb26af 100644
--- a/test/bytecode/resource/Foo.java
+++ b/test/bytecode/resource/Foo.java
@@ -1,6 +1,7 @@
public class Foo implements java.util.RandomAccess {
private static final long LONG = 123L;
- private static final String ONE = "Eén";
+ private static final long LONG_OVERFLOW = 0x1FFFFFFFFL;
+ private static final String ONE = "E\u00e9n";
private static final int INT = 123;
private static final double DOUBLE = 1.23;
private static final double DOUBLE_NAN = Double.NaN;
diff --git a/test/bytecode/src/lombok/bytecode/TestClassFileMetaData.java b/test/bytecode/src/lombok/bytecode/TestClassFileMetaData.java
index aaf7d2e9..2b506c1b 100644
--- a/test/bytecode/src/lombok/bytecode/TestClassFileMetaData.java
+++ b/test/bytecode/src/lombok/bytecode/TestClassFileMetaData.java
@@ -169,6 +169,7 @@ public class TestClassFileMetaData {
@Test
public void testContainsLong() {
assertTrue(foo.containsLong(123));
+ assertTrue(foo.containsLong(0x1FFFFFFFFL));
assertFalse(foo.containsLong(1));
assertFalse(buux.containsLong(1));