PR java/19870: Generate Synthetic Accessors For Static Private Field Accesses Across Nested Classes

Ranjit Mathew
Thu May 26 09:43:00 GMT 2005


  Here is a patch for PR java/19870. This patch generalises
the current synthetic accessor generation support in GCJ for
private fields in outer classes accessed from nested classes
to additionally support:

  1. private *static* fields

  2. access to private static fields *inside nested classes*
     (the original testcase given in PR19870)

  3. access from a nested class to a private static field
     in a "sibling" nested class.

The attached testsuite patch demonstrates what is now
possible to support in GCJ with this patch.

For static accessors, the initial "this$" parameter
is ommitted now.

Since the accessors work both ways now, I've renamed
all "*outer_field*" methods and macros to "*nested_field*"
for lack of a better name and updated their documentation.

Tested on i686-pc-linux-gnu with Jacks included. The Jacks
testresults were rather disappointing:

  FAIL: 8.5.2-accessible-static-member-usage-3
  FAIL: 15.8.4-static-2

The first is a failure to consider "foo" constant
in "case foo:" for a switch statement, where foo is
an outer field. The second is a slight corner case
that used to mistakenly pass earlier. I vote to
just XFAIL these two for now.

OK for mainline? Assuming the patch as such is
OK, is the attached testsuite addition also OK?

The new testcase demonstrates all the static
field access (read/write) combinations that
work correctly now.


Ranjit Mathew      Email: rmathew AT gmail DOT com

Bangalore, INDIA.    Web:
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pr19870.txt
URL: <>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pr19870tests.txt
URL: <>

More information about the Java-patches mailing list