This is the mail archive of the java-patches@gcc.gnu.org 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]
Other format: [Raw text]

Re: PR java/25429: can't see private static final int CREATE = 1


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Tom Tromey wrote:
> 
> Andrew> Constant propagation is broken when importing into an inner class.
> 
> Here's an updated patch plus a couple of test cases.  I tested this on
> the trunk.  I'm checking it in there.

Note that this fixes the Jacks testcase
8.5.2-accessible-static-member-usage-3
(tests/jls/classes/member-type-declarations/static-member-type-declarations).

Thanks,
Ranjit.

PS: Hey, am I the only one these days who tests against Jacks? :-/


> Andrew, where were you going to check this in?
> 4.1?  Does 4.0 need it?
> 
> Tom
> 
> Index: gcc/java/ChangeLog
> from  Tom Tromey  <tromey@redhat.com>
> 	Andrew Haley  <aph@redhat.com>
> 
> 	PR java/25429
> 	* parse.y (resolve_expression_name): Don't generate accessor
> 	methods for constant fields.
> 
> Index: libjava/ChangeLog
> from  Tom Tromey  <tromey@redhat.com>
> 
> 	* testsuite/libjava.compile/rh175833.java: New file.
> 	* testsuite/libjava.compile/pr25429.java: New file.
> 
> Index: gcc/java/parse.y
> ===================================================================
> --- gcc/java/parse.y	(revision 108605)
> +++ gcc/java/parse.y	(working copy)
> @@ -9584,8 +9584,15 @@
>  
>  	      /* If we're processing an inner class and we're trying
>  		 to access a field belonging to an outer class, build
> -		 the access to the field.  */
> -	      if (nested_member_access_p (current_class, decl))
> +		 the access to the field.
> +		 As usual, we have to treat initialized static final
> +		 variables as a special case.  */
> +              if (nested_member_access_p (current_class, decl)
> +                  && ! (JDECL_P (decl) && CLASS_FINAL_VARIABLE_P (decl)
> +                        && DECL_INITIAL (decl) != NULL_TREE
> +			&& (JSTRING_TYPE_P (TREE_TYPE (decl))
> +			    || JNUMERIC_TYPE_P (TREE_TYPE (decl)))
> +			&& TREE_CONSTANT (DECL_INITIAL (decl))))
>  		{
>  		  if (!fs && CLASS_STATIC (TYPE_NAME (current_class)))
>  		    {
> Index: libjava/testsuite/libjava.compile/pr25429.java
> ===================================================================
> --- libjava/testsuite/libjava.compile/pr25429.java	(revision 0)
> +++ libjava/testsuite/libjava.compile/pr25429.java	(revision 0)
> @@ -0,0 +1,13 @@
> +public class pr25429
> +{
> +  private static final int CONST  = 0;
> +  class I {
> +    public void f () {
> +      switch(0) {
> +      case CONST:
> +      }
> +    }
> +  }
> +
> +  public static void main(String[] args) { }
> +}
> Index: libjava/testsuite/libjava.compile/rh175833.java
> ===================================================================
> --- libjava/testsuite/libjava.compile/rh175833.java	(revision 0)
> +++ libjava/testsuite/libjava.compile/rh175833.java	(revision 0)
> @@ -0,0 +1,13 @@
> +// Follow-on to PR 25429
> +public class rh175833
> +{
> +  private static final Object CONST  = new Object();
> +    class I {
> +        public Object f () {
> +	  // We need an accessor here.
> +	  return CONST;
> +        }
> +    }
> +
> +  public static void main(String[] args) { }
> +}
> 


- --
Ranjit Mathew      Email: rmathew AT gmail DOT com

Bangalore, INDIA.    Web: http://ranjitmathew.hostingzero.com/


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDokpwYb1hx2wRS48RAp23AJwKZxE7MPkDRXyqWrAziVWk4xRaHACeJyeE
REgn/tpRV+kMG7opED2KiLA=
=6JU5
-----END PGP SIGNATURE-----


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