Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method.invoke presents different exception messages when invoking multiple times a method with wrong argument type #1835

Closed
non-conformances-research opened this issue May 4, 2018 · 6 comments
Labels

Comments

@non-conformances-research
Copy link
Contributor

The following program presents a null exception message after invoking 17 times a method with wrong argument type.

import java.lang.reflect.Method;
public class A {
public static void main(String[] args) throws NoSuchMethodException {
A a = new A();
for (int i = 0; i < 17; i++) {
Method method = A.class.getMethod("wait", long.class);
try {
method.invoke(a, "0");
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}
}

Affected versions:

openjdk version "1.8.0_162"
OpenJDK Runtime Environment (build 1.8.0_162-b12)
Eclipse OpenJ9 VM (build openj9-0.8.0, JRE 1.8.0 Linux amd64-64 Compressed References 20180315_120 (JIT enabled, AOT enabled)
OpenJ9 - e24e8aa
OMR - 3e8296b
JCL - ee1e77df1d based on jdk8u162-b12)

Steps to reproduce:

1. Compile above program
2. Run it using openj9 java

Current result:

argument type mismatch (x16)
null

Expected result:

Always print "argument type mismatch" message.

@DanHeidinga
Copy link
Member

Interesting bug. Given this occurs at the 17 invocation mark, it may be related to bytecode generation for reflect methods.

@JasonFengJ9
Copy link
Member

Happened to RI as well.

java version "9.0.4"
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)
argument type mismatch
argument type mismatch
argument type mismatch
argument type mismatch
argument type mismatch
argument type mismatch
argument type mismatch
argument type mismatch
argument type mismatch
argument type mismatch
argument type mismatch
argument type mismatch
argument type mismatch
argument type mismatch
argument type mismatch
argument type mismatch
null

It appears a JCL bug in OpenJDK.

@pdbain-ibm
Copy link
Contributor

Does the problem manifest with -Xint?

@pshipton
Copy link
Member

pshipton commented May 7, 2018

Does it still occur with Java 10 or 11?

@JasonFengJ9
Copy link
Member

JasonFengJ9 commented May 7, 2018

It still occurs with Java 10 & 11 as well.

java version "10-ea" 2018-03-20
Java(TM) SE Runtime Environment 18.3 (build 10-ea+42)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10-ea+42, mixed mode)
wrong number of arguments
...
wrong number of arguments
null

java version "11-ea" 2018-09-25
Java(TM) SE Runtime Environment 18.9 (build 11-ea+11)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11-ea+11, interpreted mode)
wrong number of arguments
...
wrong number of arguments
null

-Xint makes no difference.

@pshipton
Copy link
Member

pshipton commented May 7, 2018

@felipepontes-research please report this and similar issues to the OpenJDK project, it is not an OpenJ9 problem.

@pshipton pshipton closed this as completed May 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants