JDK-8244299 : java.lang.Class.getTypeName() swallows Throwables
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 8,11,14,15
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2020-05-02
  • Updated: 2024-06-13
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Description
A DESCRIPTION OF THE PROBLEM :
See java.lang.Class.getTypeName():
    public String getTypeName() {
        if (isArray()) {
            try {
                Class<?> cl = this;
                int dimensions = 0;
                do {
                    dimensions++;
                    cl = cl.getComponentType();
                } while (cl.isArray());
                return cl.getName() + "[]".repeat(dimensions);
            } catch (Throwable e) { /*FALLTHRU*/ }
        }
        return getName();
    }

This should probably be removed because it might hide serious problems with the JVM. It appears this originates from java.lang.reflect.Field.getTypeName(Class<?>), from where it was moved by JDK-6298888.



Comments
The code snip mentioned by the submitter can be found at JDK 8, 11 ,and also 14: https://hg.openjdk.java.net/jdk8/jdk8/jdk/file/3e5a18c3e599/src/share/classes/java/lang/Class.java#l1240 https://hg.openjdk.java.net/jdk/jdk11/file/0d6f88cca118/src/java.base/share/classes/java/lang/Class.java#l1553 https://hg.openjdk.java.net/jdk/jdk14/file/f7ab94fadd5a/src/java.base/share/classes/java/lang/Class.java#l1595 ILW=MLM=P4
04-05-2020