Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions core/src/processing/awt/PSurfaceAWT.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
33 changes: 11 additions & 22 deletions core/src/processing/core/PApplet.java
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@ public int displayDensity(int display) {
field.setAccessible(true);
Object scale = field.get(device);

if (scale instanceof Integer && ((Integer)scale).intValue() == 2) {
if (scale instanceof Integer && (Integer) scale == 2) {
return 2;
}
}
Expand Down Expand Up @@ -1620,18 +1620,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) {
Expand Down Expand Up @@ -2262,7 +2251,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);
Expand Down Expand Up @@ -2746,7 +2735,7 @@ protected void handleMouseEvent(MouseEvent event) {
break;
}

handleMethods("mouseEvent", new Object[] { event });
handleMethods("mouseEvent", event);

switch (action) {
case MouseEvent.PRESS:
Expand Down Expand Up @@ -3018,7 +3007,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).
Expand Down Expand Up @@ -3863,8 +3852,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();
Expand Down Expand Up @@ -6715,8 +6704,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");
Expand Down Expand Up @@ -10841,8 +10830,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
}
Expand Down
34 changes: 15 additions & 19 deletions core/src/processing/data/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.isAccessible()) {
Expand Down Expand Up @@ -1099,7 +1099,7 @@ public void parseInto(Object enclosingObject, String fieldName) {
//item = target.newInstance();
item = con.newInstance();
} else {
item = con.newInstance(new Object[] { enclosingObject });
item = con.newInstance(enclosingObject);
}
//Object item = defaultCons.newInstance(new Object[] { });
for (Field field : inuse) {
Expand Down Expand Up @@ -1503,17 +1503,15 @@ protected void saveODS(OutputStream os) throws IOException {
entry = new ZipEntry("content.xml");
zos.putNextEntry(entry);
//lines = new String[] {
writeUTF(zos, new String[] {
xmlHeader,
"<office:document-content" +
" xmlns:office=\"urn:oasis:names:tc:opendocument:xmlns:office:1.0\"" +
" xmlns:text=\"urn:oasis:names:tc:opendocument:xmlns:text:1.0\"" +
" xmlns:table=\"urn:oasis:names:tc:opendocument:xmlns:table:1.0\"" +
" office:version=\"1.2\">",
" <office:body>",
" <office:spreadsheet>",
" <table:table table:name=\"Sheet1\" table:print=\"false\">"
});
writeUTF(zos, xmlHeader,
"<office:document-content" +
" xmlns:office=\"urn:oasis:names:tc:opendocument:xmlns:office:1.0\"" +
" xmlns:text=\"urn:oasis:names:tc:opendocument:xmlns:text:1.0\"" +
" xmlns:table=\"urn:oasis:names:tc:opendocument:xmlns:table:1.0\"" +
" office:version=\"1.2\">",
" <office:body>",
" <office:spreadsheet>",
" <table:table table:name=\"Sheet1\" table:print=\"false\">");
//zos.write(PApplet.join(lines, "\n").getBytes());

byte[] rowStart = " <table:table-row>\n".getBytes();
Expand All @@ -1540,12 +1538,10 @@ protected void saveODS(OutputStream os) throws IOException {
}

//lines = new String[] {
writeUTF(zos, new String[] {
" </table:table>",
" </office:spreadsheet>",
" </office:body>",
"</office:document-content>"
});
writeUTF(zos, " </table:table>",
" </office:spreadsheet>",
" </office:body>",
"</office:document-content>");
//zos.write(PApplet.join(lines, "\n").getBytes());
zos.closeEntry();

Expand Down
6 changes: 3 additions & 3 deletions core/src/processing/opengl/PGraphicsOpenGL.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ 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<Object> refQueue = new ReferenceQueue<>();
private static List<Disposable<? extends Object>> reachableWeakReferences =
private static List<Disposable<?>> reachableWeakReferences =
new LinkedList<>();

static final private int MAX_DRAIN_GLRES_ITERATIONS = 10;

static void drainRefQueueBounded() {
int iterations = 0;
while (iterations < MAX_DRAIN_GLRES_ITERATIONS) {
Disposable<? extends Object> res =
(Disposable<? extends Object>) refQueue.poll();
Disposable<?> res =
(Disposable<?>) refQueue.poll();
if (res == null) {
break;
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/processing/opengl/PJOGL.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core/src/processing/opengl/PShapeOpenGL.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions core/src/processing/opengl/Texture.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down Expand Up @@ -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) {
Expand Down