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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
3dd945f
Making the ThinkDifferent classes be JVM version-independent. JDK 1.9…
ssilverman Jan 7, 2019
3cc210f
Initial migration to Java 11 on Mac as POC.
sampottinger Jan 12, 2019
117d1a5
Added draft of downloader strategies for AdoptOpenJDK.
sampottinger Jan 14, 2019
79f6353
Refactored to strategies for supporting AdoptOpenJDK in build.
sampottinger Jan 15, 2019
e781f29
PDE running under linux but sketches fail on java path.
sampottinger Jan 16, 2019
7701402
Working proof of concept in linux with AdoptOpenJDK 11.
sampottinger Jan 17, 2019
99002c7
Working PDE / example sketch in win64 for AdoptOpenJDK.
sampottinger Jan 17, 2019
f68fd9e
Migrate deprecated com.apple.eawt calls in core.
sampottinger Jan 18, 2019
8a48178
Merge pull request #1 from processing/master
sampottinger Jan 18, 2019
46d25b9
Merge branch 'java11' into master
sampottinger Jan 18, 2019
a12fa6a
Merge pull request #2 from sampottinger/master
sampottinger Jan 18, 2019
f170faf
Addressed java.xml.bind issues as part of JEP 320 for Java 11.
sampottinger Jan 22, 2019
aa01b71
Restructed jre/build compile under macro.
sampottinger Jan 22, 2019
f9d7ad9
Minor refactor in preparation of adding tests to core.
sampottinger Jan 22, 2019
0d41302
Refactored image logic to strategies for automated testing.
sampottinger Jan 22, 2019
9069b54
Draft of save image infrastructure refactored.
sampottinger Jan 22, 2019
79f25f9
Fixed missing ignore in PImage save.
sampottinger Jan 22, 2019
58539d8
Started testing in core.util.io
sampottinger Jan 22, 2019
06b26e9
Fixed formatting in build/jre/src download url generators.
sampottinger Jan 22, 2019
b60492b
Merge branch 'java11' into io_refactor
sampottinger Jan 22, 2019
9464e1c
Minor formatting fixes in build/jre/src.
sampottinger Jan 22, 2019
5ddf996
Merge branch 'java11' into io_refactor
sampottinger Jan 22, 2019
4174015
Added missing copyright statements.
sampottinger Jan 22, 2019
8327d04
Merge branch 'java11' into io_refactor
sampottinger Jan 22, 2019
b458f60
Parameterized classpath in build/jre
sampottinger Jan 22, 2019
b0d2ff9
Merge branch 'java11' into io_refactor
sampottinger Jan 22, 2019
d2bbd03
Started InputFactoryTest
sampottinger Jan 23, 2019
47d8bfa
Expanded JavaDoc and minor refactor of ImageIO.
sampottinger Jan 23, 2019
91175d8
Added javadoc for util.image and migrated PShape to use core.util.
sampottinger Jan 23, 2019
494fb6e
Updated org.eclipse.core.runtime.jar to 3.15.
sampottinger Jan 23, 2019
43c87d7
Undo 494fb6e6210a326bd1fe5203800347e14ab88c66.
sampottinger Jan 23, 2019
4853901
Resolved issue with 494fb6e6210a326bd1fe5203800347e14ab88c66.
sampottinger Jan 23, 2019
7fbb129
Re-udpate org.eclipse.core.runtime now that equinox is updated.
sampottinger Jan 23, 2019
023f046
Responded to @benfry on #5753 regarding copyright notices.
sampottinger Jan 23, 2019
2081d09
Preprocessing service compliance with JEP 220/261.
sampottinger Jan 26, 2019
5d7eba1
Added PathUtilTest.
sampottinger Jan 26, 2019
16985c9
Refactored java build for testing in java mode.
sampottinger Jan 28, 2019
7bd8e28
Started refactor on runtime forumulation with testing.
sampottinger Jan 28, 2019
7bb31cb
Finished refactor to pdex.util.runtime ahead of adding tests.
sampottinger Jan 28, 2019
0bbf9f0
Added tests and javadoc for new non-composite classpath strategies.
sampottinger Jan 29, 2019
eeebda6
Finished refactor to runtime resolution strategies.
sampottinger Jan 29, 2019
da3dc4c
Fixed Java 11 config (JCE) on Mac as part of #5753.
sampottinger Feb 1, 2019
1e50a7d
Working JFX render mode with JDK 11.
sampottinger Feb 12, 2019
bf02087
Working app export on Mac without Java embed.
sampottinger Feb 12, 2019
889e717
Java 11 embedding on mac working if not using JFX.
sampottinger Feb 12, 2019
e4cacc6
Working export with OpenJFX on Mac with JDK 11.
sampottinger Feb 12, 2019
18930db
Fixed Swing high DPI scaling issues on Windows with OpenJDK 11.
sampottinger Feb 14, 2019
914a26b
OpenJFX (JDK 11) support for Windows.
sampottinger Feb 14, 2019
8648c9b
Remove warning for OpenJDK in LinuxPlatform.java
sampottinger Feb 15, 2019
04b2716
Initialization of OpenJFX pipeline for Linux.
sampottinger Feb 15, 2019
1eb77b7
Added mockito for core testing.
sampottinger Feb 15, 2019
b1e48c7
Include linux jfx files.
sampottinger Feb 17, 2019
3701694
Fix ant typo in b1e48c76d6f0ba3cb5c03df1a442b632cf9eb795.
sampottinger Feb 17, 2019
7b8a4ab
Standardized to ant copy task for OpenJFX inclusion.
sampottinger Feb 17, 2019
2d263d9
Removed some hard-coded JDK version strings from build.xml.
sampottinger Mar 12, 2019
3e6eff0
Responded to first batch of self-review comments on #5753.
sampottinger Mar 13, 2019
0d16884
Minor fix for Downloader.java JavaDoc.
sampottinger Mar 13, 2019
6499e16
Merge branch 'java11' into io_refactor
sampottinger Mar 14, 2019
9aad59d
Added test for awt image load.
sampottinger Mar 14, 2019
9b69a45
Completed tests for image io.
sampottinger Mar 18, 2019
bbc0c27
Merge pull request #3 from sampottinger/io_refactor
sampottinger Mar 18, 2019
1567bdc
Merge pull request #5 from processing/master
sampottinger Mar 18, 2019
27d50b3
Added comment about JEP 263 in WindowsPlatform.
sampottinger Mar 18, 2019
bf1c41f
No longer reference local java install for mac.
sampottinger Mar 18, 2019
8cdee3d
Allow a cross build in build.xml.
sampottinger Mar 19, 2019
91432c7
Cross build targets.
sampottinger Mar 19, 2019
945b920
A number of assorted clean ups for #5753 ant build.
sampottinger Mar 20, 2019
9709955
Fix work directory creation in 945b9205a9ae7d5ede1e5e0d52f58bd04ed762d3
sampottinger Mar 20, 2019
2573a2c
Fix architecture in cross build.
sampottinger Mar 20, 2019
51933f5
Optimize linux build.
sampottinger Mar 20, 2019
b4def2d
Optimize mac build.
sampottinger Mar 20, 2019
e72fe69
Fix some issues related to #5753 distribution size.
sampottinger Mar 20, 2019
88508a3
Cross-build working from *nix to windows.
sampottinger Mar 20, 2019
a3202bf
Make methods build a pre-req to tests in core/build.
sampottinger Mar 20, 2019
b511860
Update exports for windows.
sampottinger Mar 20, 2019
7846999
Try to restore JDT build in core/methods/build
sampottinger Mar 20, 2019
b55fa7d
Use regular JDT in core/methods.
sampottinger Mar 20, 2019
89748ab
Fixed Windows Java 11 and OpenJFX build
sampottinger Mar 21, 2019
fc7c064
Remove verbose prism messages
sampottinger Mar 21, 2019
b9197bc
Some minor changes within nativecopy in build/build.xml
sampottinger Mar 21, 2019
5be0c01
Optimize windows build.
sampottinger Mar 21, 2019
6e33491
Restore check-os targets.
sampottinger Mar 21, 2019
497d0ac
Merge pull request #6 from sampottinger/unified_build
sampottinger Mar 21, 2019
4c0d887
Fix in codesign.
sampottinger Mar 21, 2019
6284a5a
Added arm fix / test on download url generator.
sampottinger Mar 22, 2019
652eae3
Fix FX2D fullScreen for #5753.
sampottinger Apr 6, 2019
20b9311
Fix import suggestions for #5753.
sampottinger Apr 9, 2019
47aa2a6
Merge branch 'master' of https://github.com/processing/processing int…
sampottinger Apr 25, 2019
821db90
Fix conflicts in core/build.xml
sampottinger Apr 25, 2019
da8beb3
Merge pull request #61 from sampottinger/processing-master
sampottinger Apr 25, 2019
5b1cd18
Initial revert of sampottinger/processing #3.
sampottinger Aug 7, 2019
b5929d0
Merge branch 'java11' into io_refactor_revert
sampottinger Aug 7, 2019
2f48324
Fix leftover references related to sampottinger #3 revert.
sampottinger Aug 7, 2019
055433d
Fix pshape alpha check.
sampottinger Aug 7, 2019
a51fd6f
Fix classpath changes related to #3 revert.
sampottinger Aug 7, 2019
23c0839
Fixed tiff refactor.
sampottinger Aug 7, 2019
cab5376
Re-introduced base64 image loading tests.
sampottinger Aug 9, 2019
3baf093
Created test entry point for base64 loading.
sampottinger Aug 9, 2019
bb64747
Added Base64StringImageLoadTest.
sampottinger Aug 9, 2019
c92c093
Added commenting for base64 test.
sampottinger Aug 9, 2019
126f703
Simplified base64 test slightly.
sampottinger Aug 10, 2019
bc758c2
Merge pull request #79 from sampottinger/io_refactor_revert
sampottinger Aug 10, 2019
0b45a7e
Disable swing scaling on windows.
sampottinger Aug 26, 2019
ff27751
Increment jdk 11 build.
sampottinger Aug 26, 2019
726e3a5
Switch to setting scale from applauncher for Windows.
sampottinger Aug 26, 2019
b51145e
Force swing scale on windows exports.
sampottinger Aug 26, 2019
a693904
Fix scale on non-exported sketches on Windows.
sampottinger Aug 26, 2019
49d44e3
Fix typo in Runner.java related to fixed scale on windows.
sampottinger Aug 26, 2019
7c1664e
Merge pull request #98 from sampottinger/java11_scale
sampottinger Aug 26, 2019
7792ecd
Detect partial pixel font characters for JEditTextArea.
sampottinger Aug 29, 2019
bd9ebc2
Merge pull request #107 from sampottinger/java11_partial_font
sampottinger Aug 29, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.DS_Store
.AppleDouble
*.iml
._*
*~
/build/shared/reference.zip
Expand Down
25 changes: 11 additions & 14 deletions app/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
<fail unless="core-built" message="Please build the core library first and make sure it is located at ../core/library/core.jar" />

