This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFC: fix PR 28892

PR 28892 involves compiling bytecode which has been run through
retroweaver.  Apparently retroweaver will emit bytecode that
initializes static final variables in methods other than <clinit>.
This particular set of constraints doesn't appear to be checked by the
JDK, meaning that this is bytecode which JDK users can run but which
we will reject.

I fixed this by removing the checks.  Any comments (Andrew?) before I
check this in?

This passes our test suite.  It also lets me compiling the test jars
from the PR.


Index: java/ChangeLog
from  Tom Tromey  <>

	PR java/28892:
	* expr.c (expand_java_field_op): No error for assignments not in
	class initializer or constructor.

Index: java/expr.c
--- java/expr.c	(revision 116140)
+++ java/expr.c	(working copy)
@@ -2846,21 +2846,10 @@
 	  if (DECL_CONTEXT (field_decl) != current_class)
             error ("assignment to final field %q+D not in field's class",
-	  else if (FIELD_STATIC (field_decl))
-	    {
-	      if (!DECL_CLINIT_P (current_function_decl))
-		warning (0, "assignment to final static field %q+D not in "
-                         "class initializer",
-                         field_decl);
-	    }
-	  else
-	    {
-	      tree cfndecl_name = DECL_NAME (current_function_decl);
-	      if (! DECL_CONSTRUCTOR_P (current_function_decl)
-		  && !ID_FINIT_P (cfndecl_name))
-                warning (0, "assignment to final field %q+D not in constructor",
-			 field_decl);
-	    }
+	  /* We used to check for assignments to final fields not
+	     occurring in the class initializer or in a constructor
+	     here.  However, this constraint doesn't seem to be
+	     enforced by the JVM.  */
       if (TREE_THIS_VOLATILE (field_decl))

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