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

Java 11, OpenJDK, ANTLR 4, and Travis #1

Merged
merged 20 commits into from Oct 7, 2019
Merged

Conversation

sampottinger
Copy link
Collaborator

Roughly the equivalent of merging master https://github.com/sampottinger/processing into master at https://github.com/processing/processing except that it targets the processing4 fork, this PR introduces a number of changes (and supersedes the following):

sampottinger and others added 6 commits October 5, 2019 20:49
…rain.

Moves to Java11 and OpenJDK via AdoptOpenJDK within the processing4 train using a squash of sampottinger processing fork's java11 branch.

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

 - Response to image loading changes caused by [JEP 320](https://openjdk.java.net/jeps/320)
 - Use of jmodules as necessitated by [JEP 261](https://openjdk.java.net/jeps/261)
 - Reponse to largely changed file paths caused by [JEP 220](https://openjdk.java.net/jeps/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](http://openjdk.java.net/jeps/272)
 - Response to HiDPI support on Windows and Linux in [JEP 263](https://openjdk.java.net/jeps/263)
- Removal of `java.ext.dirs`. Would be forced by [JEP 220](http://openjdk.java.net/jeps/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](https://openjdk.java.net/jeps/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.
Moves to Java11 and OpenJDK via AdoptOpenJDK
* Adding travis support (hopefully without osx).

Based off of processing 5753, demonstrates the use of Travis to build and test processing Requires use of OpenJDK (processing 5753). Will address processing 2747. Will redirect this to the original processing repo after processing 5753 is resolved.

Note that this supersedes sampottinger/processing's #7 and benfry#70 - this does not include the deploy step.

* Attempt explicit lib addition for linux-based travis build.

* Ask travis for ant optional install.
 License links in top level license file to include third party information. Specifically, in follow up to processing 5753, some updates to the license.txt file, reformatting to make it easier to find third party license information and to navigate the processing license itself.
* 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 sampottinger changed the title Java 11, OpenJDK, ANTLR, and Travis Java 11, OpenJDK, ANTLR 4, and Travis Oct 6, 2019
@sampottinger
Copy link
Collaborator Author

We may break this PR up but folks have been testing with all of them put together on my master at https://github.com/sampottinger/processing/ so... let me know what you prefer @benfry.

app/build.xml Show resolved Hide resolved
*/
package com.oracle.appbundler;

public class Environment extends Option {
Copy link
Owner

Choose a reason for hiding this comment

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

This is a ton of new classes for code that's a barely modified fork of another project… Are these really necessary? The changes make it harder to use anything upstream, and mean more maintenance for me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I backported the changes infinitekind made upstream into our copy of it. A pretty decent number of changes were made to support Java 11 and I wasn't sure if I would be able to cherry pick those changes without accepting some of the architectural shifts like this. I can try to narrow this down if you'd like but doing so likely makes it difficult to grab patches from them (and they are still pretty active: https://github.com/TheInfiniteKind/appbundler).

Copy link
Owner

Choose a reason for hiding this comment

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

So these are mostly their changes, not yours?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Correct

core/build.xml Show resolved Hide resolved
@@ -6940,8 +6940,6 @@ public void specular(int rgb) {

/**
* gray number specifying value between white and black
*
* @param gray value between black and white, by default 0 to 255
Copy link
Owner

Choose a reason for hiding this comment

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

Why is this removed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry this must have been a mistake. I'll double check what was up here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Reverted - sampottinger#6



/**
* Deal with issues related to thinking differently.
* Deal with issues related to Mac OS window behavior.
Copy link
Owner

Choose a reason for hiding this comment

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

C'mon…

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry! I don't think I got the ThinkDifferent reference and wanted to leave something in to hint more directly what it was doing. I can revert if you'd like.

java/build.xml Show resolved Hide resolved
@@ -160,23 +160,23 @@ public String toString() {
}


protected static class Edit {
public static class Edit {
Copy link
Owner

Choose a reason for hiding this comment

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

Why are all these being made public?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I need to make edits (specifically Edits later applied in preprocessing) within the new ANTLR stuff. In general, there was a lot of duplicate code for preprocessing and I tried to consolidate to ANTLR tree walking instead of regex when possible. However, I didn't want to overhaul the TextTransform / Edit infrastructure.

Copy link
Owner

Choose a reason for hiding this comment

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

Ok, sounds fine… two general rules to note here for related edits:

  • If it's an inner class that has this many public methods/fields, I lean toward breaking it out as a separate class, so that folks aren't digging inside of the parent to find out what's happening inside some other code.
  • Always wary of any internal interfaces being made public since that means any Mode or Tool author might make use of them and expect them to work in future releases. So public is used sparingly (you see a lot of protected for this reason, for instance…)

/**
* The modules comprising the Java standard modules.
*/
public static final String[] STANDARD_MODULES = {
Copy link
Owner

Choose a reason for hiding this comment

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

These can live in Runtime… They don't need to be another class that someone else has to find. If they were non-static, had accessors, or were designed to be overridden, that would make more sense.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good. They just felt really big.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Potential resolution in sampottinger#8. Let me know if you want me to merge that in.

Copy link
Owner

Choose a reason for hiding this comment

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

Sounds good, yeah—let's go ahead and merge that in. Obviously lots of future work to do on this (as mentioned via email) it's a situation where a more condensed starting point will actually be better.

*/
public static List<String> sanitizeClassPath(String classPathString) {
// Make sure class path does not contain empty string (home dir)
return Arrays.stream(classPathString.split(File.pathSeparator))
Copy link
Owner

@benfry benfry Oct 6, 2019

Choose a reason for hiding this comment

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

Please move this back into where it came from… It's a single line. The new class is 48 lines. I understand folks like abstraction, but there's also a lot of overhead to keeping track of many classes and how they interact with one another.

Same goes for a few more of these below… This doesn't fix something that was broken, but adds a lot of overhead for anyone trying to understand how parts of the code interact, and doesn't get us closer to actually cleaning all this code for Language Server and that sort of thing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this particular piece of code got pulled up because it's used in a few different places and, even though it is one line, it does carry enough complexity that I wanted to re-use it but building inheritance around it felt heavy handed. That said, I can roll all of the runtime stuff up together into class if that is preferable. Although, I should mention that the path logic has gotten more complex with Java 11, mostly due to JEP 261 and the JavaFX jettison.

In general though... Sorry about that :( . I think some of this was formulated relatively early on when I was writing to architectural guidance for projects that I'm in outside of Processing which tend to encourage this kind of decomposition but, for the most part, I know that is cultural and project coherence is more important. I'll try to address this here in Runtime* and preproc to conform more closely to Processing norms.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have a possible iteration for you at sampottinger#8. Please let me know if you want to merge or further consolidate.

Copy link
Owner

Choose a reason for hiding this comment

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

Ok, for things that are used in that many places, I'm certainly up for a general utility class being in place, but just want that to be more than a single one-liner.

sampottinger and others added 2 commits October 6, 2019 18:24
* Refactored TabLineFactory into ProblemFactory.

As part of benfry#1, refactored TabLineFactory into ProblemFactory, merging tests in the process.

* Fix imports on #7.
In response to @benfry feedback within benfry#1, consolidated all of the runtime path calculation into a single class while still maintaining all of the tests and caching logic. This reduces the class count but still adapts to jmod and javafx path calculation requirements for java 11.
Refactor ANTLR message simplification infrastructure to reduce class count within preproc given @benfy feedback within benfry#1. Note that some supporting are left out but those can be further refactored behind classes as desired but strategies are all made anon or inner.
@sampottinger
Copy link
Collaborator Author

sampottinger commented Oct 7, 2019

Hey there! Just a heads up re consolidating classes... I don't know if either of these are desired but see:

If you like one or both, I'll merge into my master which will be reflected on this PR.

Thanks,
Sam

sampottinger and others added 2 commits October 6, 2019 23:05
Fix issue reported by @codeanticode within PreprocessorResult.java where the height was not being returned correctly.
Minor fix in PreprocessorResult dimension reporting.
Copy link
Owner

@benfry benfry left a comment

Choose a reason for hiding this comment

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

Sounds good, yes—let's merge those two and with that I can merge this whole bundle.

Refactor ANTLR message simplification infrastructure.
Consolidate logic for runtime path generation into a single class.
@sampottinger
Copy link
Collaborator Author

Just merged sampottinger#8 and sampottinger#9. Let me know if there's anything else I can do!

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 15, 2021
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