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

Translate TypeNotPresentException to NoClassDefFoundError #19

Merged
merged 1 commit into from
Sep 25, 2017

Conversation

babsingh
Copy link
Contributor

While resolving bootstrap method handles, TypeNotPresentException is
currently thrown if a class is not found since we rely upon the
MethodType API. But, NoClassDefFoundError should be thrown if a class
is not found while resolving bootstrap method handles. This change
translates TypeNotPresentException to NoClassDefFoundError while
resolving bootstrap method handles.

Signed-off-by: Babneet Singh [email protected]

try {
type = MethodType.fromMethodDescriptorString(methodDescriptor, VM.getVMLangAccess().getClassloader(clazz));
} catch (TypeNotPresentException e) {
throwNoClassDefFoundError(e);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One way to make it easier to reason about this code is to write the call as:

throw throwNoClassDefFoundError(e);

so that readers know that an exception is guaranteed to be thrown here and there is no path to continue to the code below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

try {
cpEntry = getCPMethodTypeAt(clazz, index);
} catch (TypeNotPresentException e) {
throwNoClassDefFoundError(e);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here throw throwNoClassDefFoundError(e);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

* Throw NoClassDefFoundError if the cause of TypeNotPresentException is
* ClassNotFoundException. Otherwise, re-throw TypeNotPresentException.
*/
private static void throwNoClassDefFoundError(TypeNotPresentException e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this should be declared as:

private static Throwable throwNoClassDefFoundError(TypeNotPresentException e)  {

Even though its declared to return the Throwable, it should still throw the exception itself. This is just a pattern to make it easier for the caller to make it explicit that there is no fall through case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

NoClassDefFoundError noClassDefFoundError = new NoClassDefFoundError(cause.getMessage());
noClassDefFoundError.initCause(cause);
throw noClassDefFoundError;
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the if block unconditionally throws, the else isn't necessary. The throw e can follow the end of the if block. This makes again makes it clearer that there is no fall through path here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

@babsingh babsingh force-pushed the jcl_tnpe_to_ncdfe branch 2 times, most recently from 05a3122 to 2cf2c88 Compare September 15, 2017 06:07
@genie-openj9
Copy link

Can one of the admins verify this patch?

2 similar comments
@genie-openj9
Copy link

Can one of the admins verify this patch?

@genie-openj9
Copy link

Can one of the admins verify this patch?

@babsingh babsingh changed the title Translate TypeNotPresentException to NoClassDefFoundError WIP: Translate TypeNotPresentException to NoClassDefFoundError Sep 20, 2017
Copy link
Member

@DanHeidinga DanHeidinga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor doc fixup and then this is ready

* Throw NoClassDefFoundError if the cause of TypeNotPresentException is
* ClassNotFoundException. Otherwise, re-throw TypeNotPresentException.
*/
private static Throwable noClassDefFoundError(TypeNotPresentException e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add proper javadoc for this method? Also, to match the naming convention for this kind of method, can you prepend it with throw aka throwNoClassDefFoundError(...)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

@babsingh babsingh force-pushed the jcl_tnpe_to_ncdfe branch 3 times, most recently from b707b10 to 8473390 Compare September 25, 2017 15:38
@babsingh babsingh changed the title WIP: Translate TypeNotPresentException to NoClassDefFoundError Translate TypeNotPresentException to NoClassDefFoundError Sep 25, 2017
While resolving bootstrap method handles, TypeNotPresentException is
currently thrown if a class is not found since we rely upon the
MethodType API.  But, NoClassDefFoundError should be thrown if a class
is not found while resolving bootstrap method handles. This change
translates TypeNotPresentException to NoClassDefFoundError while
resolving bootstrap method handles.

Signed-off-by: Babneet Singh <[email protected]>
@DanHeidinga
Copy link
Member

Jenkins test sanity

@DanHeidinga DanHeidinga merged commit a0c8d18 into eclipse-openj9:master Sep 25, 2017
@babsingh babsingh deleted the jcl_tnpe_to_ncdfe branch September 25, 2017 19:06
@pshipton pshipton added the bug label Sep 28, 2017
amicic pushed a commit to amicic/openj9 that referenced this pull request Jan 16, 2018
Allow Object methods in invokeinterface
tajila pushed a commit to tajila/openj9 that referenced this pull request Jul 11, 2019
- segment memory allocation and free
- no support for compressed refs
- bug fixes for jvmimageport functions (imem)
- increased heap size

Signed-off-by: akshayben <[email protected]>
tajila pushed a commit to tajila/openj9 that referenced this pull request Jul 11, 2019
* Register Class into Table (eclipse-openj9#23)

- register performed in createramclass
- added register functions into internalfuncs
- changed naming scheme

Signed-off-by: akshayben <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants