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

OpenJDK 11 / OpenJFX support #5753

Closed
wants to merge 111 commits into from
Closed

Conversation

sampottinger
Copy link

@sampottinger sampottinger commented Jan 14, 2019

Moves to OpenJDK11 as part of #5750. There's lots in here so a quick rundown of the bigger stuff...


Primary required changes:
Some changes directly support OpenJFX / OpenJDK 11:

  • Response to image loading changes caused by JEP 320
  • Use of jmodules as necessitated by JEP 261
  • Reponse to largely changed file paths caused by JEP 220.
  • Modifications in build system related to AdoptOpenJDK and Java 11 which have a different naming structure for downloads.
  • Allowing use of non-Oracle Java within internal Processing checks.

Secondary required changes:
There were some secondary required changes that impacted the usability of Processing after having moved to OpenJFX / OpenJDK 11:

  • Removal of com.apple.eawt calls related to JEP 272
  • Response to HiDPI support on Windows and Linux in JEP 263
  • Removal of java.ext.dirs. Would be forced by JEP 220.
  • Due to bugs on Windows, updated the JNA jars.
  • Changes in downloader build tasks to support AdoptOpenJDK and OpenJFX.
  • Updated org.eclipse.* / equinox jars.
  • Some optimization around size of distribution.
  • Update of AppBundler.
  • Some changes in formulation of classpath and modifications in PreprocessingService given JEP 261.

Incidental changes:
This was (ahem) a bit of a larger PR with the above modifications. So, I wanted to introduce automated tests when possible and convenient along with a few changes for platform sustainability in order to support development:

  • Addition of cross-building capability (!) made possible by AdoptOpenJDK.
  • Addition of mockito for testing.
  • Upgrade of junit.
  • Addition of ant-contrib.
  • Standardized nomenclature around JRE / JDK in build/build.xml
  • Deduplication of code in jre/build.xml.
  • Addition of JavaDoc in a few places.
  • Some refactoring of PImage / Shape to support increased testing and readability in image manipulation code.

ssilverman and others added 2 commits January 6, 2019 18:48
… 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.
Focusing first on getting "hello world" applications running under Java 11, this initial migration works for Mac OS X (10.14.1). There are a number of issues and warnings still to address so the overall PR remains WIP. Specific modifications to address processing#5750:

 - Modification in build system to address a unified JDK / JRE.
 - Modification in build system and application code to deal with version naming convention migration.
 - Modification of OS X specific system paths changed by Java 11.
 - Migration to OpenJDK (processing#4415) via AdoptOpenJDK (selected due to long term build support and some vendor independence).
 - Migration to OpenJFX (processing#5286).
 - Removal of deprecated `java.ext.dirs` (replacement funcationality is still being explored).
 - Update to the appbundler fork.
 - Update to the JDT jars.

Documentation is still incomplete as is reaching feature parity on mac as well as testing on other OS'. Please don't merge yet.
@sampottinger sampottinger changed the title [WIP] Java 11 support (#5750) [WIP] Java 11 support Jan 14, 2019
@sampottinger
Copy link
Author

Currently only tested on Mac. Documentation is still incomplete. Please don't merge yet.

@sampottinger
Copy link
Author

Note that this required use of #5747.

@benfry
Copy link
Contributor

benfry commented Jan 14, 2019

Great; also helpful that you're testing on a Mac, since this is where we're likely to see the most significant gaps/problems in compatibility.

@sampottinger
Copy link
Author

@benfry - Totally! I am doing some work in Linux right now.

General community - I just mentioned this in #5750 but I don't actually have access to windows currently (maybe I'll buy a copy if I am doing a bit of work here...). That said, is there anyone readily available with windows floating around willing to do a bit of a deeper dive into the JDK?

@benfry
Copy link
Contributor

benfry commented Jan 14, 2019

For anyone interested in fiddling with Windows but on another platform, Microsoft makes available virtual machine images for use in development/evaluation with VMware, Parallels, Virtual Box…

@sampottinger
Copy link
Author

Oh that's nifty. I did not know Microsoft did that. Thanks!

@benfry
Copy link
Contributor

benfry commented Jan 14, 2019

Yeah, I've paid out of pocket for several Windows licenses over the years for testing Processing, but nice that we have other options nowadays.

As part of processing#5750, added support for AdoptOpenJDK (also required for

 - OracleDownloadUrlGenerator
 - AdoptOpenJdkDownloadUrlGenerator

which support Downloader. Tests and documentation included
(required refactor of build.xml).
@benfry
Copy link
Contributor

benfry commented Jan 16, 2019

(Seeing the 32-bit warnings/workarounds…) If we make the move to Java 11 we also might want to drop 32-bit support. If you run into things where 32-bit support is making a mess (or not), just keep them in mind to help us make that decision.

As part of processing#5753 and processing#5750, working AdoptOpenJDK released java on
Elementary Linux 5.0 (Juno, 64bit). Linux 4.15.0-36-generic. Tested
with Java 11. JDK downloads working and PDE runs but sketches wont
execute due to broken java path.
As part of processing#5750 / processing#5753, example sketch and PDE running in Linux with Elementary 5.0 (Juno, 64bit). Linux 4.15.0-36-generic. Specifically, resolved issue with java path on linux given new JDK structure.
@sampottinger
Copy link
Author

Thanks @benfry! I appreciate it. I'll see how Windows goes but, at the least, I would recommend dropping Linux 32-bit support given what build are available from AdoptOpenJDK.

@sampottinger
Copy link
Author

Quick status update... I got PDE and an example sketch running under Linux (Elementary 5.0). I'll try to catalog / tackle a few issues that I noticed there but I want move to Windows next just to see if there is anything major.

As part of processing#5750 and processing#5753, have the development environment and example sketch working in Windows 64 bit with some display issues in the IDE in particular. This is using AdoptOpenJDK 11 with Windows 10.
@sampottinger
Copy link
Author

sampottinger commented Jan 17, 2019

The IDE and simple example sketches are working in Linux64, Mac, and Windows64. There are some display issues that I noticed in the IDE and there's some warnings to address before some code clean up. I also have not been solving java.ext.dirs quite yet. Still... progress and no sign of any major showstoppers yet!

I am going to take another pass at Mac, Linux, and Windows each to harden some of this. I think some of the UI issues I have seen so far look similar to what I have seen in the past when taking other projects from proprietary JDK to OpenJDK pre-Java 11. Mostly sizing is strange.

Anyway... Question for the community... I know there's some automated test in Processing but is there a list of things to try out after a bit of a larger change like this? I was going to check the examples and then (if they are not covered in the examples) the different rendering modes, fullscreen, and export. Anything else of particular interest?

sampottinger and others added 2 commits January 18, 2019 11:49
As part of processing#5753 / processing#5750, remove deprecated com.apple.eawt calls made in the core module. Specifically, respond to (JEP 272)[http://openjdk.java.net/jeps/272] which is generating warnings on sketch run and may cause failure in future JDKs.
Sync up to official master
@sampottinger
Copy link
Author

Quick note because GitHub message was a little unclear... 46d25b9 and a12fa6a introduce changes made in processing/processing into sampottinger/processing so that I don't diverge from processing/processing:master too much.

@benfry
Copy link
Contributor

benfry commented Jan 18, 2019

What's the java.ext.dirs issue that you're referring to? The main way that we use it is to prevent anything that's in java.ext.dirs from conflicting with Processing libraries. For instance, people often have an incompatible jna.jar somewhere in a java.ext.dirs, so the code in the launcher script is taking care of zeroing out those locations.

@ssilverman
Copy link

ssilverman commented Jan 19, 2019

Those lambdas with the QuitHandler etc. won't work cross-JDK. I just made this comment on commit f68fd9e:
"I don't think this will work on JDK 1.8 if compiled on JDK 11, and vice versa. It won't work on JDK 11 if compiled on JDK 1.8. Those lambdas compile to different QuitHandlers, i.e. they're from different packages. You still need java.lang.reflect.Proxy to make this work."

#5747 will work when classes are compiled to run on a different JDK with different QuitHandler (and others) having the same simple class names but different packages.

Lambdas aren't true closures here. They're compiled to specific instance of a class.

@sampottinger
Copy link
Author

Hey friends I am so sorry for the delay.

@ssilverman - Thank you for your comments and insight. I was going to send a note on Friday asking your opinion actually on this but I ran out of time before I could get that out. It seems like JEP 272 and JEP 260 have left us in a bit of an inconvenient spot with regards to the runtime warnings re illegal reflective access and plans of making --illegal-access=deny obligatory at some point in the future. I was trying to come up with some sort of adapter based solution or something but haven't arrived at anything palatable yet. Alternatively, in addition to the option of cutting to 11 altogether, we could suppress the warnings even if the JDK might force us to migrate at some point anyway. What are your thoughts? I think this might be trouble in a few places beyond ThinkDifferent.

@benfry - Thanks for writing back and for that helpful context. With that background in mind, at one point I was hoping to allow for compilation of Processing under either 8 or 11, adding java.ext.dirs if compiling with 8 but not in 11. What is your opinion? Is that worth adding in?

I am sure the folks here already have it but, just for posterity's sake, this is covered in JEP 220 with the JVM refusing to start when java.ext.dirts is specified.

@benfry
Copy link
Contributor

benfry commented Jan 20, 2019

If we make the move to Java 11, we'd drop Java 8 immediately and not worry about backwards compatibility for compiling or running.

Most likely, we'd be calling it Processing 4 because of the number of things that would be changing underneath (JVM, app launcher, how it interacts with the OS, etc). And people who wanted to use Java 8 would have a clear choice to use 3.x.

FWIW, the more I'm thinking about it, I'm fairly certain we'd drop 32-bit support altogether. (The one exception would be if @gohai has a problem here with ARM, though those boards seem to be headed all 64-bit too).

And if we can't get OpenJDK 11 to behave as well as JDK 8, we might just leave it as a branch/fork for people who are intent on using Java 11 (and who can incorporate changes from the main branch as needed).

@sampottinger
Copy link
Author

Hey there!

A quick favor to the community, if you are on linux and you are testing these changes out... can you drop a note here with the distro and the rendering engine (P2D, FX2D, etc)? Just trying to feel out where we have folks trying this and where there might be gaps.

Thanks,
Sam

@hamoid
Copy link
Contributor

hamoid commented Sep 14, 2019

Hi @sampottinger ! What about sharing a list of names of Examples so we call all test the same and post our OS?

@clankill3r
Copy link

When will this be migrated in the main processing branch?

@sampottinger
Copy link
Author

Sorry dropped the ball on the examples @hamoid. 😅 I’ve been using something on my end but would probably want to clean it up just a smidge. I’ll try to do that.

@sampottinger
Copy link
Author

sampottinger commented Sep 29, 2019

Hey @clankill3r! I have been in some discussion with Ben but he’s been busy. There’s some discussion of this becoming a beta either in the 3 train or starting the 4 but there’s more he wants to tackle (close out more issues currently waiting for work in the processing issue tracker). I’m not sure if that would happen before or after this merges in. Sorry I don’t have much more concrete info than that. That said, in the meantime, I am in the process of investigating the JOGL 2.4 / LWJGL situation and looking at the language server. Some of that would be a pretty big lift though... Still sorting through what I’ll have time to implement.

@neilcsmith-net
Copy link

@sampottinger reminds me I think I forgot to reply to you re. LWJGL? Use the email on my GitHub profile if you want to discuss (although there's also a Gitter chat that @codeanticode set up on that topic)

@clankill3r
Copy link

clankill3r commented Sep 29, 2019 via email

@sampottinger
Copy link
Author

sampottinger commented Sep 30, 2019

Hey @neilcsmith-net! Happy to hear from you and would love to discuss. I'll reach out on email.

@clankill3r - JOGL is in a weird spot and Ben articulated that LWJGL may be a better path forward long term. It seems JOGL has been a reliable partner for Processing for some time and they are making progress towards 2.4 which solves the problems we need solved but, while it looks close to finished, it's not clear when it will land. For context: while they are active in development now, they haven't released a new version since 2015. LWJGL may be a bit more active in its development. That said, it comes with some issues for us and, in particular, will challenge some parts of core because it is doesn't use AWT (see GLFW). So, there's pros and cons.

@neilcsmith-net
Copy link

neilcsmith-net commented Sep 30, 2019

@clankill3r as Sam alludes to, why would you not really? JOGL has been a dead project for the last few years, and while it's picked up again, Processing has had to ship a patched version for the last few releases. There is still no stable JOGL that supports Java 11 properly.

There is already a mostly functional LWJGL renderer by @codeanticode at https://github.com/codeanticode/processing-lwjgl However some changes to core are required to support running with headless AWT (most of the AWT usage can stay!), and also to support running events on the main thread (-XstartOnMainThread) - basically queues of Runnable for main thread and animation thread. Those changes will require making some things in PApplet defer to the renderer (eg. for screen selection, file dialog, etc. initially - longer term maybe images and fonts, but they work headless). Those changes are required for LWJGL, but are worth it even for JOGL - https://jogamp.org/wiki/index.php/Jogl_FAQ#Why_using_AWT_for_high_performance_is_not_a_good_idea_.3F

@knupel
Copy link

knupel commented Oct 2, 2019

Ciao Sam few word about PVector, I read there an idea to change PVector class for Processing 4 https://github.com/processing/processing/wiki/Processing-4#other-nuts-and-bolts . Few time ago i propose do @benfry to work it, if he want on my Vector class to design it specificly to Processing https://github.com/StanLepunK/Rope/tree/master/src/rope/vector
Maybe with your branch may be if Ben and the Processing Staff is ok, I can work on it to merge with your branch ? Let me-us know, if you're interested.

@neilcsmith-net
Copy link

@StanLepunK Interesting! Surely a time to be considering providing double variants, and maybe moving most of Processing's maths API to double? It's 2019 after all! 😄

Aside - that wiki page is somewhat depressing, particularly the Goodbye Java? section - spent 15+ years reading semi-idiotic rants from Processing people about Sun, Oracle and Java. Java and OpenJDK is in the healthiest place it's been in in many years. It's far from a mess, unlike Processing right now!

@knupel
Copy link

knupel commented Oct 2, 2019

@neilcsmith-net Go to the double, it's something what I thing to my vector class too, so it's a good idea... now just wait what @sampottinger and @benfry think about that... I've a feeling the "Goob bye Java" is not for today :)

@clankill3r
Copy link

clankill3r commented Oct 2, 2019 via email

@knupel
Copy link

knupel commented Oct 2, 2019

@clankill3r ok, I understand the problem for the double and the cache memory, in my library that can I propose to Processing, the idea is have a part for the ivec(int), vec (float), bvec (boolean) and why not a dvec(double). For this time there is only bvec, ivec and vec available.

I don't understand and what you mean about the transient protected float[] array; and the "It makes PVector exceed from 108 bits to 140 bits so it needs more padding." ?

@dzaima
Copy link

dzaima commented Oct 2, 2019

@StanLepunK clankill3r was saying that this line is taking up precious RAM/cache for every PVector object, possibly slowing down memory-heavy things.

Every vector type in your library stores 13 32-bit numbers, coming in at 52 bytes, compared to only 8 bytes if I only needed a vec2, resulting in 84% of memory going to waste (ignoring java object overhead). While that wouldn't matter too much in many cases, I still would expect every languages standard library to be somewhat optimized.

@neilcsmith-net
Copy link

@clankill3r if you were at all bothered about cache misses you wouldn't be using PVector in the first place, you'd be using float[] or FloatBuffer. A PVector that easily provides a window into a contiguous buffer would be useful in such cases. But using float over double in general is a PITA, and causes odd deviations from upstream Java math code for little reason. If v4 is a breaking change, and Java 11 probably is, then it's worth at least considering?!

@Sardtok
Copy link
Contributor

Sardtok commented Oct 3, 2019

@neilcsmith-net I would normally also use doubles for pretty much everything. One of the few exceptions is when working with a GPU. Simply because the GPU typically takes floats. It's not a major issue, one could even allow both, but would probably end up casting to float before passing it to the GPU. (I typically don't use PVectors, but that doesn't mean they can't end up being used by Processing itself. But if I am to make something that really requires more performance, I would go more low level than Processing anyway.)

From the OpenGL documentation on vertex specification (https://www.khronos.org/opengl/wiki/Vertex_Specification):

GL_DOUBLE​: A 64-bit double-precision floating-point value. Never use this. It's technically legal, but almost certainly a performance trap. Equivalent to GLdouble.

Casting doubles to floats everywhere does add some cost, up to 5 additional clock cycles for the conversion instruction alone on modern Intel CPUs. There will be additional instructions involved as well, but they are likely less costly. Of course, most Processing applications don't require optimizing away a few microseconds each frame.

@neilcsmith-net
Copy link

neilcsmith-net commented Oct 3, 2019

@Sardtok maybe check how many times PApplet is already casting from float to double and back again in its use of Math methods, or needlessly rewriting them in a slower, more inaccurate way and missing the use of intrinsics in the JVM. Yes, if you're talking to the GPU you need to cast down to float at the end of operations, and if you're worried about cache misses at all you don't redirect calls through numerous PVector objects. But there is an assumption that what I'm suggesting would add cost rather than remove it - something which should really be benchmarked! 😉

And we've got well off-topic - sorry @sampottinger - just suggesting that this may also be the time (given breaking changes) to look at the implementations of some of those methods in PApplet. Maybe something to chit-chat more on the forum?

@sampottinger
Copy link
Author

Hey there @StanLepunK, @neilcsmith-net, @clankill3r, @dzaima, @Sardtok - Thanks for weighing in! Let's redirect the PVector conversation to sampottinger#111.

@benfry benfry mentioned this pull request Oct 4, 2019
sampottinger added a commit to sampottinger/processing4 that referenced this pull request Oct 6, 2019
Introduces ANTLR4 and Java 8 language feature support within IDE while also adding additional hooks for localization of syntax error messages, addressing processing/processing#3054 and processing/processing#3055.

The PR is broadly a continuation of processing/processing#3055, bringing it up to speed with the latest Processing master plus the changes introduced at processing/processing#5753. **Requires processing/processing#5753 as pre-requisite.** This introduces a number of edits beyond processing/processing#3055 beyond compatibility with current Processing master and processing/processing#5753 including:

 - Update to the grammar itself
 - Change ANTLR listeners to emit `TextTransform.Edit` to unify JDT-based `PreprocessingService` and `JavaBuild`, removing code with duplicate purpose.
 - Introduction of syntax error rewriting with support for localization.
 - Addition of complete localized strings set for English and Spanish.
 - Addition of partial localized strings set for other languages.
 - Refactor of ANTLR-related code for testability and readability
 - Expansion of tests including full parse tests for new Java features (type inference, lambdas).
sampottinger added a commit to sampottinger/processing4 that referenced this pull request Oct 6, 2019
* Move to ANTLR 4 with Java 11 lang features and localization.

Introduces ANTLR4 and Java 8 language feature support within IDE while also adding additional hooks for localization of syntax error messages, addressing processing/processing#3054 and processing/processing#3055.

The PR is broadly a continuation of processing/processing#3055, bringing it up to speed with the latest Processing master plus the changes introduced at processing/processing#5753. **Requires processing/processing#5753 as pre-requisite.** This introduces a number of edits beyond processing/processing#3055 beyond compatibility with current Processing master and processing/processing#5753 including:

 - Update to the grammar itself
 - Change ANTLR listeners to emit `TextTransform.Edit` to unify JDT-based `PreprocessingService` and `JavaBuild`, removing code with duplicate purpose.
 - Introduction of syntax error rewriting with support for localization.
 - Addition of complete localized strings set for English and Spanish.
 - Addition of partial localized strings set for other languages.
 - Refactor of ANTLR-related code for testability and readability
 - Expansion of tests including full parse tests for new Java features (type inference, lambdas).

* Ask travis for ant upgrade prior to run.

* Ask Travis for java11 update.

* Add openjdk ppa

* Travis no confirmation on add ppa.

* Force newer ant on travis.

* Swtich ant download to www-us mirror.

* Switch ant to 1.10.7

* Start x for unit tests in travis.

* More complete start x in travis.

* Revert x in travis.

* Try x in services.
@sampottinger
Copy link
Author

Hey friends! Just a heads up that benfry/processing4#1 just posted.

@clankill3r
Copy link

Nice, good luck with the merge battle.

@benfry
Copy link
Contributor

benfry commented Jan 17, 2020

Closing now that development has moved here: 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