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

Making the ThinkDifferent classes be JDK version-independent. JDK 9… #5747

Closed
wants to merge 5 commits into from

Conversation

ssilverman
Copy link

@ssilverman ssilverman commented Jan 7, 2019

… and later have a new java.awt.desktop package that replaces the custom handlers in the com.apple.eawt package. This commit uses java.lang.reflect.Proxy to generate handlers of the correct type, independent of the handler parameter types, which are different across JDK versions.

Specifically, this fixes being able to run a Processing app (externally or otherwise) on OSX using a JDK having a version > 1.8 (i.e. 9 and above).

… and later have a new java.awt.desktop package that replaces the custom handlers in the com.apple.eawt package. This commit uses java.lang.reflect.Proxy to generate handlers of the correct type.
@ssilverman
Copy link
Author

Fixes bug: #5746.

@ssilverman ssilverman changed the title Making the ThinkDifferent classes be JVM version-independent. JDK 1.9… Making the ThinkDifferent classes be JVM version-independent. JDK 9… Jan 7, 2019
@ssilverman ssilverman changed the title Making the ThinkDifferent classes be JVM version-independent. JDK 9… Making the ThinkDifferent classes be JDK version-independent. JDK 9… Jan 7, 2019

// public ThinkDifferent(Base base) {
// this.base = base;
// }

/**
* Sets a handler on an instance of {@link Application}, taking into account JVM version
Copy link
Author

Choose a reason for hiding this comment

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

Should say "JDK version", but I don't want to make a new commit.

Copy link
Contributor

Choose a reason for hiding this comment

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

No, JVM is correct.

Copy link
Author

Choose a reason for hiding this comment

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

My thinking on this is that the JDK includes the JVM plus libraries and other misc. stuff. You could theoretically change package names in the JDK 1.8 class files to JDK11-compliant names (eg. change com.apple.eawt to java.awt.desktop), and then run them on an older JVM (subject to only non-native code, etc). So my view is that this is still a JDK difference and not a JVM difference. JVM, in my mind, includes bytecodes plus support, and doesn't include the libraries (with some exceptions, eg. invokedynamic implementation).

Copy link
Author

Choose a reason for hiding this comment

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

Some links:

  1. https://www.javaworld.com/article/3272244/core-java/what-is-the-jvm-introducing-the-java-virtual-machine.html
  2. https://en.wikipedia.org/wiki/Java_virtual_machine

It is my belief that these support my view of libraries, including the AWT, being part of the larger meaning of a "JDK" and not "JVM", especially in this instance, where the only major difference is the package name.

Copy link
Author

Choose a reason for hiding this comment

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

Regarding me not wanting to make a "new commit", above, I've discovered that any new commits update this pull request. Makes life easier... :)

Copy link
Author

Choose a reason for hiding this comment

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

To play devil's advocate with myself: Originally, "Java" was defined as a JVM plus libraries plus language, so in reality, I think the lines are kind of fuzzy anyway. I won't object to whatever's chosen, "JVM" or "JDK".

@benfry
Copy link
Contributor

benfry commented Jan 22, 2019

Instead of using reflection throughout, a better option is to invoke the necessary class that will work for the platform in use. Debugging code that's using this much reflection is a nightmare (we know because we've gone through lots of Java versions, all the way back to 1.1).

Though to avoid these kinds of problems, if we move to Java 11, we'll likely do that and not provide any backwards compatibility (as discussed in #5753).

@ssilverman
Copy link
Author

ssilverman commented Jan 22, 2019

What do you mean by invoke the necessary class? Are you saying have a compiled version for JDK 1.8 and another for JDK 11?

My use of Processing is as part of a larger system. I use the core classes essentially as an easy-to-use graphics layer. I build my projects using Maven so I just use the core classes. However, I have to have different compiled versions of those classes for each JDK version because of those desktop package name changes.

My goal with this pull request was to make it so the exact same set of compiled classes work across both JDK versions (8 & 11). If you don’t think that’s a tenable approach here, that okay, since it’s easy enough to just have to create two separate JAR versions. I’d rather be able to use one JAR file, but it’s not critical.

I support the concept of moving to 11-only support, though.

@benfry
Copy link
Contributor

benfry commented Jan 17, 2020

Fixed with benfry/processing4#1 and continued development happening at https://github.com/processing/processing4

@benfry benfry closed this Jan 17, 2020
@processing processing locked as resolved and limited conversation to collaborators Jan 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants