aboutsummaryrefslogtreecommitdiff
path: root/gcc/java/expr.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/java/expr.c')
-rw-r--r--gcc/java/expr.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/gcc/java/expr.c b/gcc/java/expr.c
index 48e67df..1174823 100644
--- a/gcc/java/expr.c
+++ b/gcc/java/expr.c
@@ -1672,7 +1672,14 @@ tree
build_class_init (tree clas, tree expr)
{
tree init;
- if (inherits_from_p (current_class, clas))
+
+ /* An optimization: if CLAS is a superclass of the class we're
+ compiling, we don't need to initialize it. However, if CLAS is
+ an interface, it won't necessarily be initialized, even if we
+ implement it. */
+ if ((! CLASS_INTERFACE (TYPE_NAME (clas))
+ && inherits_from_p (current_class, clas))
+ || current_class == clas)
return expr;
if (always_initialize_class_p)