* class.c (build_static_field_ref): Check FIELD_FINAL.
* constants.c (alloc_class_constant): Use TYPE_CPOOL_DATA_REF
instead of current_constant_pool_data_ref.
* java-tree.h (current_constant_pool_data_ref): Undefine.
(JTI_CURRENT_CONSTANT_POOL_DATA_REF): Remove.
* jcf-parse.c (init_outgoing_cpool): Don't initialize
current_constant_pool_data_ref.
* except.c (prepare_eh_table_type ): Use DECL_NAME of class type,
not build_internal_class_name.
* parse.y (patch_incomplete_class_ref): Always emit `class$' method.
Use it when class ref isn't certain to be compiled.
From-SVN: r60448
+2002-12-23 Jeff Sturm <jsturm@one-point.com>
+
+ * class.c (build_static_field_ref): Check FIELD_FINAL.
+
+ * constants.c (alloc_class_constant): Use TYPE_CPOOL_DATA_REF
+ instead of current_constant_pool_data_ref.
+ * java-tree.h (current_constant_pool_data_ref): Undefine.
+ (JTI_CURRENT_CONSTANT_POOL_DATA_REF): Remove.
+ * jcf-parse.c (init_outgoing_cpool): Don't initialize
+ current_constant_pool_data_ref.
+
+ * except.c (prepare_eh_table_type ): Use DECL_NAME of class type,
+ not build_internal_class_name.
+
+ * parse.y (patch_incomplete_class_ref): Always emit `class$' method.
+ Use it when class ref isn't certain to be compiled.
+
2002-12-23 Joseph S. Myers <jsm@polyomino.org.uk>
* gcj.texi: Include gcc-common.texi.
{
tree fclass = DECL_CONTEXT (fdecl);
int is_compiled = is_compiled_class (fclass);
- if (is_compiled)
+
+ /* Allow static final fields to fold to a constant. */
+ if (is_compiled || FIELD_FINAL (fdecl))
{
if (!DECL_RTL_SET_P (fdecl))
{
static tree
build_constant_data_ref ()
{
+ tree cpool_data_ref = NULL_TREE;
+
if (TYPE_CPOOL_DATA_REF (current_class))
- current_constant_pool_data_ref = TYPE_CPOOL_DATA_REF (current_class);
+ cpool_data_ref = TYPE_CPOOL_DATA_REF (current_class);
- else if (current_constant_pool_data_ref == NULL_TREE)
+ if (cpool_data_ref == NULL_TREE)
{
tree decl;
tree decl_name = mangled_classname ("_CD_", current_class);
one_elt_array_domain_type));
TREE_STATIC (decl) = 1;
make_decl_rtl (decl, NULL);
- TYPE_CPOOL_DATA_REF (current_class) = current_constant_pool_data_ref
+ TYPE_CPOOL_DATA_REF (current_class) = cpool_data_ref
= build1 (ADDR_EXPR, ptr_type_node, decl);
}
- return current_constant_pool_data_ref;
+ return cpool_data_ref;
}
/* Get the pointer value at the INDEX'th element of the constant pool. */
else
exp = fold (build
(PLUS_EXPR, ptr_type_node,
- build_utf8_ref (build_internal_class_name (type)),
+ build_utf8_ref (DECL_NAME (TYPE_NAME (type))),
size_one_node));
return exp;
}
JTI_NATIVECODE_PTR_ARRAY_TYPE_NODE,
JTI_WFL_OPERATOR,
- JTI_CURRENT_CONSTANT_POOL_DATA_REF,
JTI_MAIN_CLASS,
JTI_CURRENT_CLASS,
/* They need to be reset before processing each class */
extern struct CPool *outgoing_cpool;
-/* If non-NULL, an ADDR_EXPR referencing a VAR_DECL containing
- the constant data array for the current class. */
-#define current_constant_pool_data_ref \
- java_global_trees[JTI_CURRENT_CONSTANT_POOL_DATA_REF]
#define wfl_operator \
java_global_trees[JTI_WFL_OPERATOR]
void
init_outgoing_cpool ()
{
- current_constant_pool_data_ref = NULL_TREE;
outgoing_cpool = xmalloc (sizeof (struct CPool));
memset (outgoing_cpool, 0, sizeof (struct CPool));
}
if (!(ref_type = resolve_type_during_patch (type)))
return error_mark_node;
- if (!flag_emit_class_files || JPRIMITIVE_TYPE_P (ref_type)
+ /* Generate the synthetic static method `class$'. (Previously we
+ deferred this, causing different method tables to be emitted
+ for native code and bytecode.) */
+ if (!TYPE_DOT_CLASS (current_class))
+ build_dot_class_method (current_class);
+
+ /* If we're not emitting class files and we know ref_type is a
+ compiled class, build a direct reference. */
+ if ((! flag_emit_class_files && is_compiled_class (ref_type))
+ || JPRIMITIVE_TYPE_P (ref_type)
|| TREE_CODE (ref_type) == VOID_TYPE)
{
tree dot = build_class_ref (ref_type);
}
/* If we're emitting class files and we have to deal with non
- primitive types, we invoke (and consider generating) the
- synthetic static method `class$'. */
- if (!TYPE_DOT_CLASS (current_class))
- build_dot_class_method (current_class);
+ primitive types, we invoke the synthetic static method `class$'. */
ref_type = build_dot_class_method_invocation (ref_type);
return java_complete_tree (ref_type);
}