Patch: another initialization check

Tom Tromey tromey@cygnus.com
Tue May 23 14:42:00 GMT 2000


This is inspired by PR 162, but is different in that it checks to make
sure that the Java compiler understands that Strings are constants.
(It doesn't.)

2000-05-23  Tom Tromey  <tromey@cygnus.com>

	* libjava.lang/stringconst.out: New file.
	* libjava.lang/stringconst.java: New file.

Tom

Index: libjava.lang/stringconst.out
===================================================================
RCS file: stringconst.out
diff -N stringconst.out
--- /dev/null	Tue May  5 13:32:27 1998
+++ stringconst.out	Tue May 23 14:41:51 2000
@@ -0,0 +1 @@
+zardoz
Index: libjava.lang/stringconst.java
===================================================================
RCS file: stringconst.java
diff -N stringconst.java
--- /dev/null	Tue May  5 13:32:27 1998
+++ stringconst.java	Tue May 23 14:41:51 2000
@@ -0,0 +1,22 @@
+// A reference to a String shouldn't cause an interface to be
+// initialized.
+
+interface I
+{
+  String z = "zardoz";
+  int q = stringconst.out ("q", 0);
+}
+
+public class stringconst
+{
+  public static int out (String s, int i)
+  {
+    System.out.println (s + "=" + i);
+    return i;
+  }
+
+  public static void main (String[] args)
+  {
+    System.out.println (I.z);
+  }
+}


More information about the Java-patches mailing list