<mkdir dir="bin" />

<!-- copy languages files -->
<copy todir="bin">
<fileset dir="src">
<include name="processing/app/languages/*.properties" />
</fileset>
</copy>

<!-- in some cases, pde.jar was not getting built
https://github.com/processing/processing/issues/1792 -->
<delete file="pde.jar" />
Expand All @@ -30,22 +30,19 @@

<javac source="1.8"
target="1.8"
destdir="bin"
excludes="**/tools/format/**"
encoding="UTF-8"
includeAntRuntime="false"
classpath="../core/library/core.jar;
../core/apple.jar;
lib/ant.jar;
lib/ant-launcher.jar;
destdir="bin"
excludes="**/tools/format/**"
encoding="UTF-8"
includeAntRuntime="false"
classpath="../core/library/core.jar;
../core/apple.jar;
lib/ant.jar;
lib/ant-launcher.jar;
lib/jna.jar;
lib/jna-platform.jar"
debug="on"
nowarn="true"
compiler="org.eclipse.jdt.core.JDTCompilerAdapter">
nowarn="true">
<src path="src" />
<compilerclasspath path="../java/mode/org.eclipse.jdt.core.jar;
../java/mode/jdtCompilerAdapter.jar" />
</javac>
</target>

Expand Down
Binary file modified app/lib/jna-platform.jar
Binary file not shown.
Binary file modified app/lib/jna.jar
Binary file not shown.
6 changes: 3 additions & 3 deletions app/src/processing/app/Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,10 @@ static public File getJavaHome() {
File[] plugins = getContentFile("../PlugIns").listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return dir.isDirectory() &&
name.endsWith(".jdk") && !name.startsWith(".");
name.contains("jdk") && !name.startsWith(".");
}
});
return new File(plugins[0], "Contents/Home/jre");
return new File(plugins[0], "Contents/Home");
}
// On all other platforms, it's the 'java' folder adjacent to Processing
return getContentFile("java");
Expand Down Expand Up @@ -412,4 +412,4 @@ static public int unsetenv(String variable) {
static public int getSystemDPI() {
return inst.getSystemDPI();
}
}
}
14 changes: 0 additions & 14 deletions app/src/processing/app/platform/LinuxPlatform.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,6 @@ public class LinuxPlatform extends DefaultPlatform {
public void initBase(Base base) {
super.initBase(base);

String javaVendor = System.getProperty("java.vendor");
Copy link
Author

Choose a reason for hiding this comment

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

Could consider leaving a form if this back in if desired. Leave that for other reviewers to decide.

String javaVM = System.getProperty("java.vm.name");
if (javaVendor == null ||
(!javaVendor.contains("Sun") && !javaVendor.contains("Oracle")) ||
javaVM == null || !javaVM.contains("Java")) {
Messages.showWarning("Not fond of this Java VM",
"Processing requires Java 8 from Oracle.\n" +
"Other versions such as OpenJDK, IcedTea,\n" +
"and GCJ are strongly discouraged. Among other things, you're\n" +
"likely to run into problems with sketch window size and\n" +
"placement. For more background, please read the wiki:\n" +
"https://github.com/processing/processing/wiki/Supported-Platforms#linux", null);
}

// Set x11 WM_CLASS property which is used as the application
// name by Gnome3 and other window managers.
// https://github.com/processing/processing/issues/2534
Expand Down
111 changes: 75 additions & 36 deletions app/src/processing/app/platform/ThinkDifferent.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@

import java.awt.event.*;
import java.io.File;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.List;

import javax.swing.*;

import com.apple.eawt.*;
import com.apple.eawt.AppEvent.*;
import com.apple.eawt.Application;

import processing.app.*;
import processing.app.ui.About;
Expand Down Expand Up @@ -65,44 +69,40 @@ static protected void init(final Base base) {
if (adapter == null) {
adapter = new ThinkDifferent(); //base);
}

application.setAboutHandler(new AboutHandler() {
public void handleAbout(AboutEvent ae) {
new About(null);
}

setHandler(application, "setAboutHandler", (proxy, method, args) -> {
new About(null);
return null;
});

application.setPreferencesHandler(new PreferencesHandler() {
public void handlePreferences(PreferencesEvent arg0) {
base.handlePrefs();
}

setHandler(application, "setPreferencesHandler", (proxy, method, args) -> {
base.handlePrefs();
return null;
});

application.setOpenFileHandler(new OpenFilesHandler() {
public void openFiles(OpenFilesEvent event) {
for (File file : event.getFiles()) {
base.handleOpen(file.getAbsolutePath());
}
setHandler(application, "setOpenFileHandler", (proxy, method, args) -> {
Method m = args[0].getClass().getMethod("getFiles");
for (File file : (List<File>) m.invoke(args[0])) {
base.handleOpen(file.getAbsolutePath());
}
return null;
});

application.setPrintFileHandler(new PrintFilesHandler() {
public void printFiles(PrintFilesEvent event) {
// TODO not yet implemented
}

setHandler(application, "setPrintFileHandler", (proxy, method, args) -> {
// TODO not yet implemented
return null;
});

application.setQuitHandler(new QuitHandler() {
public void handleQuitRequestWith(QuitEvent event, QuitResponse response) {
if (base.handleQuit()) {
response.performQuit();
} else {
response.cancelQuit();
}

setHandler(application, "setQuitHandler", (proxy, method, args) -> {
if (base.handleQuit()) {
args[1].getClass().getMethod("performQuit").invoke(args[1]);
} else {
args[1].getClass().getMethod("cancelQuit").invoke(args[1]);
}
return null;
});

// Set the menubar to be used when nothing else is open.
// Set the menubar to be used when nothing else is open.
JMenuBar defaultMenuBar = new JMenuBar();
JMenu fileMenu = buildFileMenu(base);
defaultMenuBar.add(fileMenu);
Expand All @@ -117,12 +117,12 @@ public void handleQuitRequestWith(QuitEvent event, QuitResponse response) {
e.printStackTrace(); // oh well, never mind
}
// } else {
// // The douchebags at Oracle didn't feel that a working f*king menubar
// // on OS X was important enough to make it into the 7u40 release.
// // The douchebags at Oracle didn't feel that a working f*king menubar
// // on OS X was important enough to make it into the 7u40 release.
// //http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8007267
// // It languished in the JDK 8 source and has been backported for 7u60:
// //http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8022667
//
//
// JFrame offscreen = new JFrame();
// offscreen.setUndecorated(true);
// offscreen.setJMenuBar(defaultMenuBar);
Expand All @@ -131,12 +131,51 @@ public void handleQuitRequestWith(QuitEvent event, QuitResponse response) {
// offscreen.setVisible(true);
// }
}


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

/**
* Sets a handler on an instance of {@link Application}, taking into account JVM version
* differences.
*
* @param app an instance of {@link Application}
* @param name the "set handler" method name
* @param handler the handler
*/
private static void setHandler(Application app, String name, InvocationHandler handler) {
// Determine which version of com.apple.eawt.Application to use and pass it a handler of the
// appropriate type
Method[] methods = app.getClass().getMethods();
for (Method m : methods) {
if (!name.equals(m.getName())) {
continue;
}
if (m.getParameterCount() != 1) {
continue;
}
Class paramType = m.getParameterTypes()[0];
try {
// Allow a null handler
Object proxy = null;
if (handler != null) {
proxy = Proxy.newProxyInstance(
paramType.getClassLoader(), new Class<?>[] { paramType }, handler);
}
m.invoke(app, proxy);
} catch (IllegalArgumentException ex) {
// TODO: Print error?: method doesn't take an interface, etc.
} catch (IllegalAccessException ex) {
// TODO: Print error?: Other method invocation problem
} catch (InvocationTargetException ex) {
ex.getCause().printStackTrace();
// TODO: Print ex.getCause() a different way?
}
break;
}
}

/**
* Gimpy file menu to be used on OS X when no sketches are open.
Expand All @@ -162,7 +201,7 @@ public void actionPerformed(ActionEvent e) {
fileMenu.add(item);

item = Toolkit.newJMenuItemShift(Language.text("menu.file.sketchbook"), 'K');
item.addActionListener(new ActionListener() {
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
base.getNextMode().showSketchbookFrame();
Expand Down
57 changes: 8 additions & 49 deletions app/src/processing/app/platform/WindowsPlatform.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,16 @@ public class WindowsPlatform extends DefaultPlatform {
"\\" + APP_NAME.toLowerCase() + ".exe \"%1\"";
static final String REG_DOC = APP_NAME + ".Document";

// Starting with Java 9, the scaling is done automatically. If DPI is
// used to scaling within the application, one ends up with 2x the
// expected scale. See JEP 263.
private static final int WINDOWS_NATIVE_DPI = 96;

public void initBase(Base base) {
super.initBase(base);

checkAssociations();

//checkQuickTime();
checkPath();

Expand Down Expand Up @@ -627,56 +633,9 @@ public int unsetenv(String variable) {
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


// Need to extend com.sun.jna.platform.win32.User32 to access
// Win32 function GetDpiForSystem()
interface ExtUser32 extends StdCallLibrary, com.sun.jna.platform.win32.User32 {
ExtUser32 INSTANCE = (ExtUser32) Native.loadLibrary("user32", ExtUser32.class, W32APIOptions.DEFAULT_OPTIONS);

public int GetDpiForSystem();

public int SetProcessDpiAwareness(int value);

public final int DPI_AWARENESS_INVALID = -1;
public final int DPI_AWARENESS_UNAWARE = 0;
public final int DPI_AWARENESS_SYSTEM_AWARE = 1;
public final int DPI_AWARENESS_PER_MONITOR_AWARE = 2;

public Pointer SetThreadDpiAwarenessContext(Pointer dpiContext);

public final Pointer DPI_AWARENESS_CONTEXT_UNAWARE = new Pointer(-1);
public final Pointer DPI_AWARENESS_CONTEXT_SYSTEM_AWARE = new Pointer(-2);
public final Pointer DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE = new Pointer(-3);
}


static private int detected = detectSystemDPI();


public int getSystemDPI() {
if (detected == -1) {
return super.getSystemDPI();
}
return detected;
// Note that this is supported "natively" within Java - See JEP 263.
return WINDOWS_NATIVE_DPI;
}


public static int detectSystemDPI() {
try {
ExtUser32.INSTANCE.SetProcessDpiAwareness(ExtUser32.DPI_AWARENESS_SYSTEM_AWARE);
} catch (Throwable e) {
// Ignore error
}
try {
ExtUser32.INSTANCE.SetThreadDpiAwarenessContext(ExtUser32.DPI_AWARENESS_CONTEXT_SYSTEM_AWARE);
} catch (Throwable e) {
// Ignore error (call valid only on Windows 10)
}
try {
return ExtUser32.INSTANCE.GetDpiForSystem();
} catch (Throwable e) {
// DPI detection failed, fall back with default
System.out.println("DPI detection failed, fallback to 96 dpi");
return -1;
}
}
}