-
Bug
-
Resolution: Fixed
-
P4
-
5.0
-
b31
-
generic
-
solaris_8
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8085016 | emb-9 | Joel Borggrén-Franck | P4 | Resolved | Fixed | team |
Tiger introduces a cache of commonly used wrapper instances, and a static
factory for returning them. The language requires caching Integers in the
range -128 to 127. But this cache is not used in the reflection
implementation, resulting in much unnecessary object creation when running
reflective code.
Here is a test case that illustrates the problem:
/////////////////////////////////////////////////////////
import java.lang.reflect.*;
class Main {
public static int f() { return 0; }
public static void main(String[] args) throws Exception {
Method m = Main.class.getMethod("f");
Object o1 = m.invoke(null);
Object o2 = m.invoke(null);
if (o1 != o2)
throw new Error(System.identityHashCode(o1) +
" " + System.identityHashCode(o2));
}
}
factory for returning them. The language requires caching Integers in the
range -128 to 127. But this cache is not used in the reflection
implementation, resulting in much unnecessary object creation when running
reflective code.
Here is a test case that illustrates the problem:
/////////////////////////////////////////////////////////
import java.lang.reflect.*;
class Main {
public static int f() { return 0; }
public static void main(String[] args) throws Exception {
Method m = Main.class.getMethod("f");
Object o1 = m.invoke(null);
Object o2 = m.invoke(null);
if (o1 != o2)
throw new Error(System.identityHashCode(o1) +
" " + System.identityHashCode(o2));
}
}
- backported by
-
JDK-8085016 (reflect) unnecessary object creation in reflection
- Resolved
- relates to
-
JDK-8060027 Tests java/beans/XMLEncoder/Test4903007.java and java/beans/XMLEncoder/java_awt_GridBagLayout.java
- Resolved
-
JDK-8162815 unnecessary object creation in reflection
- Closed