This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Java: Fix for PR 4695
Alexandre Petit-Bianco wrote:
>>So, I think we need a way to treat them as static but not actually
>>set the ACC_STATIC for the emitted class.
>>
>
>Yes. Is there a PR covering this type of illegal access non-detection?
>
I'll submit one.
>Otherwise, you're patch is good to go, along with the mod I suggested.
>
How about this instead, in create_anonymous_class? It fixes your failing
test case and causes no regressions. It should enable us to check the
access to enclosing instance with PURE_INNER_CLASS_DECL_P. As we
discussed, it should really set another flag instead of ACC_STATIC to be
correct according to JLS2, but I'll leave that for another patch. Note
that GCJ doesn't seem to emit the ACC_STATIC bit for classes anyway, so
this isn't a problem yet.
regards
Bryce.
@@ -3924,6 +3924,7 @@
char buffer [80];
tree super = NULL_TREE, itf = NULL_TREE;
tree id, type_decl, class;
+ int flags;
/* The unqualified name of the anonymous class. It's just a number. */
sprintf (buffer, "%d", anonymous_class_counter++);
@@ -3947,8 +3948,12 @@
super = type_name;
}
- class = create_class (ACC_FINAL, id, super, itf);
+ flags = ACC_FINAL;
+ if (ctxp->explicit_constructor_p)
+ flags |= ACC_STATIC;
+
+ class = create_class (flags, id, super, itf);
/* We didn't know anything about the stuff. We register a dependence. */
if (!type_decl)
register_incomplete_type (JDEP_ANONYMOUS, type_name, class, NULL_TREE);