@@ -1581,18 +1581,7 @@ public void unregisterMethod(String name, Object target) {
15811581 }
15821582 }
15831583
1584-
1585- protected void handleMethods(String methodName) {
1586- synchronized (registerLock) {
1587- RegisteredMethods meth = registerMap.get(methodName);
1588- if (meth != null) {
1589- meth.handle();
1590- }
1591- }
1592- }
1593-
1594-
1595- protected void handleMethods(String methodName, Object[] args) {
1584+ protected void handleMethods(String methodName, Object...args) {
15961585 synchronized (registerLock) {
15971586 RegisteredMethods meth = registerMap.get(methodName);
15981587 if (meth != null) {
@@ -2223,7 +2212,7 @@ protected PGraphics makeGraphics(int w, int h,
22232212 Class<?> rendererClass =
22242213 Thread.currentThread().getContextClassLoader().loadClass(renderer);
22252214
2226- Constructor<?> constructor = rendererClass.getConstructor(new Class[] { } );
2215+ Constructor<?> constructor = rendererClass.getConstructor();
22272216 PGraphics pg = (PGraphics) constructor.newInstance();
22282217
22292218 pg.setParent(this);
@@ -2707,7 +2696,7 @@ protected void handleMouseEvent(MouseEvent event) {
27072696 break;
27082697 }
27092698
2710- handleMethods("mouseEvent", new Object[] { event } );
2699+ handleMethods("mouseEvent", event);
27112700
27122701 switch (action) {
27132702 case MouseEvent.PRESS:
@@ -2979,7 +2968,7 @@ protected void handleKeyEvent(KeyEvent event) {
29792968 }
29802969 */
29812970
2982- handleMethods("keyEvent", new Object[] { event } );
2971+ handleMethods("keyEvent", event);
29832972
29842973 // if someone else wants to intercept the key, they should
29852974 // set key to zero (or something besides the ESC).
@@ -3824,8 +3813,8 @@ public void dispose() {
38243813 */
38253814 public void method(String name) {
38263815 try {
3827- Method method = getClass().getMethod(name, new Class[] {} );
3828- method.invoke(this, new Object[] { } );
3816+ Method method = getClass().getMethod(name);
3817+ method.invoke(this);
38293818
38303819 } catch (IllegalArgumentException e) {
38313820 e.printStackTrace();
@@ -6676,8 +6665,8 @@ static private void selectCallback(File selectedFile,
66766665 try {
66776666 Class<?> callbackClass = callbackObject.getClass();
66786667 Method selectMethod =
6679- callbackClass.getMethod(callbackMethod, new Class[] { File.class } );
6680- selectMethod.invoke(callbackObject, new Object[] { selectedFile } );
6668+ callbackClass.getMethod(callbackMethod, File.class);
6669+ selectMethod.invoke(callbackObject, selectedFile);
66816670
66826671 } catch (IllegalAccessException iae) {
66836672 System.err.println(callbackMethod + "() must be public");
@@ -10802,8 +10791,8 @@ public void uncaughtException(Thread t, Throwable e) {
1080210791 Class<?> thinkDifferent =
1080310792 Thread.currentThread().getContextClassLoader().loadClass(td);
1080410793 Method method =
10805- thinkDifferent.getMethod("init", new Class[] { PApplet.class } );
10806- method.invoke(null, new Object[] { sketch } );
10794+ thinkDifferent.getMethod("init", PApplet.class);
10795+ method.invoke(null, sketch);
1080710796 } catch (Exception e) {
1080810797 e.printStackTrace(); // That's unfortunate
1080910798 }
0 commit comments