This is the mail archive of the java-patches@sourceware.cygnus.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch: another initialization check


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);
+  }
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]