-
Bug
-
Resolution: Unresolved
-
P4
-
None
-
6
-
Cause Known
-
sparc
-
solaris_9
FULL PRODUCT VERSION :
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Server VM (build 1.6.0-b105, mixed mode
ADDITIONAL OS VERSION INFORMATION :
SunOS ceti.umiacs.umd.edu 5.9 gspot:s9u2_beta:07/09/2003 sun4u sparc SUNW,Sun-Fire
A DESCRIPTION OF THE PROBLEM :
The javadoc for java.lang.Class.getSimpleName() states "Returns an empty string if the underlying class is anonymous."
However, if the class was compiled with a target of 1.4 or earlier, this is violated. Instead, it strips off the package name but leaves the rest of the class name.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile these two classes and run TestSimpleName
public class SimpleNameTest {
static Object test = new Object() {
public String toString() {
return "test";
}
};
}
public class TestSimpleName {
public static void main(String args[]) throws Exception {
System.out.println("'" + SimpleNameTest.test.getClass().getSimpleName() + "'");
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Running TestSimpleName should always print ''
ACTUAL -
If SimpleNameTest was compiled using javac 1.4, or compiled with Java SE 5 or Java SE 6 with a target of 1.4 or jsr14, then running TestSimpleName will print 'SimpleNameTest$1'
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class SimpleNameTest {
static Object test = new Object() {
public String toString() {
return "test";
}
};
}
public class TestSimpleName {
public static void main(String args[]) throws Exception {
System.out.println("'" + SimpleNameTest.test.getClass().getSimpleName() + "'");
}
}
---------- END SOURCE ----------
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Server VM (build 1.6.0-b105, mixed mode
ADDITIONAL OS VERSION INFORMATION :
SunOS ceti.umiacs.umd.edu 5.9 gspot:s9u2_beta:07/09/2003 sun4u sparc SUNW,Sun-Fire
A DESCRIPTION OF THE PROBLEM :
The javadoc for java.lang.Class.getSimpleName() states "Returns an empty string if the underlying class is anonymous."
However, if the class was compiled with a target of 1.4 or earlier, this is violated. Instead, it strips off the package name but leaves the rest of the class name.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile these two classes and run TestSimpleName
public class SimpleNameTest {
static Object test = new Object() {
public String toString() {
return "test";
}
};
}
public class TestSimpleName {
public static void main(String args[]) throws Exception {
System.out.println("'" + SimpleNameTest.test.getClass().getSimpleName() + "'");
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Running TestSimpleName should always print ''
ACTUAL -
If SimpleNameTest was compiled using javac 1.4, or compiled with Java SE 5 or Java SE 6 with a target of 1.4 or jsr14, then running TestSimpleName will print 'SimpleNameTest$1'
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class SimpleNameTest {
static Object test = new Object() {
public String toString() {
return "test";
}
};
}
public class TestSimpleName {
public static void main(String args[]) throws Exception {
System.out.println("'" + SimpleNameTest.test.getClass().getSimpleName() + "'");
}
}
---------- END SOURCE ----------
- relates to
-
JDK-4891872 (reflect) Extend reflection to support generics, metadata and JSR201 features
- Resolved