mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
deal with a handful of Java 9 changes and deprecations
This commit is contained in:
@@ -712,7 +712,8 @@ public class Base {
|
||||
protected void initInternalTool(String className) {
|
||||
try {
|
||||
Class<?> toolClass = Class.forName(className);
|
||||
final Tool tool = (Tool) toolClass.newInstance();
|
||||
final Tool tool = (Tool)
|
||||
toolClass.getDeclaredConstructor().newInstance();
|
||||
|
||||
tool.init(this);
|
||||
internalTools.add(tool);
|
||||
|
||||
@@ -41,14 +41,14 @@ import processing.core.PConstants;
|
||||
public class Platform {
|
||||
static DefaultPlatform inst;
|
||||
|
||||
static Map<Integer, String> platformNames = new HashMap<Integer, String>();
|
||||
static Map<Integer, String> platformNames = new HashMap<>();
|
||||
static {
|
||||
platformNames.put(PConstants.WINDOWS, "windows"); //$NON-NLS-1$
|
||||
platformNames.put(PConstants.MACOSX, "macosx"); //$NON-NLS-1$
|
||||
platformNames.put(PConstants.LINUX, "linux"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
static Map<String, Integer> platformIndices = new HashMap<String, Integer>();
|
||||
static Map<String, Integer> platformIndices = new HashMap<>();
|
||||
static {
|
||||
platformIndices.put("windows", PConstants.WINDOWS); //$NON-NLS-1$
|
||||
platformIndices.put("macosx", PConstants.MACOSX); //$NON-NLS-1$
|
||||
@@ -86,7 +86,7 @@ public class Platform {
|
||||
} else if (Platform.isLinux()) {
|
||||
platformClass = Class.forName("processing.app.platform.LinuxPlatform"); //$NON-NLS-1$
|
||||
}
|
||||
inst = (DefaultPlatform) platformClass.newInstance();
|
||||
inst = (DefaultPlatform) platformClass.getDeclaredConstructor().newInstance();
|
||||
} catch (Exception e) {
|
||||
Messages.showError("Problem Setting the Platform",
|
||||
"An unknown error occurred while trying to load\n" +
|
||||
|
||||
@@ -63,7 +63,7 @@ public class ToolContribution extends LocalContribution implements Tool, Compara
|
||||
String className = initLoader(null);
|
||||
if (className != null) {
|
||||
Class<?> toolClass = loader.loadClass(className);
|
||||
tool = (Tool) toolClass.newInstance();
|
||||
tool = (Tool) toolClass.getDeclaredConstructor().newInstance();
|
||||
}
|
||||
|
||||
referenceFile = new File(folder, "reference/index.html");
|
||||
@@ -95,7 +95,7 @@ public class ToolContribution extends LocalContribution implements Tool, Compara
|
||||
|
||||
static public List<ToolContribution> loadAll(File toolsFolder) {
|
||||
File[] list = ContributionType.TOOL.listCandidates(toolsFolder);
|
||||
ArrayList<ToolContribution> outgoing = new ArrayList<ToolContribution>();
|
||||
ArrayList<ToolContribution> outgoing = new ArrayList<>();
|
||||
// If toolsFolder does not exist or is inaccessible (stranger things have
|
||||
// happened, and are reported as bugs) list will come back null.
|
||||
if (list != null) {
|
||||
|
||||
@@ -2479,7 +2479,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
|
||||
// on macosx, setting the destructive property places this option
|
||||
// away from the others at the lefthand side
|
||||
pane.putClientProperty("Quaqua.OptionPane.destructiveOption",
|
||||
new Integer(2));
|
||||
Integer.valueOf(2));
|
||||
|
||||
JDialog dialog = pane.createDialog(this, null);
|
||||
dialog.setVisible(true);
|
||||
|
||||
@@ -385,7 +385,7 @@ public class Toolkit {
|
||||
cleanChars = cleanString.toCharArray();
|
||||
cleanCharas = new Character[cleanChars.length];
|
||||
for (int i = 0; i < cleanChars.length; i++) {
|
||||
cleanCharas[i] = new Character(cleanChars[i]);
|
||||
cleanCharas[i] = cleanChars[i];
|
||||
}
|
||||
Arrays.sort(cleanCharas, charComparator); // sorts in increasing order
|
||||
for (char mnem : cleanCharas) {
|
||||
|
||||
@@ -9596,7 +9596,7 @@ public class PApplet implements PConstants {
|
||||
|
||||
static final public float parseFloat(String what, float otherwise) {
|
||||
try {
|
||||
return new Float(what).floatValue();
|
||||
return Float.parseFloat(what);
|
||||
} catch (NumberFormatException e) { }
|
||||
|
||||
return otherwise;
|
||||
@@ -9646,7 +9646,7 @@ public class PApplet implements PConstants {
|
||||
float output[] = new float[what.length];
|
||||
for (int i = 0; i < what.length; i++) {
|
||||
try {
|
||||
output[i] = new Float(what[i]).floatValue();
|
||||
output[i] = Float.parseFloat(what[i]);
|
||||
} catch (NumberFormatException e) {
|
||||
output[i] = missing;
|
||||
}
|
||||
@@ -10669,7 +10669,7 @@ public class PApplet implements PConstants {
|
||||
try {
|
||||
Class<?> c =
|
||||
Thread.currentThread().getContextClassLoader().loadClass(name);
|
||||
sketch = (PApplet) c.newInstance();
|
||||
sketch = (PApplet) c.getDeclaredConstructor().newInstance();
|
||||
} catch (RuntimeException re) {
|
||||
// Don't re-package runtime exceptions
|
||||
throw re;
|
||||
|
||||
@@ -109,7 +109,7 @@ public class JSONArray {
|
||||
* Construct an empty JSONArray.
|
||||
*/
|
||||
public JSONArray() {
|
||||
this.myArrayList = new ArrayList<Object>();
|
||||
this.myArrayList = new ArrayList<>();
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ public class JSONArray {
|
||||
* @nowebref
|
||||
*/
|
||||
public JSONArray(IntList list) {
|
||||
myArrayList = new ArrayList<Object>();
|
||||
myArrayList = new ArrayList<>();
|
||||
for (int item : list.values()) {
|
||||
myArrayList.add(Integer.valueOf(item));
|
||||
}
|
||||
@@ -176,9 +176,9 @@ public class JSONArray {
|
||||
* @nowebref
|
||||
*/
|
||||
public JSONArray(FloatList list) {
|
||||
myArrayList = new ArrayList<Object>();
|
||||
myArrayList = new ArrayList<>();
|
||||
for (float item : list.values()) {
|
||||
myArrayList.add(new Float(item));
|
||||
myArrayList.add(Float.valueOf(item));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ public class JSONArray {
|
||||
* @nowebref
|
||||
*/
|
||||
public JSONArray(StringList list) {
|
||||
myArrayList = new ArrayList<Object>();
|
||||
myArrayList = new ArrayList<>();
|
||||
for (String item : list.values()) {
|
||||
myArrayList.add(item);
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ public class JSONObject {
|
||||
* string objects. This is used by JSONObject.put(string, object).
|
||||
*/
|
||||
private static HashMap<String, Object> keyPool =
|
||||
new HashMap<String, Object>(keyPoolSize);
|
||||
new HashMap<>(keyPoolSize);
|
||||
|
||||
|
||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
@@ -197,7 +197,7 @@ public class JSONObject {
|
||||
* @nowebref
|
||||
*/
|
||||
public JSONObject() {
|
||||
this.map = new HashMap<String, Object>();
|
||||
this.map = new HashMap<>();
|
||||
}
|
||||
|
||||
|
||||
@@ -291,7 +291,7 @@ public class JSONObject {
|
||||
* the JSONObject.
|
||||
*/
|
||||
protected JSONObject(HashMap<String, Object> map) {
|
||||
this.map = new HashMap<String, Object>();
|
||||
this.map = new HashMap<>();
|
||||
if (map != null) {
|
||||
Iterator i = map.entrySet().iterator();
|
||||
while (i.hasNext()) {
|
||||
@@ -309,7 +309,7 @@ public class JSONObject {
|
||||
* @nowebref
|
||||
*/
|
||||
public JSONObject(IntDict dict) {
|
||||
map = new HashMap<String, Object>();
|
||||
map = new HashMap<>();
|
||||
for (int i = 0; i < dict.size(); i++) {
|
||||
setInt(dict.key(i), dict.value(i));
|
||||
}
|
||||
@@ -320,7 +320,7 @@ public class JSONObject {
|
||||
* @nowebref
|
||||
*/
|
||||
public JSONObject(FloatDict dict) {
|
||||
map = new HashMap<String, Object>();
|
||||
map = new HashMap<>();
|
||||
for (int i = 0; i < dict.size(); i++) {
|
||||
setFloat(dict.key(i), dict.value(i));
|
||||
}
|
||||
@@ -331,7 +331,7 @@ public class JSONObject {
|
||||
* @nowebref
|
||||
*/
|
||||
public JSONObject(StringDict dict) {
|
||||
map = new HashMap<String, Object>();
|
||||
map = new HashMap<>();
|
||||
for (int i = 0; i < dict.size(); i++) {
|
||||
setString(dict.key(i), dict.value(i));
|
||||
}
|
||||
@@ -1212,7 +1212,7 @@ public class JSONObject {
|
||||
* @see JSONObject#setBoolean(String, boolean)
|
||||
*/
|
||||
public JSONObject setFloat(String key, float value) {
|
||||
this.put(key, new Double(value));
|
||||
this.put(key, Double.valueOf(value));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1226,7 +1226,7 @@ public class JSONObject {
|
||||
* @throws RuntimeException If the key is null or if the number is NaN or infinite.
|
||||
*/
|
||||
public JSONObject setDouble(String key, double value) {
|
||||
this.put(key, new Double(value));
|
||||
this.put(key, Double.valueOf(value));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1326,7 +1326,7 @@ public class JSONObject {
|
||||
pooled = (String)keyPool.get(key);
|
||||
if (pooled == null) {
|
||||
if (keyPool.size() >= keyPoolSize) {
|
||||
keyPool = new HashMap<String, Object>(keyPoolSize);
|
||||
keyPool = new HashMap<>(keyPoolSize);
|
||||
}
|
||||
keyPool.put(key, key);
|
||||
} else {
|
||||
|
||||
@@ -1076,7 +1076,7 @@ public class Table {
|
||||
}
|
||||
|
||||
Field[] fields = target.getDeclaredFields();
|
||||
ArrayList<Field> inuse = new ArrayList<Field>();
|
||||
ArrayList<Field> inuse = new ArrayList<>();
|
||||
for (Field field : fields) {
|
||||
String name = field.getName();
|
||||
if (getColumnIndex(name, false) != -1) {
|
||||
@@ -2215,7 +2215,7 @@ public class Table {
|
||||
// only create this on first get(). subsequent calls to set the title will
|
||||
// also update this array, but only if it exists.
|
||||
if (columnIndices == null) {
|
||||
columnIndices = new HashMap<String, Integer>();
|
||||
columnIndices = new HashMap<>();
|
||||
for (int col = 0; col < columns.length; col++) {
|
||||
columnIndices.put(columnTitles[col], col);
|
||||
}
|
||||
@@ -4195,8 +4195,8 @@ public class Table {
|
||||
|
||||
|
||||
static class HashMapBlows {
|
||||
HashMap<String,Integer> dataToIndex = new HashMap<String, Integer>();
|
||||
ArrayList<String> indexToData = new ArrayList<String>();
|
||||
HashMap<String,Integer> dataToIndex = new HashMap<>();
|
||||
ArrayList<String> indexToData = new ArrayList<>();
|
||||
|
||||
HashMapBlows() { }
|
||||
|
||||
@@ -4255,7 +4255,7 @@ public class Table {
|
||||
void read(DataInputStream input) throws IOException {
|
||||
int count = input.readInt();
|
||||
//System.out.println("found " + count + " entries in category map");
|
||||
dataToIndex = new HashMap<String, Integer>(count);
|
||||
dataToIndex = new HashMap<>(count);
|
||||
for (int i = 0; i < count; i++) {
|
||||
String str = input.readUTF();
|
||||
//System.out.println(i + " " + str);
|
||||
|
||||
@@ -17,6 +17,13 @@ X https://github.com/processing/processing/pull/5202
|
||||
_ need to make this work behind the scenes instead
|
||||
_ create icon.png or have an 'icons' folder with multiple sizes
|
||||
|
||||
_ Switch to getModifiersEx() and fix the AWT modifiers used in PSurfaceAWT
|
||||
_ this is an easy fix, but need to check impact elsewhere
|
||||
_ does anything else rely on these modifiers?
|
||||
|
||||
_ Fix Java 9 incompatibilities inside PSurfaceFX
|
||||
_ https://github.com/processing/processing/issues/5286
|
||||
|
||||
_ Hitting ESC in FX2D app on macOS throws IllegalStateException
|
||||
_ https://github.com/processing/processing/issues/5249
|
||||
|
||||
|
||||
Reference in New Issue
Block a user