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

Fixes java mode loading #3444

Merged
merged 4 commits into from Jul 9, 2015
Merged

Fixes java mode loading #3444

merged 4 commits into from Jul 9, 2015

Conversation

@Manindra29
Copy link
Member

@Manindra29 Manindra29 commented Jul 1, 2015

If the NoClassDefFoundError is caught for JavaMode, reinits the urlclassloader. (fixes #3443)

Manindra29 added 3 commits Jun 30, 2015
Signed-off-by: Manindra Moharana <mkmoharana29@gmail.com>
@Manindra29 Manindra29 changed the title Fixes java mode loading #3443 Fixes java mode loading Jul 1, 2015
@benfry
Copy link
Member

@benfry benfry commented Jul 3, 2015

This is a really hacky approach and only gets it working with Java Mode...

We already have the idea of the imports entry in the .properties file, a better option would likely be to include the import for Java Mode in there, and then use that to figure out which classes need to be loaded. So you'd include:

imports=processing.mode.java

in your mode.properties file, and we'd iterate through the modes to find the right classes, then read those JARs from the new mode's ClassLoader.

On a quick glance, it also looks like your approach is stealing the ClassLoader of JavaMode and polluting it with the subclassing Mode's classes, which is also a bad idea, because it would mean other Modes would be capable of breaking the default mode, and therefore completely hosing Processing.

@Manindra29
Copy link
Member Author

@Manindra29 Manindra29 commented Jul 7, 2015

@benfry I wasn't aware of the imports field in mode.properties. I've updated the PR as you suggested. Now dependencies are loaded by classname. If mode.properties has:

imports=processing.mode.java.JavaMode

The installed modes are searched for a class name matching processing.mode.java.JavaMode. If such a Mode is found, all of its jars are added to the urlclassloader. This method feels much cleaner.

(This works with REPLMode)

@codeanticode
Copy link
Member

@codeanticode codeanticode commented Jul 8, 2015

Tested the android mode, it works now!

benfry added a commit that referenced this pull request Jul 9, 2015
@benfry benfry merged commit 85184bb into master Jul 9, 2015
@benfry
Copy link
Member

@benfry benfry commented Jul 9, 2015

Thanks for fixing.

@benfry benfry deleted the fixJavaModeLoading branch Aug 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants
You can’t perform that action at this time.