JDK-8058322 : Zero name_index item of MethodParameters attribute cause MalformedParameterException.
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 8,9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2014-09-12
  • Updated: 2024-10-24
  • Resolved: 2014-11-11
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.
JDK 9 Other
9 b42Fixed openjdk8u442Fixed
Related Reports
Blocks :  
Duplicate :  
Duplicate :  
Description
JVMS says:
"If the value of the name_index item is zero, then this parameters element indicates a formal parameter with no name. "

But j.l.r.Executable.getParameters() throw MalformedParameterExeption: Invalid parameter name "".
This looks as if parameter had empty-string name.

It is reproduced on Solaris with 8, 8u26, 9 and 9.0 
and on Windows 7 with 8u20.

Minimized test:
------------------------------------------------------------

public class Second {
    public static String method(int i){
        return "in";
    }

    public static void main(String[] args) throws NoSuchMethodException {
        Second.class.getMethod("method", int.class).getParameters();
    }

}
------------------------------------------------------------

After compilation (javac -parameters Second.java) MethodParameters attribute of "method" was changed from "0x0100110000;" to "0x0100000000;". Modified version is attached.

The following JCK test will fail due to this bug: vm/classfmt/atr/atrmtp003/atrmtp00303m1/atrmtp00303m1.
Comments
A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk8u-dev/pull/592 Date: 2024-10-08 17:11:01 +0000
08-10-2024

Fix Request [8u]: Core reflection in JDK 8 currently is not accepting compliant class files conforming to JVMS, compiled by JDK 21 or later that include MethodParameters attribute with 0-index names. The fix is clean: the relevant section of code has not been changed in 8u, and this patch has no extra dependencies. See JDK-8341145 for the output of javac for JDK 21 and later.
08-10-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk8u/pull/63 Date: 2024-10-08 12:54:02 +0000
08-10-2024

URL: http://hg.openjdk.java.net/jdk9/jdk9/hotspot/rev/83c20afb7a9e User: lana Date: 2014-12-10 19:54:57 +0000
10-12-2014

URL: http://hg.openjdk.java.net/jdk9/hs-rt/hotspot/rev/83c20afb7a9e User: emc Date: 2014-11-11 02:23:51 +0000
11-11-2014

Out for review: http://cr.openjdk.java.net/~emc/8058322/
29-10-2014

Root cause: hotspot translates 0 entries into "". This was intended to be removed at some point, but never was.
21-10-2014

According to the spec, a MethodParameters attribute with index 0 does indeed have no name. Likely, it's getting translated into "" somewhere in the reflection API.
21-10-2014

ILW: H (Spec conformance issue), L (manually edit class file to reproduce), L (have a correct class file): -> P4 Eric, this looks like a reflection issue, observable only with a slightly malformed class file.
19-09-2014

Konstantin, I can't get this to reproduce, can you add details about exactly which version of the jdk you use?
18-09-2014

I have testes the attached class file on 8, 8u26, 9 and 9.0 on Solaris. In all cases I get this exception.
18-09-2014