This is the mail archive of the
mauve-patches@sourceware.org
mailing list for the Mauve project.
Patch: FYI: add another newInstance test
- From: Tom Tromey <tromey at redhat dot com>
- To: Mauve Patch List <mauve-patches at sources dot redhat dot com>
- Cc: Christian Thalinger <twisti at complang dot tuwien dot ac dot at>
- Date: 28 Feb 2006 11:26:09 -0700
- Subject: Patch: FYI: add another newInstance test
- Reply-to: tromey at redhat dot com
Twisti said on irc that the xalan problem is caused by something in
newInstance.
I added a quick test case for this ... but the test already passes on
jamvm, gij, and the JDK.
So perhaps I'm misunderstanding what the bug is actually supposed to
be. Twisti, any comments?
Tom
2006-02-28 Tom Tromey <tromey@redhat.com>
* gnu/testlet/java/lang/Class/newInstance.java (test6): New class.
(test): Updated comment. Run test6 test.
Index: gnu/testlet/java/lang/Class/newInstance.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/lang/Class/newInstance.java,v
retrieving revision 1.5
diff -u -r1.5 newInstance.java
--- gnu/testlet/java/lang/Class/newInstance.java 22 Dec 2005 12:46:02 -0000 1.5
+++ gnu/testlet/java/lang/Class/newInstance.java 28 Feb 2006 18:27:45 -0000
@@ -23,6 +23,8 @@
package gnu.testlet.java.lang.Class;
+import java.io.IOException;
+
import gnu.testlet.Testlet;
import gnu.testlet.TestHarness;
@@ -135,6 +137,29 @@
}
}
+ public static class test6
+ {
+ public test6() throws IOException
+ {
+ throw new IOException("hi bob");
+ }
+
+ static void check(TestHarness harness)
+ {
+ boolean ok = false;
+ try
+ {
+ test6.class.newInstance();
+ }
+ catch (Throwable t)
+ {
+ harness.debug(t);
+ ok = t instanceof IOException;
+ }
+ harness.check(ok);
+ }
+ }
+
public void test(TestHarness harness)
{
test1.check(harness);
@@ -150,9 +175,11 @@
// Just see to it that the following is legal.
new test5();
// If new test5() is legal, why should test5.class.newInstance()
- // throw IllegalAccessException? But the runtime access control
- // is somewhat different from the compile time access control.
- // So it may be OK that Sun's JDK throws IllegalAccessException here.
+ // throw IllegalAccessException? The reason that it is different is
+ // that 'new test5()' will call a compiler-generated accessor
+ // constructor. This accessor has package-private access and an
+ // extra argument (to differentiate it from the user-written
+ // constructor).
checkFail(harness, test5.class);
checkSuccess(harness, test1.inner.class);
@@ -169,6 +196,8 @@
harness.debug(x);
harness.fail("test configuration failure");
}
+
+ test6.check(harness);
}
static void checkSuccess(TestHarness harness, Class c)