aboutsummaryrefslogtreecommitdiff
path: root/gcc/java
diff options
context:
space:
mode:
authorAndrew Haley <aph@redhat.com>2007-04-03 15:28:16 +0000
committerAndrew Haley <aph@gcc.gnu.org>2007-04-03 15:28:16 +0000
commit696fbee71016c152278c38048421cf291e1566a4 (patch)
tree60fe445d5b46b75e3d08f3d3944f489dda85b945 /gcc/java
parent83ff0d10edd6af76343e00f4cd8cdb78c1c0b640 (diff)
downloadgcc-696fbee71016c152278c38048421cf291e1566a4.zip
gcc-696fbee71016c152278c38048421cf291e1566a4.tar.gz
gcc-696fbee71016c152278c38048421cf291e1566a4.tar.bz2
jvgenmain.c (main): Change main to use class$, not class$$.
2007-04-03 Andrew Haley <aph@redhat.com> * jvgenmain.c (main): Change main to use class$, not class$$. (do_mangle_classname): Likewise. * class.c (hide): New function. (add_field): Hide everything that shouldn't be visible outside a DSO. (build_static_class_ref): Likewise. (build_classdollar_field): Likewise. (make_class_data): Likewise. (layout_class_method): Likewise. * expr.c (special_method_p): New function. * class.c (push_class): Don't bogusly guess the source filename. * jcf-parse.c (give_name_to_class): Don't set input_location from DECL_ARTIFICIAL decls. From-SVN: r123476
Diffstat (limited to 'gcc/java')
-rw-r--r--gcc/java/ChangeLog17
-rw-r--r--gcc/java/class.c31
-rw-r--r--gcc/java/expr.c19
-rw-r--r--gcc/java/java-tree.h1
-rw-r--r--gcc/java/jcf-parse.c9
-rw-r--r--gcc/java/jvgenmain.c6
6 files changed, 74 insertions, 9 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index f979728..e02257f 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,20 @@
+2007-04-03 Andrew Haley <aph@redhat.com>
+
+ * jvgenmain.c (main): Change main to use class$, not class$$.
+ (do_mangle_classname): Likewise.
+ * class.c (hide): New function.
+ (add_field): Hide everything that shouldn't be visible outside a
+ DSO.
+ (build_static_class_ref): Likewise.
+ (build_classdollar_field): Likewise.
+ (make_class_data): Likewise.
+ (layout_class_method): Likewise.
+ * expr.c (special_method_p): New function.
+
+ * class.c (push_class): Don't bogusly guess the source filename.
+ * jcf-parse.c (give_name_to_class): Don't set input_location from
+ DECL_ARTIFICIAL decls.
+
2007-03-30 Rafael Avila de Espindola <espindola@google.com>
* typeck.c (java_signed_or_unsigned_type): Removed.
diff --git a/gcc/java/class.c b/gcc/java/class.c
index c9ccef6..d707461 100644
--- a/gcc/java/class.c
+++ b/gcc/java/class.c
@@ -428,8 +428,7 @@ push_class (tree class_type, tree class_name)
tree decl, signature;
location_t saved_loc = input_location;
#ifndef USE_MAPPED_LOCATION
- tree source_name = identifier_subst (class_name, "", '.', '/', ".java");
- input_filename = IDENTIFIER_POINTER (source_name);
+ input_filename = "<unknown>";
input_line = 0;
#endif
CLASS_P (class_type) = 1;
@@ -691,6 +690,13 @@ build_java_method_type (tree fntype, tree this_class, int access_flags)
return fntype;
}
+static void
+hide (tree decl)
+{
+ DECL_VISIBILITY (decl) = VISIBILITY_HIDDEN;
+ DECL_VISIBILITY_SPECIFIED (decl) = 1;
+}
+
tree
add_method_1 (tree this_class, int access_flags, tree name, tree function_type)
{
@@ -801,6 +807,10 @@ add_field (tree class, tree name, tree field_type, int flags)
/* Always make field externally visible. This is required so
that native methods can always access the field. */
TREE_PUBLIC (field) = 1;
+ /* Hide everything that shouldn't be visible outside a DSO. */
+ if (flag_indirect_classes
+ || (FIELD_PRIVATE (field)))
+ hide (field);
/* Considered external unless we are compiling it into this
object file. */
DECL_EXTERNAL (field) = (is_compiled_class (class) != 2);
@@ -958,7 +968,11 @@ build_static_class_ref (tree type)
decl = build_decl (VAR_DECL, decl_name, class_type_node);
TREE_STATIC (decl) = 1;
if (! flag_indirect_classes)
- TREE_PUBLIC (decl) = 1;
+ {
+ TREE_PUBLIC (decl) = 1;
+ if (CLASS_PRIVATE (TYPE_NAME (type)))
+ hide (decl);
+ }
DECL_IGNORED_P (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
if (is_compiled_class (type) == 1)
@@ -997,6 +1011,7 @@ build_classdollar_field (tree type)
TREE_CONSTANT (decl) = 1;
TREE_READONLY (decl) = 1;
TREE_PUBLIC (decl) = 1;
+ hide (decl);
DECL_IGNORED_P (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl);
@@ -1684,6 +1699,10 @@ make_class_data (tree type)
TREE_PUBLIC (dtable_decl) = 1;
DECL_INITIAL (dtable_decl) = dtable;
+ /* The only dispatch table exported from a DSO is the dispatch
+ table for java.lang.Class. */
+ if (DECL_NAME (type_decl) != id_class)
+ hide (dtable_decl);
if (! flag_indirect_classes)
rest_of_decl_compilation (dtable_decl, 1, 0);
/* Maybe we're compiling Class as the first class. If so, set
@@ -2553,6 +2572,12 @@ layout_class_method (tree this_class, tree super_class,
TREE_PUBLIC (method_decl) = 1;
+ if (flag_indirect_classes
+ || (METHOD_PRIVATE (method_decl) && METHOD_STATIC (method_decl)
+ && ! METHOD_NATIVE (method_decl)
+ && ! special_method_p (method_decl)))
+ hide (method_decl);
+
/* Considered external unless it is being compiled into this object
file, or it was already flagged as external. */
if (!DECL_EXTERNAL (method_decl))
diff --git a/gcc/java/expr.c b/gcc/java/expr.c
index 46300ef..1a5ec68 100644
--- a/gcc/java/expr.c
+++ b/gcc/java/expr.c
@@ -2095,6 +2095,25 @@ static rewrite_rule rules[] =
{NULL, NULL, NULL, NULL, 0, NULL}};
+/* True if this method is special, i.e. it's a private method that
+ should be exported from a DSO. */
+
+bool
+special_method_p (tree candidate_method)
+{
+ tree context = DECL_NAME (TYPE_NAME (DECL_CONTEXT (candidate_method)));
+ tree method = DECL_NAME (candidate_method);
+ rewrite_rule *p;
+
+ for (p = rules; p->classname; p++)
+ {
+ if (get_identifier (p->classname) == context
+ && get_identifier (p->method) == method)
+ return true;
+ }
+ return false;
+}
+
/* Scan the rules list for replacements for *METHOD_P and replace the
args accordingly. If the rewrite results in an access to a private
method, update SPECIAL.*/
diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h
index c11f83e..00ac1b9 100644
--- a/gcc/java/java-tree.h
+++ b/gcc/java/java-tree.h
@@ -1174,6 +1174,7 @@ extern tree check_for_builtin (tree, tree);
extern void initialize_builtins (void);
extern tree lookup_name (tree);
+extern bool special_method_p (tree);
extern void maybe_rewrite_invocation (tree *, tree *, tree *, tree *);
extern tree build_known_method_ref (tree, tree, tree, tree, tree, tree);
extern tree build_class_init (tree, tree);
diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c
index 39abb57..9411119 100644
--- a/gcc/java/jcf-parse.c
+++ b/gcc/java/jcf-parse.c
@@ -1218,9 +1218,12 @@ give_name_to_class (JCF *jcf, int i)
main_input_filename = sfname;
}
#else
- input_location = DECL_SOURCE_LOCATION (TYPE_NAME (this_class));
- if (main_input_filename == NULL && jcf == main_jcf)
- main_input_filename = input_filename;
+ if (! DECL_ARTIFICIAL (TYPE_NAME (this_class)))
+ {
+ input_location = DECL_SOURCE_LOCATION (TYPE_NAME (this_class));
+ if (main_input_filename == NULL && jcf == main_jcf)
+ main_input_filename = input_filename;
+ }
#endif
jcf->cpool.data[i].t = this_class;
diff --git a/gcc/java/jvgenmain.c b/gcc/java/jvgenmain.c
index f4fb0ba..0bce004 100644
--- a/gcc/java/jvgenmain.c
+++ b/gcc/java/jvgenmain.c
@@ -143,8 +143,8 @@ main (int argc, char **argv)
fprintf (stream, " JvRunMainName (\"%s\", argc, argv);\n", classname);
else
{
- fprintf (stream, " extern void *%s;\n", mangled_classname);
- fprintf (stream, " JvRunMain (%s, argc, argv);\n", mangled_classname);
+ fprintf (stream, " extern char %s;\n", mangled_classname);
+ fprintf (stream, " JvRunMain (&%s, argc, argv);\n", mangled_classname);
}
fprintf (stream, "}\n");
if (stream != stdout && fclose (stream) != 0)
@@ -176,7 +176,7 @@ do_mangle_classname (const char *string)
count++;
}
append_gpp_mangled_name (&ptr [-count], count);
- obstack_grow (mangle_obstack, "7class$$E", strlen ("7class$$E"));
+ obstack_grow (mangle_obstack, "6class$E", strlen ("6class$E"));
obstack_1grow (mangle_obstack, '\0');
return obstack_finish (mangle_obstack);
}