This is the mail archive of the
java-patches@sourceware.cygnus.com
mailing list for the Java project.
Patch: another initialization check
- To: Java Patch List <java-patches at sourceware dot cygnus dot com>
- Subject: Patch: another initialization check
- From: Tom Tromey <tromey at cygnus dot com>
- Date: 23 May 2000 15:43:48 -0600
- Reply-To: tromey at cygnus dot com
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);
+ }
+}