This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Java: Fix .class accessibility flags for inner classes
- From: Bryce McKinlay <bryce at waitaki dot otago dot ac dot nz>
- To: java-patches at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Thu, 08 Aug 2002 18:02:41 +1200
- Subject: Java: Fix .class accessibility flags for inner classes
GCJ did not put the correct accessibility flags on the bytecode
generated for private and protected inner classes.
For example:
class A
{
private class X {}
}
Running jcf-dump on A$X.class we see:
Attribute "InnerClasses", length:10
class: 2=A$X (21="X"), access flags: 0x0, outer class: 20=A
But with javac:
Attribute "InnerClasses", length:10
class: 2=A$X (21="X"), access flags: 0x2 private, outer class: 20=A
This would cause incorrect accessibility errors when, for example,
trying to access a protected inner class from another package when the
class file is produced by GCJ.
regards
Bryce.
2002-08-08 Bryce McKinlay <bryce@waitaki.otago.ac.nz>
* jcf-write.c (get_access_flags): Return correct access flags for
private and protected inner classes.
Index: jcf-write.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-write.c,v
retrieving revision 1.107
diff -u -r1.107 jcf-write.c
--- jcf-write.c 11 Jun 2002 17:31:11 -0000 1.107
+++ jcf-write.c 8 Aug 2002 05:52:01 -0000
@@ -683,6 +683,10 @@
flags |= ACC_INTERFACE;
if (CLASS_STATIC (decl))
flags |= ACC_STATIC;
+ if (CLASS_PRIVATE (decl))
+ flags |= ACC_PRIVATE;
+ if (CLASS_PROTECTED (decl))
+ flags |= ACC_PROTECTED;
if (ANONYMOUS_CLASS_P (TREE_TYPE (decl))
|| LOCAL_CLASS_P (TREE_TYPE (decl)))
flags |= ACC_PRIVATE;