From 0eb450e9d8d274992727fddcaff2d3bdec8a9e9c Mon Sep 17 00:00:00 2001 From: Brendan Robert Date: Wed, 17 Sep 2014 23:53:59 -0500 Subject: [PATCH] Fixed initalization issues caused by recent refactoring and verified a few cards --- src/main/java/jace/apple2e/Apple2e.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/jace/apple2e/Apple2e.java b/src/main/java/jace/apple2e/Apple2e.java index f0f4e68..b6b1afc 100644 --- a/src/main/java/jace/apple2e/Apple2e.java +++ b/src/main/java/jace/apple2e/Apple2e.java @@ -198,16 +198,19 @@ public class Apple2e extends Computer { RAM128k currentMemory = (RAM128k) getMemory(); if (currentMemory != null && !(currentMemory.getClass().equals(ramCard.getValue()))) { try { - RAM128k newMemory = (RAM128k) ramCard.getValue().newInstance(); + RAM128k newMemory = (RAM128k) ramCard.getValue().getConstructor(Computer.class).newInstance(this); newMemory.copyFrom(currentMemory); setMemory(newMemory); - } catch (InstantiationException | IllegalAccessException ex) { + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException ex) { + Logger.getLogger(Apple2e.class.getName()).log(Level.SEVERE, null, ex); } } if (getMemory() == null) { try { - currentMemory = (RAM128k) ramCard.getValue().newInstance(); - } catch (InstantiationException | IllegalAccessException ex) { + currentMemory = (RAM128k) ramCard.getValue().getConstructor(Computer.class).newInstance(this); + } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | SecurityException ex) { + Logger.getLogger(Apple2e.class.getName()).log(Level.SEVERE, null, ex); + } catch (IllegalArgumentException | InvocationTargetException ex) { Logger.getLogger(Apple2e.class.getName()).log(Level.SEVERE, null, ex); } try { @@ -240,7 +243,7 @@ public class Apple2e extends Computer { g = getVideo().getScreen(); } try { - setVideo((Video) videoRenderer.getValue().newInstance()); + setVideo((Video) videoRenderer.getValue().getConstructor(Computer.class).newInstance(this)); getVideo().configureVideoMode(); getVideo().reconfigure(); getVideo().setScreen(g); @@ -248,6 +251,8 @@ public class Apple2e extends Computer { getVideo().resume(); } catch (InstantiationException | IllegalAccessException ex) { Logger.getLogger(Apple2e.class.getName()).log(Level.SEVERE, null, ex); + } catch (NoSuchMethodException | SecurityException | IllegalArgumentException | InvocationTargetException ex) { + Logger.getLogger(Apple2e.class.getName()).log(Level.SEVERE, null, ex); } }