diff --git a/core/src/processing/awt/PSurfaceAWT.java b/core/src/processing/awt/PSurfaceAWT.java index 8d897f44df..705f771872 100644 --- a/core/src/processing/awt/PSurfaceAWT.java +++ b/core/src/processing/awt/PSurfaceAWT.java @@ -597,8 +597,8 @@ public void setIcon(PImage image) { Class thinkDifferent = Thread.currentThread().getContextClassLoader().loadClass(td); Method method = - thinkDifferent.getMethod("setIconImage", new Class[] { java.awt.Image.class }); - method.invoke(null, new Object[] { awtImage }); + thinkDifferent.getMethod("setIconImage", Image.class); + method.invoke(null, awtImage); } catch (Exception e) { e.printStackTrace(); // That's unfortunate } @@ -655,8 +655,8 @@ protected void setProcessingIcon(Frame frame) { Class thinkDifferent = Thread.currentThread().getContextClassLoader().loadClass(td); Method method = - thinkDifferent.getMethod("setIconImage", new Class[] { java.awt.Image.class }); - method.invoke(null, new Object[] { Toolkit.getDefaultToolkit().getImage(url) }); + thinkDifferent.getMethod("setIconImage", Image.class); + method.invoke(null, Toolkit.getDefaultToolkit().getImage(url)); } catch (Exception e) { e.printStackTrace(); // That's unfortunate } diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index ccc62e859a..3b8b06a984 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -1581,18 +1581,7 @@ public void unregisterMethod(String name, Object target) { } } - - protected void handleMethods(String methodName) { - synchronized (registerLock) { - RegisteredMethods meth = registerMap.get(methodName); - if (meth != null) { - meth.handle(); - } - } - } - - - protected void handleMethods(String methodName, Object[] args) { + protected void handleMethods(String methodName, Object...args) { synchronized (registerLock) { RegisteredMethods meth = registerMap.get(methodName); if (meth != null) { @@ -2223,7 +2212,7 @@ protected PGraphics makeGraphics(int w, int h, Class rendererClass = Thread.currentThread().getContextClassLoader().loadClass(renderer); - Constructor constructor = rendererClass.getConstructor(new Class[] { }); + Constructor constructor = rendererClass.getConstructor(); PGraphics pg = (PGraphics) constructor.newInstance(); pg.setParent(this); @@ -2707,7 +2696,7 @@ protected void handleMouseEvent(MouseEvent event) { break; } - handleMethods("mouseEvent", new Object[] { event }); + handleMethods("mouseEvent", event); switch (action) { case MouseEvent.PRESS: @@ -2979,7 +2968,7 @@ protected void handleKeyEvent(KeyEvent event) { } */ - handleMethods("keyEvent", new Object[] { event }); + handleMethods("keyEvent", event); // if someone else wants to intercept the key, they should // set key to zero (or something besides the ESC). @@ -3824,8 +3813,8 @@ public void dispose() { */ public void method(String name) { try { - Method method = getClass().getMethod(name, new Class[] {}); - method.invoke(this, new Object[] { }); + Method method = getClass().getMethod(name); + method.invoke(this); } catch (IllegalArgumentException e) { e.printStackTrace(); @@ -6676,8 +6665,8 @@ static private void selectCallback(File selectedFile, try { Class callbackClass = callbackObject.getClass(); Method selectMethod = - callbackClass.getMethod(callbackMethod, new Class[] { File.class }); - selectMethod.invoke(callbackObject, new Object[] { selectedFile }); + callbackClass.getMethod(callbackMethod, File.class); + selectMethod.invoke(callbackObject, selectedFile); } catch (IllegalAccessException iae) { System.err.println(callbackMethod + "() must be public"); @@ -10802,8 +10791,8 @@ public void uncaughtException(Thread t, Throwable e) { Class thinkDifferent = Thread.currentThread().getContextClassLoader().loadClass(td); Method method = - thinkDifferent.getMethod("init", new Class[] { PApplet.class }); - method.invoke(null, new Object[] { sketch }); + thinkDifferent.getMethod("init", PApplet.class); + method.invoke(null, sketch); } catch (Exception e) { e.printStackTrace(); // That's unfortunate } diff --git a/core/src/processing/data/Table.java b/core/src/processing/data/Table.java index 7dde4803bb..da18974e80 100644 --- a/core/src/processing/data/Table.java +++ b/core/src/processing/data/Table.java @@ -1062,7 +1062,7 @@ public void parseInto(Object enclosingObject, String fieldName) { con = target.getDeclaredConstructor(); //new Class[] { }); // PApplet.println("no enclosing class"); } else { - con = target.getDeclaredConstructor(new Class[] { enclosingClass }); + con = target.getDeclaredConstructor(enclosingClass); // PApplet.println("enclosed by " + enclosingClass.getName()); } if (!con.canAccess(null)) { @@ -1509,17 +1509,15 @@ protected void saveODS(OutputStream os) throws IOException { entry = new ZipEntry("content.xml"); zos.putNextEntry(entry); //lines = new String[] { - writeUTF(zos, new String[] { - xmlHeader, - "", - " ", - " ", - " " - }); + writeUTF(zos, xmlHeader, + "", + " ", + " ", + " "); //zos.write(PApplet.join(lines, "\n").getBytes()); byte[] rowStart = " \n".getBytes(); @@ -1546,12 +1544,10 @@ protected void saveODS(OutputStream os) throws IOException { } //lines = new String[] { - writeUTF(zos, new String[] { - " ", - " ", - " ", - "" - }); + writeUTF(zos, " ", + " ", + " ", + ""); //zos.write(PApplet.join(lines, "\n").getBytes()); zos.closeEntry(); diff --git a/core/src/processing/opengl/PGraphicsOpenGL.java b/core/src/processing/opengl/PGraphicsOpenGL.java index b4f145eda6..7d992cdb36 100644 --- a/core/src/processing/opengl/PGraphicsOpenGL.java +++ b/core/src/processing/opengl/PGraphicsOpenGL.java @@ -53,7 +53,7 @@ public class PGraphicsOpenGL extends PGraphics { // Using the technique alternative to finalization described in: // http://www.oracle.com/technetwork/articles/java/finalization-137655.html private static ReferenceQueue refQueue = new ReferenceQueue<>(); - private static List> reachableWeakReferences = + private static List> reachableWeakReferences = new LinkedList<>(); static final private int MAX_DRAIN_GLRES_ITERATIONS = 10; @@ -61,8 +61,8 @@ public class PGraphicsOpenGL extends PGraphics { static void drainRefQueueBounded() { int iterations = 0; while (iterations < MAX_DRAIN_GLRES_ITERATIONS) { - Disposable res = - (Disposable) refQueue.poll(); + Disposable res = + (Disposable) refQueue.poll(); if (res == null) { break; } diff --git a/core/src/processing/opengl/PJOGL.java b/core/src/processing/opengl/PJOGL.java index 9c057313a0..debe596654 100644 --- a/core/src/processing/opengl/PJOGL.java +++ b/core/src/processing/opengl/PJOGL.java @@ -1469,7 +1469,7 @@ public int createShader(int type) { @Override public void shaderSource(int shader, String source) { - gl2.glShaderSource(shader, 1, new String[] { source }, (int[]) null, 0); + gl2.glShaderSource(shader, 1, new String[] { source }, null, 0); } @Override diff --git a/core/src/processing/opengl/PShapeOpenGL.java b/core/src/processing/opengl/PShapeOpenGL.java index 96165fb810..c1ef87cad3 100644 --- a/core/src/processing/opengl/PShapeOpenGL.java +++ b/core/src/processing/opengl/PShapeOpenGL.java @@ -4681,7 +4681,7 @@ public void draw(PGraphics g) { if (family == GROUP) { if (fragmentedGroup(gl)) { for (int i = 0; i < childCount; i++) { - ((PShapeOpenGL) children[i]).draw(gl); + children[i].draw(gl); } } else { PImage tex = null; diff --git a/core/src/processing/opengl/Texture.java b/core/src/processing/opengl/Texture.java index 4cc51ba645..b6bf7d2bf1 100644 --- a/core/src/processing/opengl/Texture.java +++ b/core/src/processing/opengl/Texture.java @@ -925,7 +925,7 @@ protected boolean bufferUpdate() { protected void getSourceMethods() { try { disposeBufferMethod = bufferSource.getClass(). - getMethod("disposeBuffer", new Class[] { Object.class }); + getMethod("disposeBuffer", Object.class); } catch (Exception e) { throw new RuntimeException("Provided source object doesn't have a " + "disposeBuffer method."); @@ -1659,7 +1659,7 @@ protected class BufferData { void dispose() { try { // Disposing the native buffer. - disposeBufferMethod.invoke(bufferSource, new Object[] { natBuf }); + disposeBufferMethod.invoke(bufferSource, natBuf); natBuf = null; rgbBuf = null; } catch (Exception e) {