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
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c146954
Moves to Java11 and OpenJDK via AdoptOpenJDK within the processing4 t…
sampottinger Oct 6, 2019
86a2cd9
Merge pull request #2 from sampottinger/java11
sampottinger Oct 6, 2019
25a0853
Add travis support for CI (not CD) (#3)
sampottinger Oct 6, 2019
2b853b8
Updated license text.
sampottinger Oct 6, 2019
00dd280
Merge pull request #4 from sampottinger/license_text
sampottinger Oct 6, 2019
ee299ef
Move to ANTLR 4 with Java 11 lang features and localization. (#5)
sampottinger Oct 6, 2019
4d05baf
Removed pdex build per @benfry comments.
sampottinger Oct 7, 2019
554ace3
Revert changes in comments inside PApplet and PGraphics.
sampottinger Oct 7, 2019
d02ad8f
Fix formatting issue in PImage.
sampottinger Oct 7, 2019
7cad017
Recover lost changes in cut over to sampottinger/processing4.
sampottinger Oct 7, 2019
30133d8
Merge pull request #6 from sampottinger/pr_1_simple_fixes
sampottinger Oct 7, 2019
0febfce
Fix LongDict @nowebref
sampottinger Oct 7, 2019
2b05da1
Refactored TabLineFactory into ProblemFactory. (#7)
sampottinger Oct 7, 2019
a265b1e
Consolidate logic for runtime path generation into a single class.
sampottinger Oct 7, 2019
ceb9fed
Add back in RuntimePathBuilder* under new location.
sampottinger Oct 7, 2019
f846c7e
Refactor ANTLR message simplification infrastructure.
sampottinger Oct 7, 2019
e46a957
Minor fix in PreprocessorResult dimension reporting.
sampottinger Oct 7, 2019
caa3580
Merge pull request #10 from sampottinger/fix_preprocessor_result_height
sampottinger Oct 7, 2019
0dfa125
Merge pull request #9 from sampottinger/error_rewrite_restructure
sampottinger Oct 7, 2019
404835f
Merge pull request #8 from sampottinger/runtime_structural_refactor
sampottinger Oct 7, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
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
26 changes: 26 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
git:
depth: 1

language: java

jdk:
- openjdk11

before_install:
- sudo apt-get -qq update
- sudo apt-get install ant-optional
- sudo apt-get install wget
- wget --no-check-certificate https://www-us.apache.org/dist//ant/binaries/apache-ant-1.10.7-bin.tar.gz
- tar -xzvf apache-ant-1.10.7-bin.tar.gz
- export PATH=`pwd`/apache-ant-1.10.7/bin:$PATH

services:
- xvfb

before_script:
- export DISPLAY=:99.0
- cd build

script:
- ant clean
- ant build
1,009 changes: 1,009 additions & 0 deletions LICENSE.md

Large diffs are not rendered by default.

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">
benfry marked this conversation as resolved.
Show resolved Hide resolved
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.
10 changes: 7 additions & 3 deletions app/src/processing/app/Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ public class Platform {

// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

static public boolean isInit() {
return inst != null;
}


static public void init() {
try {
Expand Down Expand Up @@ -339,10 +343,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 +416,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");
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;
}
}
}