Test Class.forName and serialization on inner classes

Change-Id: Ib8e5e5df02818ca05d46d866f60a59c07a843d51
diff --git a/test/042-new-instance/expected.txt b/test/042-new-instance/expected.txt
index bb1b80c..7d843d1 100644
--- a/test/042-new-instance/expected.txt
+++ b/test/042-new-instance/expected.txt
@@ -4,6 +4,8 @@
 Got expected InstantationError
 Cons LocalClass failed as expected
 Cons LocalClass2 succeeded
+Cons InnerClass succeeded
+Cons StaticInnerClass succeeded
 Cons got expected PackageAccess complaint
 Cons got expected InstantationException
 Cons got expected PackageAccess2 complaint
diff --git a/test/042-new-instance/src/Main.java b/test/042-new-instance/src/Main.java
index e43c5a5..b0a5fd4 100644
--- a/test/042-new-instance/src/Main.java
+++ b/test/042-new-instance/src/Main.java
@@ -92,6 +92,28 @@
             ex.printStackTrace();
         }
 
+        // should succeed
+        try {
+            Class c = Class.forName("Main$InnerClass");
+            Constructor cons = c.getDeclaredConstructor(new Class<?>[]{Main.class});
+            Object obj = cons.newInstance(new Main());
+            System.out.println("Cons InnerClass succeeded");
+        } catch (Exception ex) {
+            System.err.println("Cons InnerClass failed");
+            ex.printStackTrace();
+        }
+
+        // should succeed
+        try {
+            Class c = Class.forName("Main$StaticInnerClass");
+            Constructor cons = c.getDeclaredConstructor((Class[]) null);
+            Object obj = cons.newInstance();
+            System.out.println("Cons StaticInnerClass succeeded");
+        } catch (Exception ex) {
+            System.err.println("Cons StaticInnerClass failed");
+            ex.printStackTrace();
+        }
+
         // should fail
         try {
             Class c = Class.forName("otherpackage.PackageAccess");
@@ -135,6 +157,12 @@
         }
 
     }
+
+    class InnerClass {
+    }
+
+    static class StaticInnerClass {
+    }
 }
 
 class LocalClass {
diff --git a/test/093-serialization/expected.txt b/test/093-serialization/expected.txt
index 60c64f8..c9bc1c3 100644
--- a/test/093-serialization/expected.txt
+++ b/test/093-serialization/expected.txt
@@ -1 +1,2 @@
 one=true two=2 three=three four=4.0 five=5.0 six=6 seven=7 eight=8 nine=9 thing=X
+x=cafef00d
diff --git a/test/093-serialization/src/Main.java b/test/093-serialization/src/Main.java
index ca3dc9f..3cb98be 100644
--- a/test/093-serialization/src/Main.java
+++ b/test/093-serialization/src/Main.java
@@ -47,6 +47,8 @@
 
         Sub sub = new Sub('X');
         objStream.writeObject(sub);
+        Inner inner = new Inner(0xCAFEF00D);
+        objStream.writeObject(inner);
         byte[] bytes = byteStream.toByteArray();
 
         objStream.close();
@@ -59,8 +61,10 @@
         ObjectInputStream objStream = new ObjectInputStream(byteStream);
 
         Sub sub;
+        Inner inner;
         try {
             sub = (Sub) objStream.readObject();
+            inner = (Inner) objStream.readObject();
         } catch (ClassNotFoundException cnfe) {
             throw new RuntimeException(cnfe);
         }
@@ -69,6 +73,19 @@
         byteStream.close();
 
         sub.check();
+        inner.check();
+    }
+
+    static class Inner implements Serializable {
+        private static final long serialVersionUID = 319009;
+        private final int x;
+        public Inner (int x) {
+            this.x = x;
+        }
+
+        public void check() {
+            System.out.println("x=" + Integer.toHexString(x));
+        }
     }
 }
 
@@ -113,4 +130,3 @@
             + " thing=" + thing);
     }
 }
-