ADDITIONAL SYSTEM INFORMATION :
OS OSX
java version "15" 2020-09-15
Java(TM) SE Runtime Environment (build 15+36-1562)
Java HotSpot(TM) 64-Bit Server VM (build 15+36-1562, mixed mode, sharing)
javap version 15
A DESCRIPTION OF THE PROBLEM :
Assembly class file include String which has spaces character at last ( e.g. " 123 " ) and last spaces is cut ( e.g. " 123" ) .
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile java source.
javac Test.java
public class Test {
public void test1() {
String = " 123 ";
}
}
2. Assembly class file and got Expected Result.
javap -v Test.class
3. And this output of string last spaces is cut.
For example
// 123
// String 123
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Compiled from "Test.java"
public class Test
minor version: 0
major version: 59
flags: (0x0021) ACC_PUBLIC, ACC_SUPER
this_class: #9 // Test
super_class: #2 // java/lang/Object
interfaces: 0, fields: 0, methods: 2, attributes: 1
Constant pool:
#1 = Methodref #2.#3 // java/lang/Object."<init>":()V
#2 = Class #4 // java/lang/Object
#3 = NameAndType #5:#6 // "<init>":()V
#4 = Utf8 java/lang/Object
#5 = Utf8 <init>
#6 = Utf8 ()V
#7 = String #8 // 123
#8 = Utf8 123
#9 = Class #10 // Test
#10 = Utf8 Test
#11 = Utf8 Code
#12 = Utf8 LineNumberTable
#13 = Utf8 test1
#14 = Utf8 SourceFile
#15 = Utf8 Test.java
{
public Test();
descriptor: ()V
flags: (0x0001) ACC_PUBLIC
Code:
stack=1, locals=1, args_size=1
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return
LineNumberTable:
line 3: 0
public void test1();
descriptor: ()V
flags: (0x0001) ACC_PUBLIC
Code:
stack=1, locals=2, args_size=1
0: ldc #7 // String 123
2: astore_1
3: return
LineNumberTable:
line 6: 0
line 35: 3
}
ACTUAL -
Compiled from "Test.java"
public class Test
minor version: 0
major version: 59
flags: (0x0021) ACC_PUBLIC, ACC_SUPER
this_class: #9 // Test
super_class: #2 // java/lang/Object
interfaces: 0, fields: 0, methods: 2, attributes: 1
Constant pool:
#1 = Methodref #2.#3 // java/lang/Object."<init>":()V
#2 = Class #4 // java/lang/Object
#3 = NameAndType #5:#6 // "<init>":()V
#4 = Utf8 java/lang/Object
#5 = Utf8 <init>
#6 = Utf8 ()V
!CHANGED THIS↓ LINE!
#7 = String #8 // 123 ;
#8 = Utf8 123
#9 = Class #10 // Test
#10 = Utf8 Test
#11 = Utf8 Code
#12 = Utf8 LineNumberTable
#13 = Utf8 test1
#14 = Utf8 SourceFile
#15 = Utf8 Test.java
{
public Test();
descriptor: ()V
flags: (0x0001) ACC_PUBLIC
Code:
stack=1, locals=1, args_size=1
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return
LineNumberTable:
line 3: 0
public void test1();
descriptor: ()V
flags: (0x0001) ACC_PUBLIC
Code:
stack=1, locals=2, args_size=1
!CHANGED THIS↓ LINE!
0: ldc #7 // String 123 ;
2: astore_1
3: return
LineNumberTable:
line 6: 0
line 35: 3
}
---------- BEGIN SOURCE ----------
public class Test {
public void test1() {
String = " 123 ";
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
nothing
But I know that terminal stdout is ignore some spaces character so I tried redirect like this.
javap -v Test.class > out.txt
But also last spaces was cut.
FREQUENCY : always
OS OSX
java version "15" 2020-09-15
Java(TM) SE Runtime Environment (build 15+36-1562)
Java HotSpot(TM) 64-Bit Server VM (build 15+36-1562, mixed mode, sharing)
javap version 15
A DESCRIPTION OF THE PROBLEM :
Assembly class file include String which has spaces character at last ( e.g. " 123 " ) and last spaces is cut ( e.g. " 123" ) .
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile java source.
javac Test.java
public class Test {
public void test1() {
String = " 123 ";
}
}
2. Assembly class file and got Expected Result.
javap -v Test.class
3. And this output of string last spaces is cut.
For example
// 123
// String 123
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Compiled from "Test.java"
public class Test
minor version: 0
major version: 59
flags: (0x0021) ACC_PUBLIC, ACC_SUPER
this_class: #9 // Test
super_class: #2 // java/lang/Object
interfaces: 0, fields: 0, methods: 2, attributes: 1
Constant pool:
#1 = Methodref #2.#3 // java/lang/Object."<init>":()V
#2 = Class #4 // java/lang/Object
#3 = NameAndType #5:#6 // "<init>":()V
#4 = Utf8 java/lang/Object
#5 = Utf8 <init>
#6 = Utf8 ()V
#7 = String #8 // 123
#8 = Utf8 123
#9 = Class #10 // Test
#10 = Utf8 Test
#11 = Utf8 Code
#12 = Utf8 LineNumberTable
#13 = Utf8 test1
#14 = Utf8 SourceFile
#15 = Utf8 Test.java
{
public Test();
descriptor: ()V
flags: (0x0001) ACC_PUBLIC
Code:
stack=1, locals=1, args_size=1
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return
LineNumberTable:
line 3: 0
public void test1();
descriptor: ()V
flags: (0x0001) ACC_PUBLIC
Code:
stack=1, locals=2, args_size=1
0: ldc #7 // String 123
2: astore_1
3: return
LineNumberTable:
line 6: 0
line 35: 3
}
ACTUAL -
Compiled from "Test.java"
public class Test
minor version: 0
major version: 59
flags: (0x0021) ACC_PUBLIC, ACC_SUPER
this_class: #9 // Test
super_class: #2 // java/lang/Object
interfaces: 0, fields: 0, methods: 2, attributes: 1
Constant pool:
#1 = Methodref #2.#3 // java/lang/Object."<init>":()V
#2 = Class #4 // java/lang/Object
#3 = NameAndType #5:#6 // "<init>":()V
#4 = Utf8 java/lang/Object
#5 = Utf8 <init>
#6 = Utf8 ()V
!CHANGED THIS↓ LINE!
#7 = String #8 // 123 ;
#8 = Utf8 123
#9 = Class #10 // Test
#10 = Utf8 Test
#11 = Utf8 Code
#12 = Utf8 LineNumberTable
#13 = Utf8 test1
#14 = Utf8 SourceFile
#15 = Utf8 Test.java
{
public Test();
descriptor: ()V
flags: (0x0001) ACC_PUBLIC
Code:
stack=1, locals=1, args_size=1
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return
LineNumberTable:
line 3: 0
public void test1();
descriptor: ()V
flags: (0x0001) ACC_PUBLIC
Code:
stack=1, locals=2, args_size=1
!CHANGED THIS↓ LINE!
0: ldc #7 // String 123 ;
2: astore_1
3: return
LineNumberTable:
line 6: 0
line 35: 3
}
---------- BEGIN SOURCE ----------
public class Test {
public void test1() {
String = " 123 ";
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
nothing
But I know that terminal stdout is ignore some spaces character so I tried redirect like this.
javap -v Test.class > out.txt
But also last spaces was cut.
FREQUENCY : always
- duplicates
-
JDK-8300631 javap fails to show the entire string with trailing space in constant pool
-
- Closed
-