#include "config.h"#include "system.h"#include <math.h>#include "jcf.h"#include "tree.h"#include "javaop.h"#include "java-tree.h"#include "java-opcodes.h"#include <getopt.h>#include "jcf-reader.c"

Go to the source code of this file.
Data Types | |
| type | method_name |
| type | include |
| type | namelet |
Defines | |
| #define | METHOD_IS_FINAL(Class, Method) (((Class) & ACC_FINAL) || ((Method) & (ACC_FINAL | ACC_PRIVATE))) |
| #define | METHOD_IS_NATIVE(Method) ((Method) & ACC_NATIVE) |
| #define | HANDLE_START_FIELD(ACCESS_FLAGS, NAME, SIGNATURE, ATTRIBUTE_COUNT) |
| #define | HANDLE_END_FIELD() |
| #define | HANDLE_CONSTANTVALUE(VALUEINDEX) current_field_value = (VALUEINDEX) |
| #define | HANDLE_METHOD(ACCESS_FLAGS, NAME, SIGNATURE, ATTRIBUTE_COUNT) |
| #define | HANDLE_CODE_ATTRIBUTE(MAX_STACK, MAX_LOCALS, CODE_LENGTH) if (out && method_declared) decompile_method (out, jcf, CODE_LENGTH); |
| #define | HANDLE_END_METHOD() |
| #define | NEED_PEEK_ATTRIBUTE |
| #define | NEED_SKIP_ATTRIBUTE |
| #define | F_NAN_MASK 0x7f800000 |
| #define | D_NAN_MASK 0x7ff0000000000000LL |
| #define | JAVALANG "java/lang/" |
| #define | JAVAIO "java/io/" |
| #define | JAVAUTIL "java/util/" |
| #define | LONG_OPT(Num) ((Num) + 128) |
| #define | OPT_classpath LONG_OPT (0) |
| #define | OPT_CLASSPATH OPT_classpath |
| #define | OPT_bootclasspath LONG_OPT (1) |
| #define | OPT_extdirs LONG_OPT (2) |
| #define | OPT_HELP LONG_OPT (3) |
| #define | OPT_TEMP LONG_OPT (4) |
| #define | OPT_VERSION LONG_OPT (5) |
| #define | OPT_PREPEND LONG_OPT (6) |
| #define | OPT_FRIEND LONG_OPT (7) |
| #define | OPT_ADD LONG_OPT (8) |
| #define | OPT_APPEND LONG_OPT (9) |
| #define | OPT_M LONG_OPT (10) |
| #define | OPT_MM LONG_OPT (11) |
| #define | OPT_MG LONG_OPT (12) |
| #define | OPT_MD LONG_OPT (13) |
| #define | OPT_MMD LONG_OPT (14) |
Functions/Subroutines | |
| static void print_field_info | PARAMS ((FILE *, JCF *, int, int, JCF_u2)) |
| static void print_mangled_classname | PARAMS ((FILE *, JCF *, const char *, int)) |
| static int print_cxx_classname | PARAMS ((FILE *, const char *, JCF *, int)) |
| static void print_c_decl | PARAMS ((FILE *, JCF *, int, int, int, const char *, int)) |
| static void decompile_method | PARAMS ((FILE *, JCF *, int)) |
| static void add_class_decl | PARAMS ((FILE *, JCF *, JCF_u2)) |
| static int java_float_finite | PARAMS ((jfloat)) |
| static int java_double_finite | PARAMS ((jdouble)) |
| static int utf8_cmp | PARAMS ((const unsigned char *, int, const char *)) |
| static char *cxx_keyword_subst | PARAMS ((const unsigned char *, int)) |
| static void generate_access | PARAMS ((FILE *, JCF_u2)) |
| static char *get_field_name | PARAMS ((JCF *, int, JCF_u2)) |
| static void print_field_name | PARAMS ((FILE *, JCF *, int, JCF_u2)) |
| static const unsigned char *super_class_name | PARAMS ((JCF *, int *)) |
| static void print_include | PARAMS ((FILE *, const unsigned char *, int)) |
| static const unsigned char *decode_signature_piece | PARAMS ((FILE *, const unsigned char *, const unsigned char *, int *)) |
| static void usage | PARAMS ((void)) |
| static int | java_double_finite (jdouble d) |
| static void | jni_print_char (FILE *stream, int ch) |
| static void | DEFUN (print_name,(stream, jcf, name_index), FILE *stream AND JCF *jcf AND int name_index) |
| static void | print_base_classname (FILE *stream, JCF *jcf, int index) |
| static int | utf8_cmp (unsigned char *str, int length, const char *name) const |
| static char * | cxx_keyword_subst (unsigned char *str, int length) const |
| static void | generate_access (FILE *stream, JCF_u2 flags) |
| static int | name_is_method_p (unsigned char *name, int length) const |
| static int | overloaded_jni_method_exists_p (unsigned char *name, int length, const char *signature, int sig_length) const |
| static char * | get_field_name (JCF *jcf, int name_index, JCF_u2 flags) |
| static void | print_field_name (FILE *stream, JCF *jcf, int name_index, JCF_u2 flags) |
| static void | DEFUN (print_field_info,(stream, jcf, name_index, sig_index, flags), FILE *stream AND JCF *jcf AND int name_index AND int sig_index AND JCF_u2 flags) |
| static void | DEFUN (print_method_info,(stream, jcf, name_index, sig_index, flags), FILE *stream AND JCF *jcf AND int name_index AND int sig_index AND JCF_u2 flags) |
| static void | decompile_return_statement (FILE *out, JCF *jcf, int methodtype, int nameindex, int objecttype) |
| static void | decompile_method (FILE *out, JCF *jcf, int code_len) |
| static const unsigned char * | decode_signature_piece (FILE *stream, const unsigned char *signature, const unsigned char *limit, int *need_space) |
| static void | DEFUN (print_c_decl,(stream, jcf, name_index, signature_index, is_init, name_override, flags), FILE *stream AND JCF *jcf AND int name_index AND int signature_index AND int is_init AND const char *name_override AND int flags) |
| static void | DEFUN (print_full_cxx_name,(stream, jcf, name_index, signature_index, is_init, name_override, flags), FILE *stream AND JCF *jcf AND int name_index AND int signature_index AND int is_init AND const char *name_override AND int flags) |
| static void | DEFUN (print_name_for_stub_or_jni,(stream, jcf, name_index, signature_index, is_init, name_override, flags), FILE *stream AND JCF *jcf AND int name_index AND int signature_index AND int is_init AND const char *name_override AND int flags) |
| static void | DEFUN (print_stub_or_jni,(stream, jcf, name_index, signature_index, is_init, name_override, flags), FILE *stream AND JCF *jcf AND int name_index AND int signature_index AND int is_init AND const char *name_override AND int flags) |
| static void | DEFUN (print_mangled_classname,(stream, jcf, prefix, index), FILE *stream AND JCF *jcf AND const char *prefix AND int index) |
| static int | print_cxx_classname (FILE *stream, const char *prefix, JCF *jcf, int index) |
| static const unsigned char * | super_class_name (JCF *derived_jcf, int *len) |
| static void | print_include (FILE *out, const unsigned char *utf8, int len) |
| static void add_namelet | PARAMS ((const unsigned char *, const unsigned char *, struct namelet *)) |
| static void print_namelet | PARAMS ((FILE *, struct namelet *, int)) |
| static void | add_namelet (unsigned char *name, unsigned char *name_limit, struct namelet *parent) const |
| static void | print_namelet (FILE *out, struct namelet *name, int depth) |
| static void | add_class_decl (FILE *out, JCF *jcf, JCF_u2 signature) |
| static void | print_class_decls (FILE *out, JCF *jcf, int self) |
| static void | DEFUN (process_file,(jcf, out), JCF *jcf AND FILE *out) |
| static void | usage () |
| static void | help () |
| static void | version () |
| int | DEFUN (main,(argc, argv), int argc AND char **argv) |
Variables | |
| FILE * | out = NULL |
| static int | found_error = 0 |
| static int | flag_jni = 0 |
| int | flag_newer = 1 |
| const char * | output_directory = "" |
| const char * | temp_directory = "/tmp" |
| static int | friend_count |
| static char ** | friend_specs = NULL |
| static int | prepend_count |
| static char ** | prepend_specs = NULL |
| static int | add_count |
| static char ** | add_specs = NULL |
| static int | append_count |
| static char ** | append_specs = NULL |
| int | verbose = 0 |
| int | stubs = 0 |
| struct JCF * | current_jcf |
| static JCF_u2 | last_access |
| static struct method_name * | method_name_list |
| static const char *const | cxx_keywords [] |
| int | written_class_count = 0 |
| static struct include * | all_includes = NULL |
| static struct namelet | root |
| static struct option | options [] |
| #define D_NAN_MASK 0x7ff0000000000000LL |
Referenced by java_double_finite().
| #define F_NAN_MASK 0x7f800000 |
Referenced by PARAMS().
| #define HANDLE_CODE_ATTRIBUTE | ( | MAX_STACK, | |||
| MAX_LOCALS, | |||||
| CODE_LENGTH | ) | if (out && method_declared) decompile_method (out, jcf, CODE_LENGTH); |
Referenced by DEFUN().
| #define HANDLE_CONSTANTVALUE | ( | VALUEINDEX | ) | current_field_value = (VALUEINDEX) |
Referenced by DEFUN().
| #define HANDLE_END_FIELD | ( | ) |
| #define HANDLE_END_METHOD | ( | ) |
| #define HANDLE_METHOD | ( | ACCESS_FLAGS, | |||
| NAME, | |||||
| SIGNATURE, | |||||
| ATTRIBUTE_COUNT | ) |
Referenced by DEFUN().
| #define HANDLE_START_FIELD | ( | ACCESS_FLAGS, | |||
| NAME, | |||||
| SIGNATURE, | |||||
| ATTRIBUTE_COUNT | ) |
| #define JAVAIO "java/io/" |
Referenced by add_namelet().
| #define JAVALANG "java/lang/" |
Referenced by add_namelet().
| #define JAVAUTIL "java/util/" |
Referenced by add_namelet().
| #define METHOD_IS_FINAL | ( | Class, | |||
| Method | ) | (((Class) & ACC_FINAL) || ((Method) & (ACC_FINAL | ACC_PRIVATE))) |
| #define METHOD_IS_NATIVE | ( | Method | ) | ((Method) & ACC_NATIVE) |
| #define NEED_PEEK_ATTRIBUTE |
| #define NEED_SKIP_ATTRIBUTE |
| #define OPT_bootclasspath LONG_OPT (1) |
| #define OPT_HELP LONG_OPT (3) |
| #define OPT_M LONG_OPT (10) |
Definition at line 2112 of file gjavah.c.
Referenced by c_common_decode_option(), and c_common_handle_option().
| #define OPT_MD LONG_OPT (13) |
Definition at line 2115 of file gjavah.c.
Referenced by c_common_decode_option(), c_common_handle_option(), c_common_missing_argument(), and missing_arg().
| #define OPT_MG LONG_OPT (12) |
Definition at line 2114 of file gjavah.c.
Referenced by c_common_decode_option(), and c_common_handle_option().
| #define OPT_MM LONG_OPT (11) |
Definition at line 2113 of file gjavah.c.
Referenced by c_common_decode_option(), and c_common_handle_option().
| #define OPT_MMD LONG_OPT (14) |
Definition at line 2116 of file gjavah.c.
Referenced by c_common_decode_option(), c_common_handle_option(), c_common_missing_argument(), and missing_arg().
| #define OPT_VERSION LONG_OPT (5) |
Definition at line 1785 of file gjavah.c.
References add_namelet(), i, JPOOL_UTF_DATA, JPOOL_UTF_LENGTH, len, print_include(), s, and start.
| static void add_namelet | ( | unsigned char * | name, | |
| unsigned char * | name_limit, | |||
| struct namelet * | parent | |||
| ) | const [static] |
Definition at line 1670 of file gjavah.c.
References namelet::is_class, JAVAIO, JAVALANG, JAVAUTIL, n, namelet::name, namelet::next, NULL, p, strlen(), strncmp(), strncpy(), namelet::subnamelets, and xmalloc().
Referenced by add_class_decl(), and print_class_decls().
| static char* cxx_keyword_subst | ( | unsigned char * | str, | |
| int | length | |||
| ) | const [static] |
Definition at line 507 of file gjavah.c.
References ARRAY_SIZE, dup(), first, i, last, NULL, r, strcpy, strlen(), utf8_cmp(), and xmalloc().
Referenced by DEFUN(), and get_field_name().
| static const unsigned char* decode_signature_piece | ( | FILE * | stream, | |
| const unsigned char * | signature, | |||
| const unsigned char * | limit, | |||
| int * | need_space | |||
| ) | [static] |
Definition at line 1023 of file gjavah.c.
References ACC_SYNCHRONIZED, codes, decompile_return_statement(), fputs(), index(), JPOOL_USHORT1, JPOOL_USHORT2, print_field_name(), JCF::read_ptr, and JCF::this_class.
| static void decompile_return_statement | ( | FILE * | out, | |
| JCF * | jcf, | |||
| int | methodtype, | |||
| int | nameindex, | |||
| int | objecttype | |||
| ) | [static] |
Definition at line 901 of file gjavah.c.
References fputs(), i, JPOOL_UTF_DATA, JPOOL_UTF_LENGTH, print_field_name(), and UTF8_GET.
Referenced by decompile_method().
| int DEFUN | ( | main | , | |
| (argc, argv) | , | |||
| int argc AND char ** | argv | |||
| ) |
Definition at line 1850 of file gjavah.c.
References ACC_INTERFACE, ACC_PUBLIC, add_count, add_specs, append_count, append_specs, flag_jni, found_error, fprintf(), fputc(), fputs(), free(), friend_count, friend_specs, generate_access(), i, JCF_SEEK, JCF_TELL, last_access, len, mode, prepend_count, prepend_specs, print_class_decls(), print_cxx_classname(), print_include(), strcmp(), strlen(), stubs, super_class_name(), uint32, and xmalloc().
| static void DEFUN | ( | print_full_cxx_name | , | |
| (stream, jcf, name_index, signature_index,is_init, name_override, flags) | , | |||
| FILE *stream AND JCF *jcf AND int name_index AND int signature_index AND int is_init AND const char *name_override AND int | flags | |||
| ) | [static] |
Definition at line 1325 of file gjavah.c.
References decode_signature_piece(), flag_jni, found_error, fprintf(), fputs(), jni_print_char(), JPOOL_UTF_DATA, JPOOL_UTF_LENGTH, overloaded_jni_method_exists_p(), print_base_classname(), method_name::signature, stream, and UTF8_GET.
| static void DEFUN | ( | print_method_info | , | |
| (stream, jcf, name_index, sig_index, flags) | , | |||
| FILE *stream AND JCF *jcf AND int name_index AND int sig_index AND JCF_u2 | flags | |||
| ) | [static] |
Definition at line 789 of file gjavah.c.
References ACC_ABSTRACT, CONSTANT_Utf8, cxx_keyword_subst(), flag_jni, found_error, fprintf(), fputs(), free(), generate_access(), JPOOL_TAG, JPOOL_UTF_DATA, JPOOL_UTF_LENGTH, method_name::length, length, memcpy, METHOD_IS_FINAL, METHOD_IS_NATIVE, method_name::name, method_name::next, NULL, out, method_name::sig_length, method_name::signature, str, stream, stubs, utf8_cmp(), and xmalloc().
| static void DEFUN | ( | print_name | , | |
| (stream, jcf, name_index) | , | |||
| FILE *stream AND JCF *jcf AND int | name_index | |||
| ) | [static] |
Definition at line 305 of file gjavah.c.
References CONSTANT_Utf8, flag_jni, found_error, fprintf(), jni_print_char(), JPOOL_TAG, JPOOL_UTF_DATA, JPOOL_UTF_LENGTH, length, str, stream, and UTF8_GET.
Definition at line 556 of file gjavah.c.
References ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_VISIBILITY, found_error, fprintf(), fputs(), and last_access.
Referenced by DEFUN().
| static char* get_field_name | ( | JCF * | jcf, | |
| int | name_index, | |||
| JCF_u2 | flags | |||
| ) | [static] |
Definition at line 626 of file gjavah.c.
References ACC_STATIC, cxx_keyword_subst(), found_error, fprintf(), JPOOL_UTF_DATA, JPOOL_UTF_LENGTH, length, memcpy, name_is_method_p(), NULL, strcpy, and xmalloc().
Referenced by print_field_name().
| static int java_double_finite | ( | jdouble | d | ) | [static] |
Definition at line 274 of file gjavah.c.
References flag_jni, fprintf(), fputc(), fputs(), and ISALNUM.
Referenced by decode_signature_piece(), DEFUN(), and print_cxx_classname().
| static int name_is_method_p | ( | unsigned char * | name, | |
| int | length | |||
| ) | const [static] |
Definition at line 588 of file gjavah.c.
References method_name::length, memcmp, method_name::name, method_name::next, NULL, and p.
Referenced by get_field_name().
| static int overloaded_jni_method_exists_p | ( | unsigned char * | name, | |
| int | length, | |||
| const char * | signature, | |||
| int | sig_length | |||
| ) | const [static] |
Definition at line 605 of file gjavah.c.
References method_name::length, memcmp, method_name::name, method_name::next, NULL, p, method_name::sig_length, and method_name::signature.
Referenced by DEFUN().
| static void add_namelet PARAMS | ( | (const unsigned char *, const unsigned char *, struct namelet *) | ) | [static] |
| static const unsigned char* decode_signature_piece PARAMS | ( | (FILE *, const unsigned char *, const unsigned char *, int *) | ) | [static] |
| static const unsigned char* super_class_name PARAMS | ( | (JCF *, int *) | ) | [static] |
| static char* get_field_name PARAMS | ( | (JCF *, int, JCF_u2) | ) | [static] |
| static char* cxx_keyword_subst PARAMS | ( | (const unsigned char *, int) | ) | [static] |
| static int utf8_cmp PARAMS | ( | (const unsigned char *, int, const char *) | ) | [static] |
| static int java_double_finite PARAMS | ( | (jdouble) | ) | [static] |
| static int java_float_finite PARAMS | ( | (jfloat) | ) | [static] |
Definition at line 339 of file gjavah.c.
References c, fputs(), JPOOL_USHORT1, JPOOL_UTF_DATA, JPOOL_UTF_LENGTH, len, p, s, and UTF8_GET.
Referenced by DEFUN().
Definition at line 1822 of file gjavah.c.
References add_namelet(), fputs(), JPOOL_USHORT1, JPOOL_UTF_DATA, JPOOL_UTF_LENGTH, len, print_namelet(), s, and namelet::subnamelets.
Referenced by DEFUN().
| static int print_cxx_classname | ( | FILE * | stream, | |
| const char * | prefix, | |||
| JCF * | jcf, | |||
| int | index | |||
| ) | [static] |
Definition at line 1530 of file gjavah.c.
References c, flag_jni, fputs(), jni_print_char(), JPOOL_USHORT1, JPOOL_UTF_DATA, JPOOL_UTF_LENGTH, len, p, s, stubs, and UTF8_GET.
Referenced by DEFUN().
Definition at line 661 of file gjavah.c.
References fputs(), free(), get_field_name(), JPOOL_UTF_DATA, and JPOOL_UTF_LENGTH.
Referenced by decompile_method(), and decompile_return_statement().
Definition at line 1603 of file gjavah.c.
References flag_jni, fputs(), include::name, include::next, strlen(), strncmp(), strncpy(), and xmalloc().
Referenced by add_class_decl(), and DEFUN().
Definition at line 1729 of file gjavah.c.
References c, fprintf(), fputc(), fputs(), free(), i, namelet::is_class, namelet::name, namelet::next, NULL, and namelet::subnamelets.
Referenced by print_class_decls().
| static const unsigned char* super_class_name | ( | JCF * | derived_jcf, | |
| int * | len | |||
| ) | [static] |
Definition at line 1573 of file gjavah.c.
References JPOOL_USHORT1, JPOOL_UTF_DATA, and JPOOL_UTF_LENGTH.
Referenced by DEFUN().
| static int utf8_cmp | ( | unsigned char * | str, | |
| int | length, | |||
| const char * | name | |||
| ) | const [static] |
Definition at line 373 of file gjavah.c.
Referenced by cxx_keyword_p(), cxx_keyword_subst(), and DEFUN().
struct include* all_includes = NULL [static] |
int append_count [static] |
char** append_specs = NULL [static] |
Definition at line 89 of file gjavah.c.
Referenced by expand_invoke(), expand_java_field_op(), init_jcf_parse(), java_init_lex(), parse_zip_file_entries(), read_class(), and verify_jvm_instructions().
const char* const cxx_keywords[] [static] |
int flag_jni = 0 [static] |
Definition at line 48 of file gjavah.c.
Referenced by build_jni_stub(), decode_signature_piece(), DEFUN(), jni_print_char(), print_cxx_classname(), and print_include().
| int flag_newer = 1 |
int found_error = 0 [static] |
Definition at line 45 of file gjavah.c.
Referenced by DEFUN(), generate_access(), get_field_name(), merge_intrinsic(), parse_array_spec(), and parse_pe_array_spec().
int friend_count [static] |
char** friend_specs = NULL [static] |
JCF_u2 last_access [static] |
struct method_name* method_name_list [static] |
Initial value:
{
{ "classpath", required_argument, NULL, OPT_classpath },
{ "bootclasspath", required_argument, NULL, OPT_bootclasspath },
{ "extdirs", required_argument, NULL, OPT_extdirs },
{ "CLASSPATH", required_argument, NULL, OPT_CLASSPATH },
{ "help", no_argument, NULL, OPT_HELP },
{ "stubs", no_argument, &stubs, 1 },
{ "td", required_argument, NULL, OPT_TEMP },
{ "verbose", no_argument, NULL, 'v' },
{ "version", no_argument, NULL, OPT_VERSION },
{ "prepend", required_argument, NULL, OPT_PREPEND },
{ "friend", required_argument, NULL, OPT_FRIEND },
{ "add", required_argument, NULL, OPT_ADD },
{ "append", required_argument, NULL, OPT_APPEND },
{ "M", no_argument, NULL, OPT_M },
{ "MM", no_argument, NULL, OPT_MM },
{ "MG", no_argument, NULL, OPT_MG },
{ "MD", no_argument, NULL, OPT_MD },
{ "MMD", no_argument, NULL, OPT_MMD },
{ "jni", no_argument, &flag_jni, 1 },
{ NULL, no_argument, NULL, 0 }
}
| const char* output_directory = "" |
int prepend_count [static] |
char** prepend_specs = NULL [static] |
| int stubs = 0 |
Definition at line 87 of file gjavah.c.
Referenced by DEFUN(), elf64_hppa_check_relocs(), Fixup_Long_Branches(), and print_cxx_classname().
| const char* temp_directory = "/tmp" |
| int written_class_count = 0 |
1.5.6