gcc/libjava/java/lang/natClass.cc

2084 lines
55 KiB
C++
Raw Normal View History

1999-04-07 16:42:40 +02:00
// natClass.cc - Implementation of java.lang.Class native methods.
/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
Free Software Foundation
1999-04-07 16:42:40 +02:00
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
#include <config.h>
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
#include <limits.h>
1999-04-07 16:42:40 +02:00
#include <string.h>
lang.c (LANG_HOOKS_GET_CALLEE_FNDECL): New. 2003-10-22 Andrew Haley <aph@redhat.com> * lang.c (LANG_HOOKS_GET_CALLEE_FNDECL): New. (java_get_callee_fndecl): New. * jcf-parse.c (java_parse_file): Call emit_catch_table(). * java-tree.h (ctable_decl): New. (catch_classes): New. (java_tree_index): Add JTI_CTABLE_DECL, JTI_CATCH_CLASSES. * decl.c (java_init_decl_processing): Add catch_class_type. Add ctable_decl. Add catch_classes field. * class.c (build_indirect_class_ref): Break out from build_class_ref. (make_field_value): Check flag_indirect_dispatch. (make_class_data): Ditto. Tidy uses of PUSH_FIELD_VALUE. Add field catch_classes. (make_catch_class_record): New. * java-tree.h (PUSH_FIELD_VALUE): Tidy. 2003-10-22 Andrew Haley <aph@redhat.com> * java/lang/natClass.cc (initializeClass): Call _Jv_linkExceptionClassTable. (_Jv_LinkSymbolTable): Call )_Jv_ThrowNoSuchMethodError. Call _Jv_Defer_Resolution on a method whose ncode is NULL. (_Jv_linkExceptionClassTable): New function. (_Jv_LayoutVTableMethods): If superclass looks like a constant pool entry, look it up. * java/lang/Class.h (struct _Jv_CatchClass): New. (_Jv_linkExceptionClassTable): New friend. (_Jv_Defer_Resolution): New friend. (class Class.catch_classes): New field. * include/java-interp.h (Jv_Defer_Resolution): New method. (_Jv_PrepareClass): Make a friend of _Jv_MethodBase. (_Jv_MethodBase.deferred): New field. (_Jv_Defer_Resolution): New function. * resolve.cc (_Jv_PrepareClass): Resolve deferred handlers. * exception.cc (get_ttype_entry): Change return type to void**. (PERSONALITY_FUNCTION): Remove all code related to using a Utf8Const* for a match type. Change match type to be a pointer to a pointer, rather than a pointer to a Class. * defineclass.cc (handleCodeAttribute): Initialize method->deferred. (handleMethodsEnd): Likewise. From-SVN: r72886
2003-10-24 11:29:43 +02:00
#include <stddef.h>
#include <stdio.h>
1999-04-07 16:42:40 +02:00
#pragma implementation "Class.h"
#include <gcj/cni.h>
1999-04-07 16:42:40 +02:00
#include <jvm.h>
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
#include <java-threads.h>
1999-04-07 16:42:40 +02:00
#include <java/lang/Class.h>
#include <java/lang/ClassLoader.h>
#include <java/lang/String.h>
#include <java/lang/reflect/Modifier.h>
#include <java/lang/reflect/Member.h>
#include <java/lang/reflect/Method.h>
#include <java/lang/reflect/Field.h>
#include <java/lang/reflect/Proxy.h>
1999-04-07 16:42:40 +02:00
#include <java/lang/reflect/Constructor.h>
#include <java/lang/AbstractMethodError.h>
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
#include <java/lang/ArrayStoreException.h>
#include <java/lang/ClassCastException.h>
1999-04-07 16:42:40 +02:00
#include <java/lang/ClassNotFoundException.h>
java-interp.h: Don't include MethodInvocation.h. * include/java-interp.h: Don't include MethodInvocation.h. (class _Jv_InterpMethod): Don't make MethodInvocation a friend. * Makefile.in: Rebuilt. * Makefile.am (gnu/gcj/runtime/MethodInvocation.h): Removed. (ordinary_java_source_files): Don't mention MethodInvocation.java. * gnu/gcj/runtime/MethodInvocation.java: Removed. * interpret.cc (MethodInvocation::continue1): Removed. (run): Handle exceptions here. * java/lang/ClassLoader.java (defineClass1, defineClass2): Removed. * java/lang/natClassLoader.cc (defineClass0): Catch exceptions here. (defineClass2): Removed. * java/lang/reflect/Method.java (hack_trampoline, hack_call): Removed. * java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA): Catch exceptions here. (hack_call): Removed. * java/lang/Class.h (Class): Removed hackRunInitializers, hackTrampoline. * java/lang/natClass.cc (hackRunInitializers): Removed. (initializeClass): Catch exceptions here. Include ExceptionInInitializerError.h. * java/lang/Class.java (hackTrampoline, hackRunInitializers): Removed. * java/lang/Object.h (Object): Don't mention hack12_6. * java/lang/natObject.cc (_Jv_FinalizeObject): Catch exceptions here. * java/lang/Object.java (hack12_6): Removed. * java/lang/natThread.cc (run_): Renamed. Catch exceptions here. (start): Use run_, not run__. * java/lang/Thread.java (run_): Renamed from run__; old run_ removed. * jni.cc (_Jv_JNI_FindClass): Handle exceptions. (_Jv_JNI_EnsureLocalCapacity): Likewise. (_Jv_JNI_DefineClass): Likewise. (_Jv_JNI_ThrowNew): Likewise. (_Jv_JNI_AllocObject): Likewise. (_Jv_JNI_GetAnyMethodID): Likewise. (_Jv_JNI_CallAnyMethodV): Likewise. (_Jv_JNI_CallAnyMethodA): Likewise. (_Jv_JNI_CallAnyVoidMethodV): Likewise. (_Jv_JNI_CallAnyVoidMethodA): Likewise. (_Jv_JNI_GetAnyFieldID): Likewise. (_Jv_JNI_NewString): Likewise. (_Jv_JNI_NewStringUTF): Likewise. (_Jv_JNI_GetStringUTFChars): Likewise. (_Jv_JNI_NewObjectArray): Likewise. (_Jv_JNI_NewPrimitiveArray): Likewise. (_Jv_JNI_GetPrimitiveArrayRegion): Likewise. (_Jv_JNI_GetStringRegion): Likewise. (_Jv_JNI_GetStringUTFRegion): Likewise. (_Jv_JNI_SetPrimitiveArrayRegion): Likewise. (_Jv_JNI_MonitorEnter): Likewise. (_Jv_JNI_MonitorExit): Likewise. (_Jv_JNI_ToReflectedField): Likewise. (_Jv_JNI_ToReflectedMethod): Likewise. (_Jv_JNI_RegisterNatives): Likewise. (_Jv_JNI_AttachCurrentThread): Likewise. (_Jv_JNI_DestroyJavaVM): Likewise. From-SVN: r32294
2000-03-02 21:25:20 +01:00
#include <java/lang/ExceptionInInitializerError.h>
1999-04-07 16:42:40 +02:00
#include <java/lang/IllegalAccessException.h>
#include <java/lang/IllegalAccessError.h>
#include <java/lang/IllegalArgumentException.h>
1999-04-07 16:42:40 +02:00
#include <java/lang/IncompatibleClassChangeError.h>
jcf-parse.c (java_parse_file): Write otable and atable. 2003-10-01 Andrew Haley <aph@redhat.com> * jcf-parse.c (java_parse_file): Write otable and atable. * java-tree.h (atable_methods): New. (atable_decl): New. (atable_syms_decl): New. (enum java_tree_index): Add JTI_ATABLE_METHODS, JTI_ATABLE_DECL, JTI_ATABLE_SYMS_DECL. Rename JTI_METHOD_SYMBOL* to JTI_SYMBOL*. (symbol_*type): Rename method_symbol* to symbol*type. (emit_offset_symbol_table): Delete. (emit_symbol_table): New. (get_symbol_table_index): New. (atable_type): New. * expr.c (build_field_ref): Handle flag_indirect_dispatch. (build_known_method_ref): Likewise. (get_symbol_table_index): Rename from get_offset_table_index. Parameterize to allow re-use by differing types of symbol table. (build_invokevirtual): Pass table to get_offset_table_index. * decl.c (java_init_decl_processing): Push types and decls for atable and atable_syyms. * class.c (build_static_field_ref): Handle flag_indirect_dispatch. (make_class_data): Add new fields atable and atable_syms. (emit_symbol_table): Rename from emit_offset_symbol_table. Parameterize to allow re-use by different types of symbol table. (build_symbol_entry): Renamed from build_method_symbols_entry. 2003-10-01 Andrew Haley <aph@redhat.com> * java/lang/natClass.cc (initializeClass): Check for otable and atable. (_Jv_LinkOffsetTable): Check for existence of atable. Rewrite loops using for(). Search superinterfaces. Check for fields as well as methods. Initialize atable as well as otable: check for static methods as well as virtual methods. * java/lang/Class.h (struct _Jv_AddressTable): New. (atable): New. (atable_syms): New. * include/jvm.h (_Jv_equalUtf8Consts): constify. * prims.cc (_Jv_equalUtf8Consts): constify. From-SVN: r71979
2003-10-01 18:22:13 +02:00
#include <java/lang/NoSuchFieldError.h>
natClassLoader.cc (_Jv_PrepareCompiledClass): Call _Jv_PushClass. 2002-12-03 Andrew Haley <aph@redhat.com> * java/lang/natClassLoader.cc (_Jv_PrepareCompiledClass): Call _Jv_PushClass. (_Jv_InitNewClassFields): Set protectionDomain and chain = NULL. (_Jv_PopClass): New. (_Jv_PushClass): New. * java/lang/natClass.cc (forName (jstring)): Use a StackTrace to discover the ClassLoader of our caller. (_Jv_CheckArrayStore): Don't check that a class is assignment compatible with Object. * java/lang/natVMTHrowable.cc: Delete. * gnu/gcj/runtime/StackTrace.java: New, partly copied from java.lang.VMThrowable. (StackTrace(), StackTrace(int)): New constructors. (classAt, methodAt, update, methodAtAddress): New methods. (map): New field. * java/lang/VMThrowable.java: Use StackTrace instead of natVMTHrowable. * java/lang/Class.h (getClassLoaderInternal): New. (class Class): Be friendly with _Jv_PopClass and _Jv_PushClass. Be friendly with gnu::gcj::runtime::StackTrace. (Object.chain): New field. * include/java-interp.h (class _Jv_InterpMethod): Be friendly with gnu::gcj::runtime::StackTrace. * prims.cc (_Jv_NewObjectArray): Use getClassLoaderInternal() instead of getClassLoader(). * verify.cc (class _Jv_BytecodeVerifier): Likewise. java::lang::VMThrowable. * Makefile.am (core_java_source_files): Add MethodRef.java, StackTrace.java. (nat_source_files): Remove natVMThrowable.cc; add natStackTrace.cc. * Makefile.in: Rebuild. 2002-12-03 Andrew Haley <aph@redhat.com> * class.c (make_class_data): New field, "chain". * decl.c (java_init_decl_processing): Likewise. From-SVN: r59769
2002-12-03 14:50:05 +01:00
#include <java/lang/ArrayIndexOutOfBoundsException.h>
1999-04-07 16:42:40 +02:00
#include <java/lang/InstantiationException.h>
#include <java/lang/NoClassDefFoundError.h>
#include <java/lang/NoSuchFieldException.h>
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
#include <java/lang/NoSuchMethodError.h>
1999-04-07 16:42:40 +02:00
#include <java/lang/NoSuchMethodException.h>
#include <java/lang/Thread.h>
#include <java/lang/NullPointerException.h>
#include <java/lang/RuntimePermission.h>
1999-04-07 16:42:40 +02:00
#include <java/lang/System.h>
#include <java/lang/SecurityException.h>
1999-04-07 16:42:40 +02:00
#include <java/lang/SecurityManager.h>
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
#include <java/lang/StringBuffer.h>
#include <java/lang/VMClassLoader.h>
#include <gcj/method.h>
natClassLoader.cc (_Jv_PrepareCompiledClass): Call _Jv_PushClass. 2002-12-03 Andrew Haley <aph@redhat.com> * java/lang/natClassLoader.cc (_Jv_PrepareCompiledClass): Call _Jv_PushClass. (_Jv_InitNewClassFields): Set protectionDomain and chain = NULL. (_Jv_PopClass): New. (_Jv_PushClass): New. * java/lang/natClass.cc (forName (jstring)): Use a StackTrace to discover the ClassLoader of our caller. (_Jv_CheckArrayStore): Don't check that a class is assignment compatible with Object. * java/lang/natVMTHrowable.cc: Delete. * gnu/gcj/runtime/StackTrace.java: New, partly copied from java.lang.VMThrowable. (StackTrace(), StackTrace(int)): New constructors. (classAt, methodAt, update, methodAtAddress): New methods. (map): New field. * java/lang/VMThrowable.java: Use StackTrace instead of natVMTHrowable. * java/lang/Class.h (getClassLoaderInternal): New. (class Class): Be friendly with _Jv_PopClass and _Jv_PushClass. Be friendly with gnu::gcj::runtime::StackTrace. (Object.chain): New field. * include/java-interp.h (class _Jv_InterpMethod): Be friendly with gnu::gcj::runtime::StackTrace. * prims.cc (_Jv_NewObjectArray): Use getClassLoaderInternal() instead of getClassLoader(). * verify.cc (class _Jv_BytecodeVerifier): Likewise. java::lang::VMThrowable. * Makefile.am (core_java_source_files): Add MethodRef.java, StackTrace.java. (nat_source_files): Remove natVMThrowable.cc; add natStackTrace.cc. * Makefile.in: Rebuild. 2002-12-03 Andrew Haley <aph@redhat.com> * class.c (make_class_data): New field, "chain". * decl.c (java_init_decl_processing): Likewise. From-SVN: r59769
2002-12-03 14:50:05 +01:00
#include <gnu/gcj/RawData.h>
#include <java/lang/VerifyError.h>
#include <java/lang/InternalError.h>
#include <java/lang/TypeNotPresentException.h>
#include <java/lang/Byte.h>
#include <java/lang/Short.h>
#include <java/lang/Integer.h>
#include <java/lang/Float.h>
#include <java/lang/Double.h>
#include <java/lang/Long.h>
#include <java/lang/Character.h>
#include <java/lang/Boolean.h>
#include <java/lang/annotation/Annotation.h>
#include <java/util/HashMap.h>
#include <java/util/Map.h>
#include <sun/reflect/annotation/AnnotationInvocationHandler.h>
#include <java/lang/Enum.h>
1999-04-07 16:42:40 +02:00
[multiple changes] 1999-08-09 Anthony Green <green@cygnus.com> * gij.cc: New file. * include/config.h.in: Rebuilt. * acconfig.h: Add INTERPRETER. * configure: Rebuilt. * Makefile.in: Rebuilt. * Makefile.am (libffi_files): Identify the libffi object files for inclusion in libgcj. (LIBFFIINCS): Define. * interpret.cc (gnu::gcj::runtime::MethodInvocation::continue1): Dummy definition for configurations without an interpreter. * java/net/natPlainSocketImpl.cc (getOption): Disamiguate call to java::lang::Boolean constructor. * include/java-interp.h: Always include java-cpool.h. * java/lang/natClassLoader.cc (getVMClassLoader0): Always return 0 when INTERPRETER not defined. * java/lang/Class.h (finalize): Define. * gnu/gcj/util/path/DirectoryPathEntry.java (getURL): Catch IOException from File.getCanonicalPath. (getStream): Likewise. * NEWS: More news. * THANKS: More thanks. 1999-08-09 Kresten Krab Thorup <krab@gnu.org> * resolve.cc (get_ffi_type_from_signature): Generate uint16 for jchar type. (_Jv_PrepareClass): Allow non-abstract classes to have abstract subclasses. (_Jv_ResolvePoolEntry): Revert subclass check for protected fields and methods. * interpret.cc (continue1/perform_invoke): Don't sign extend uint16 return val. (continue1/lshl,lshr): Push long, not int. (continue1/ulshr): Use UINT64, not long long. * defineclass.cc (handleFieldsEnd): Handle case when all fields are static. * java/lang/natClass.cc (forName): Add call to _Jv_InitClass. * java/lang/FirstThread.java (run): Add top-level exception handler. (run0): Renamed from run. 1999-08-08 Kresten Krab Thorup <krab@gnu.org> * configure.in (--with-interpreter): Added. * include/config.h.in (INTERPRETER): Added. * java/lang/ClassLoader.java: File replaced. * java/lang/VMClassLoader.java: New file. * java/lang/natClassLoader.cc: New file. * gnu/gcj/runtime/MethodInvocation.java: New file. * gnu/gcj/util/path/SearchPath.java: New file. * gnu/gcj/util/path/PathEntry.java: New file. * gnu/gcj/util/path/DirectoryPathEntry.java: New file. * gnu/gcj/util/path/ZipPathEntry.java: New file. * gnu/gcj/util/path/URLPathEntry.java: New file. * gnu/gcj/util/path/CacheEntry.java: New file. * include/java-interp.h: New file. * include/java-cpool.h: New file. * include/java-insns.h: New file. * defineclass.cc: New file. * interpret.cc: New file. * resolve.cc: New file. * java/lang/natClass.cc (loaded_classes, _Jv_RegisterClass, _Jv_RegisterClasses, _Jv_FindClassInCache, _Jv_FindClass, _Jv_NewClass, _Jv_FindArrayClass): Moved to natClassLoader.cc. (finalize): New. (STATE_NOTHING, STATE_RESOLVED, STATE_IN_PROGRESS, STATE_DONE, STATE_ERROR): Moved to java/lang/Class.h and renamed with JV_ prefix. (initializeClass): Use new JV_ prefixed names. Also, call ClassLoader::resolveClass instead of _Jv_ResolveClass. * java/lang/Class.h (JV_STATE_PRELOADING, JV_STATE_LOADING, JV_STATE_LOADED, JV_STATE_COMPILED, JV_STATE_PREPARED, JV_STATE_LINKED): New. (_Jv_WaitForState, _Jv_RegisterInitiatingLoader, _Jv_UnregisterClass, _Jv_InternClassStrings): New friends. (_Jv_IsInterpretedClass, _Jv_InitField, _Jv_LookupDeclaredMethod, _Jv_DetermineVTableIndex, _Jv_ResolvePoolEntry, _Jv_PrepareClass, _Jv_ClassReader, _Jv_InterpClass, _Jv_InterpMethod, _Jv_InterpMethodInvocation): New friends for interpreter. (finalize): New. (CONSTANT_Class, CONSTANT_String, etc.): Moved to include/java-cpool.h and renamed with JV_ prefix. * include/jvm.h (_Jv_makeUtf8Const, _Jv_makeUtf8TypeConst): New decls. (_Jv_UnregisterClass): New decl. * java/lang/natClassLoader.cc (_Jv_FindArrayClass): Added class loader argument. (_Jv_FindClass): Use class loader. * prims.cc (_Jv_makeUtf8Const): New function. (_Jv_NewObjectArray): Change use of _Jv_FindArrayClass. (_Jv_NewPrimArray): Ditto. (_Jv_FindClassFromSignature): Ditto. * java/lang/reflect/natArray.cc (newInstance): Ditto. * java/lang/reflect/natMethod.cc (getType): Ditto. * include/java-field.h (_Jv_Field::isRef): Make robust for non-resolved contexts. * boehm.cc (_Jv_MarkObj): Mark interpreter-related fields. Also, don't mark class->next field. * java/lang/VirtualMachineError.java: Added FIXME note. * configure.in (INTERPSPEC): New spec. * libgcj.spec.in: Added INTERPSPEC. * Makefile.am: Added gcjh friends for java/lang/VMClassLoader and gnu/gcj/runtime/MethodInvocation. (libgcj_la_SOURCES): Added resolve.cc defineclass.cc interpret.cc. (ordinary_java_source_files): Added above mentioned java classes. * configure: Rebuilt. * Makefile.in: Rebuilt. From-SVN: r28597
1999-08-08 16:06:23 +02:00
#include <java-cpool.h>
lang.c (LANG_HOOKS_GET_CALLEE_FNDECL): New. 2003-10-22 Andrew Haley <aph@redhat.com> * lang.c (LANG_HOOKS_GET_CALLEE_FNDECL): New. (java_get_callee_fndecl): New. * jcf-parse.c (java_parse_file): Call emit_catch_table(). * java-tree.h (ctable_decl): New. (catch_classes): New. (java_tree_index): Add JTI_CTABLE_DECL, JTI_CATCH_CLASSES. * decl.c (java_init_decl_processing): Add catch_class_type. Add ctable_decl. Add catch_classes field. * class.c (build_indirect_class_ref): Break out from build_class_ref. (make_field_value): Check flag_indirect_dispatch. (make_class_data): Ditto. Tidy uses of PUSH_FIELD_VALUE. Add field catch_classes. (make_catch_class_record): New. * java-tree.h (PUSH_FIELD_VALUE): Tidy. 2003-10-22 Andrew Haley <aph@redhat.com> * java/lang/natClass.cc (initializeClass): Call _Jv_linkExceptionClassTable. (_Jv_LinkSymbolTable): Call )_Jv_ThrowNoSuchMethodError. Call _Jv_Defer_Resolution on a method whose ncode is NULL. (_Jv_linkExceptionClassTable): New function. (_Jv_LayoutVTableMethods): If superclass looks like a constant pool entry, look it up. * java/lang/Class.h (struct _Jv_CatchClass): New. (_Jv_linkExceptionClassTable): New friend. (_Jv_Defer_Resolution): New friend. (class Class.catch_classes): New field. * include/java-interp.h (Jv_Defer_Resolution): New method. (_Jv_PrepareClass): Make a friend of _Jv_MethodBase. (_Jv_MethodBase.deferred): New field. (_Jv_Defer_Resolution): New function. * resolve.cc (_Jv_PrepareClass): Resolve deferred handlers. * exception.cc (get_ttype_entry): Change return type to void**. (PERSONALITY_FUNCTION): Remove all code related to using a Utf8Const* for a match type. Change match type to be a pointer to a pointer, rather than a pointer to a Class. * defineclass.cc (handleCodeAttribute): Initialize method->deferred. (handleMethodsEnd): Likewise. From-SVN: r72886
2003-10-24 11:29:43 +02:00
#include <java-interp.h>
#include <java-assert.h>
New Stack Trace infrastructure. 2005-03-10 Bryce McKinlay <mckinlay@redhat.com> New Stack Trace infrastructure. * Makefile.am (libgcj0_convenience_la_SOURCES): Add stacktrace.cc. (gnu/gcj/runtime/StackTrace.lo): Removed. (ordinary_java_source_files): Remove obsolete files. (nat_source_files): Remove obsolete files. Add natVMThrowable.cc. * configure.host (fallback_backtrace_h): Set backtrace header for mingw and cygwin targets. * configure.ac: Make symlink for fallback backtrace headers. * Makefile.in, configure: Rebuilt. * defineclass.cc (_Jv_ClassReader::read_one_code_attribute): Read 'LineNumberTable' attribute. (_Jv_ClassReader::read_one_class_attribute): Read 'SourceFile' attribute. (_Jv_ClassReader::handleCodeAttribute): Initialize method line table fields. * exception.cc: Remove unused include. * interpret.cc (DIRECT_THREADED, insn_slot): Moved to java-interp.h. (SAVE_PC): New macro. Save current PC in the interpreter frame. (NULLCHECK, NULLARRAYCHECK): Use SAVE_PC. (_Jv_InterpMethod::compile): Translate bytecode PC values in the line table to direct threaded instruction values. (_Jv_StartOfInterpreter, _Jv_EndOfInterpreter): Removed. (_Jv_InterpMethod::run): No longer member function. All callers updated. Remove _Unwind calls. Call SAVE_PC whenever a call is made or where an instruction could throw. (_Jv_InterpMethod::get_source_line): New. Look up source line numbers in line_table. * prims.cc (catch_segv): Construct exception after MAKE_THROW_FRAME. (catch_fpe): Likewise. * stacktrace.cc: New file. Stack trace code now here. * gnu/gcj/runtime/MethodRef.java: * gnu/gcj/runtime/NameFinder.java: Mostly reimplemented. Now simply calls addr2line to look up PC addresses in a given binary or shared library. * gnu/gcj/runtime/StackTrace.java, gnu/gcj/runtime/natNameFinder.cc, gnu/gcj/runtime/natStackTrace.cc: Removed. * gnu/java/lang/MainThread.java (call_main): Add comment warning that this function name is specially recognised by the stack trace code and shouldn't be changed. * include/java-interp.h (DIRECT_THREADED, insn_slot): Moved here. (struct _Jv_LineTableEntry, line_table, line_table_len): New. (_Jv_InterpMethod::run): Update declaration. (_Jv_StackTrace_): New friend. NameFinder and StackTrace no longer friends. (_Jv_InterpFrame): Renamed from _Jv_MethodChain. Add PC field. * include/java-stack.h: New file. Declarations for stack tracing. * include/jvm.h (_Jv_Frame_info): Removed. * java/lang/Class.h: Update friend declarations. * java/lang/VMClassLoader.java (getSystemClassLoader): Simplify exception message. * java/lang/VMThrowable.java (fillInStackTrace): Now native. (getStackTrace): Now native. (data): New RawDataManaged field. * java/lang/natClass.cc: Update includes. (forName): Use _Jv_StackTrace::GetCallingClass for calling-classloader check. (getClassLoader): Likewise. * java/lang/natRuntime.cc: Update includes. (_load): Use _Jv_StackTrace::GetFirstNonSystemClassLoader. * java/lang/natVMSecurityManager.cc: Update includes. (getClassContext): Use _Jv_StackTrace::GetClassContext. * java/lang/natVMThrowable.cc: New file. Native methods for VMThrowable. * java/lang/reflect/natArray.cc: Update includes. (newInstance): Use _Jv_StackTrace::GetCallingClass to implement accessibility check. * java/lang/reflect/natConstructor.cc: Update includes. (newInstance): Use _Jv_StackTrace::GetCallingClass to implement accessibility check. * java/lang/reflect/natField.cc: Update includes. (getAddr): Use _Jv_StackTrace::GetCallingClass to implement accessibility check. * java/lang/reflect/natMethod.cc: Update includes. (invoke): Use _Jv_StackTrace::GetCallingClass to implement accessibility check. * java/util/natResourceBundle.cc: Update includes. (getCallingClassLoader): Use _Jv_StackTrace::GetCallingClass. * java/util/logging/natLogger.cc: Update includes. Use _Jv_StackTrace::GetCallerInfo to get call-site info. * sysdep/generic/backtrace.h: Fallback backtrace code. Stub implementation. * sysdep/i386/backtrace.h: New. Fallback backtrace code. i386 implementation. From-SVN: r96253
2005-03-10 20:02:21 +01:00
#include <java-stack.h>
#include <execution.h>
1999-04-07 16:42:40 +02:00
using namespace gcj;
1999-04-07 16:42:40 +02:00
jclass
decl.c (init_decl_processing): Add new class "protectionDomain" field. gcc/java: 2001-04-25 Bryce McKinlay <bryce@waitaki.otago.ac.nz> * decl.c (init_decl_processing): Add new class "protectionDomain" field. * class.c (make_class_data): Set initial value for "protectionDomain". libjava: 2001-04-25 Bryce McKinlay <bryce@albatross.co.nz> java.security merge and ClassLoader compliance fixes. * java/lang/Class.h (Class): Include ProtectionDomain.h. New protectionDomain field. (forName): Add initialize parameter. Fixes declaration to comply with JDK spec. * java/lang/natClass.cc (forName): Correct declaration of the three-arg variant. Honour "initialize" flag. (getProtectionDomain0): New method. * java/lang/Class.java: Fix forName() declaration. (getPackage): New method based on Classpath implementation. (getProtectionDomain0): New native method decl. (getProtectionDomain): New method. * java/lang/ClassLoader.java (getParent): Now final. (definedPackages): New field. (getPackage): New. (defineClass): New variant with protectionDomain argument. (definePackage): New. (getPackages): New. (findSystemClass): Now final. (getSystemResourceAsStream): Remove redundant "final" modifier. (getSystemResource): Remove redundant "final" modifier. (getResources): Now final. (protectionDomainPermission): New static field. (unknownProtectionDomain): Ditto. (defaultProtectionDomain): Ditto. (getSystemClassLoader): Now non-native. * java/util/ResourceBundle.java (tryGetSomeBundle): Use the correct arguments for Class.forName(). * java/lang/Package.java: New file. * gnu/gcj/runtime/VMClassLoader.java (getVMClassLoader): Removed. (instance): Static initialize singleton. (findClass): Override this, not findSystemClass. * java/lang/natClassLoader.cc (defineClass0): Set class's protectionDomain field as specified. (getSystemClassLoader): Removed. (findClass): Renamed from findSystemClass. Call the interpreter via URLClassLoader.findClass if loading class via dlopen fails. * java/security/*.java: java.security import/merge with Classpath. * java/security/acl/*.java: Likewise. * java/security/interfaces/*.java: Likewise. * java/security/spec/*.java: Likewise. * java/net/NetPermission.java: Likewise. * java/net/SocketPermission.java: Likewise. * gnu/java/security/provider/DefaultPolicy.java: Likewise. * Makefile.am: Add new classes. * Makefile.in: Rebuilt. * gcj/javaprims.h: CNI namespace rebuild. From-SVN: r41543
2001-04-25 17:45:15 +02:00
java::lang::Class::forName (jstring className, jboolean initialize,
java::lang::ClassLoader *loader)
1999-04-07 16:42:40 +02:00
{
if (! className)
throw new java::lang::NullPointerException;
1999-04-07 16:42:40 +02:00
jsize length = _Jv_GetStringUTFLength (className);
char buffer[length];
_Jv_GetStringUTFRegion (className, 0, className->length(), buffer);
1999-04-07 16:42:40 +02:00
_Jv_Utf8Const *name = _Jv_makeUtf8Const (buffer, length);
if (! _Jv_VerifyClassName (name))
throw new java::lang::ClassNotFoundException (className);
1999-04-07 16:42:40 +02:00
jclass klass = (buffer[0] == '['
? _Jv_FindClassFromSignature (name->chars(), loader)
: _Jv_FindClass (name, loader));
decl.c (init_decl_processing): Add new class "protectionDomain" field. gcc/java: 2001-04-25 Bryce McKinlay <bryce@waitaki.otago.ac.nz> * decl.c (init_decl_processing): Add new class "protectionDomain" field. * class.c (make_class_data): Set initial value for "protectionDomain". libjava: 2001-04-25 Bryce McKinlay <bryce@albatross.co.nz> java.security merge and ClassLoader compliance fixes. * java/lang/Class.h (Class): Include ProtectionDomain.h. New protectionDomain field. (forName): Add initialize parameter. Fixes declaration to comply with JDK spec. * java/lang/natClass.cc (forName): Correct declaration of the three-arg variant. Honour "initialize" flag. (getProtectionDomain0): New method. * java/lang/Class.java: Fix forName() declaration. (getPackage): New method based on Classpath implementation. (getProtectionDomain0): New native method decl. (getProtectionDomain): New method. * java/lang/ClassLoader.java (getParent): Now final. (definedPackages): New field. (getPackage): New. (defineClass): New variant with protectionDomain argument. (definePackage): New. (getPackages): New. (findSystemClass): Now final. (getSystemResourceAsStream): Remove redundant "final" modifier. (getSystemResource): Remove redundant "final" modifier. (getResources): Now final. (protectionDomainPermission): New static field. (unknownProtectionDomain): Ditto. (defaultProtectionDomain): Ditto. (getSystemClassLoader): Now non-native. * java/util/ResourceBundle.java (tryGetSomeBundle): Use the correct arguments for Class.forName(). * java/lang/Package.java: New file. * gnu/gcj/runtime/VMClassLoader.java (getVMClassLoader): Removed. (instance): Static initialize singleton. (findClass): Override this, not findSystemClass. * java/lang/natClassLoader.cc (defineClass0): Set class's protectionDomain field as specified. (getSystemClassLoader): Removed. (findClass): Renamed from findSystemClass. Call the interpreter via URLClassLoader.findClass if loading class via dlopen fails. * java/security/*.java: java.security import/merge with Classpath. * java/security/acl/*.java: Likewise. * java/security/interfaces/*.java: Likewise. * java/security/spec/*.java: Likewise. * java/net/NetPermission.java: Likewise. * java/net/SocketPermission.java: Likewise. * gnu/java/security/provider/DefaultPolicy.java: Likewise. * Makefile.am: Add new classes. * Makefile.in: Rebuilt. * gcj/javaprims.h: CNI namespace rebuild. From-SVN: r41543
2001-04-25 17:45:15 +02:00
if (klass == NULL)
throw new java::lang::ClassNotFoundException (className);
[multiple changes] 1999-08-09 Anthony Green <green@cygnus.com> * gij.cc: New file. * include/config.h.in: Rebuilt. * acconfig.h: Add INTERPRETER. * configure: Rebuilt. * Makefile.in: Rebuilt. * Makefile.am (libffi_files): Identify the libffi object files for inclusion in libgcj. (LIBFFIINCS): Define. * interpret.cc (gnu::gcj::runtime::MethodInvocation::continue1): Dummy definition for configurations without an interpreter. * java/net/natPlainSocketImpl.cc (getOption): Disamiguate call to java::lang::Boolean constructor. * include/java-interp.h: Always include java-cpool.h. * java/lang/natClassLoader.cc (getVMClassLoader0): Always return 0 when INTERPRETER not defined. * java/lang/Class.h (finalize): Define. * gnu/gcj/util/path/DirectoryPathEntry.java (getURL): Catch IOException from File.getCanonicalPath. (getStream): Likewise. * NEWS: More news. * THANKS: More thanks. 1999-08-09 Kresten Krab Thorup <krab@gnu.org> * resolve.cc (get_ffi_type_from_signature): Generate uint16 for jchar type. (_Jv_PrepareClass): Allow non-abstract classes to have abstract subclasses. (_Jv_ResolvePoolEntry): Revert subclass check for protected fields and methods. * interpret.cc (continue1/perform_invoke): Don't sign extend uint16 return val. (continue1/lshl,lshr): Push long, not int. (continue1/ulshr): Use UINT64, not long long. * defineclass.cc (handleFieldsEnd): Handle case when all fields are static. * java/lang/natClass.cc (forName): Add call to _Jv_InitClass. * java/lang/FirstThread.java (run): Add top-level exception handler. (run0): Renamed from run. 1999-08-08 Kresten Krab Thorup <krab@gnu.org> * configure.in (--with-interpreter): Added. * include/config.h.in (INTERPRETER): Added. * java/lang/ClassLoader.java: File replaced. * java/lang/VMClassLoader.java: New file. * java/lang/natClassLoader.cc: New file. * gnu/gcj/runtime/MethodInvocation.java: New file. * gnu/gcj/util/path/SearchPath.java: New file. * gnu/gcj/util/path/PathEntry.java: New file. * gnu/gcj/util/path/DirectoryPathEntry.java: New file. * gnu/gcj/util/path/ZipPathEntry.java: New file. * gnu/gcj/util/path/URLPathEntry.java: New file. * gnu/gcj/util/path/CacheEntry.java: New file. * include/java-interp.h: New file. * include/java-cpool.h: New file. * include/java-insns.h: New file. * defineclass.cc: New file. * interpret.cc: New file. * resolve.cc: New file. * java/lang/natClass.cc (loaded_classes, _Jv_RegisterClass, _Jv_RegisterClasses, _Jv_FindClassInCache, _Jv_FindClass, _Jv_NewClass, _Jv_FindArrayClass): Moved to natClassLoader.cc. (finalize): New. (STATE_NOTHING, STATE_RESOLVED, STATE_IN_PROGRESS, STATE_DONE, STATE_ERROR): Moved to java/lang/Class.h and renamed with JV_ prefix. (initializeClass): Use new JV_ prefixed names. Also, call ClassLoader::resolveClass instead of _Jv_ResolveClass. * java/lang/Class.h (JV_STATE_PRELOADING, JV_STATE_LOADING, JV_STATE_LOADED, JV_STATE_COMPILED, JV_STATE_PREPARED, JV_STATE_LINKED): New. (_Jv_WaitForState, _Jv_RegisterInitiatingLoader, _Jv_UnregisterClass, _Jv_InternClassStrings): New friends. (_Jv_IsInterpretedClass, _Jv_InitField, _Jv_LookupDeclaredMethod, _Jv_DetermineVTableIndex, _Jv_ResolvePoolEntry, _Jv_PrepareClass, _Jv_ClassReader, _Jv_InterpClass, _Jv_InterpMethod, _Jv_InterpMethodInvocation): New friends for interpreter. (finalize): New. (CONSTANT_Class, CONSTANT_String, etc.): Moved to include/java-cpool.h and renamed with JV_ prefix. * include/jvm.h (_Jv_makeUtf8Const, _Jv_makeUtf8TypeConst): New decls. (_Jv_UnregisterClass): New decl. * java/lang/natClassLoader.cc (_Jv_FindArrayClass): Added class loader argument. (_Jv_FindClass): Use class loader. * prims.cc (_Jv_makeUtf8Const): New function. (_Jv_NewObjectArray): Change use of _Jv_FindArrayClass. (_Jv_NewPrimArray): Ditto. (_Jv_FindClassFromSignature): Ditto. * java/lang/reflect/natArray.cc (newInstance): Ditto. * java/lang/reflect/natMethod.cc (getType): Ditto. * include/java-field.h (_Jv_Field::isRef): Make robust for non-resolved contexts. * boehm.cc (_Jv_MarkObj): Mark interpreter-related fields. Also, don't mark class->next field. * java/lang/VirtualMachineError.java: Added FIXME note. * configure.in (INTERPSPEC): New spec. * libgcj.spec.in: Added INTERPSPEC. * Makefile.am: Added gcjh friends for java/lang/VMClassLoader and gnu/gcj/runtime/MethodInvocation. (libgcj_la_SOURCES): Added resolve.cc defineclass.cc interpret.cc. (ordinary_java_source_files): Added above mentioned java classes. * configure: Rebuilt. * Makefile.in: Rebuilt. From-SVN: r28597
1999-08-08 16:06:23 +02:00
decl.c (init_decl_processing): Add new class "protectionDomain" field. gcc/java: 2001-04-25 Bryce McKinlay <bryce@waitaki.otago.ac.nz> * decl.c (init_decl_processing): Add new class "protectionDomain" field. * class.c (make_class_data): Set initial value for "protectionDomain". libjava: 2001-04-25 Bryce McKinlay <bryce@albatross.co.nz> java.security merge and ClassLoader compliance fixes. * java/lang/Class.h (Class): Include ProtectionDomain.h. New protectionDomain field. (forName): Add initialize parameter. Fixes declaration to comply with JDK spec. * java/lang/natClass.cc (forName): Correct declaration of the three-arg variant. Honour "initialize" flag. (getProtectionDomain0): New method. * java/lang/Class.java: Fix forName() declaration. (getPackage): New method based on Classpath implementation. (getProtectionDomain0): New native method decl. (getProtectionDomain): New method. * java/lang/ClassLoader.java (getParent): Now final. (definedPackages): New field. (getPackage): New. (defineClass): New variant with protectionDomain argument. (definePackage): New. (getPackages): New. (findSystemClass): Now final. (getSystemResourceAsStream): Remove redundant "final" modifier. (getSystemResource): Remove redundant "final" modifier. (getResources): Now final. (protectionDomainPermission): New static field. (unknownProtectionDomain): Ditto. (defaultProtectionDomain): Ditto. (getSystemClassLoader): Now non-native. * java/util/ResourceBundle.java (tryGetSomeBundle): Use the correct arguments for Class.forName(). * java/lang/Package.java: New file. * gnu/gcj/runtime/VMClassLoader.java (getVMClassLoader): Removed. (instance): Static initialize singleton. (findClass): Override this, not findSystemClass. * java/lang/natClassLoader.cc (defineClass0): Set class's protectionDomain field as specified. (getSystemClassLoader): Removed. (findClass): Renamed from findSystemClass. Call the interpreter via URLClassLoader.findClass if loading class via dlopen fails. * java/security/*.java: java.security import/merge with Classpath. * java/security/acl/*.java: Likewise. * java/security/interfaces/*.java: Likewise. * java/security/spec/*.java: Likewise. * java/net/NetPermission.java: Likewise. * java/net/SocketPermission.java: Likewise. * gnu/java/security/provider/DefaultPolicy.java: Likewise. * Makefile.am: Add new classes. * Makefile.in: Rebuilt. * gcj/javaprims.h: CNI namespace rebuild. From-SVN: r41543
2001-04-25 17:45:15 +02:00
if (initialize)
_Jv_InitClass (klass);
1999-04-07 16:42:40 +02:00
return klass;
}
jclass
java::lang::Class::forName (jstring className)
{
natClassLoader.cc (_Jv_PrepareCompiledClass): Call _Jv_PushClass. 2002-12-03 Andrew Haley <aph@redhat.com> * java/lang/natClassLoader.cc (_Jv_PrepareCompiledClass): Call _Jv_PushClass. (_Jv_InitNewClassFields): Set protectionDomain and chain = NULL. (_Jv_PopClass): New. (_Jv_PushClass): New. * java/lang/natClass.cc (forName (jstring)): Use a StackTrace to discover the ClassLoader of our caller. (_Jv_CheckArrayStore): Don't check that a class is assignment compatible with Object. * java/lang/natVMTHrowable.cc: Delete. * gnu/gcj/runtime/StackTrace.java: New, partly copied from java.lang.VMThrowable. (StackTrace(), StackTrace(int)): New constructors. (classAt, methodAt, update, methodAtAddress): New methods. (map): New field. * java/lang/VMThrowable.java: Use StackTrace instead of natVMTHrowable. * java/lang/Class.h (getClassLoaderInternal): New. (class Class): Be friendly with _Jv_PopClass and _Jv_PushClass. Be friendly with gnu::gcj::runtime::StackTrace. (Object.chain): New field. * include/java-interp.h (class _Jv_InterpMethod): Be friendly with gnu::gcj::runtime::StackTrace. * prims.cc (_Jv_NewObjectArray): Use getClassLoaderInternal() instead of getClassLoader(). * verify.cc (class _Jv_BytecodeVerifier): Likewise. java::lang::VMThrowable. * Makefile.am (core_java_source_files): Add MethodRef.java, StackTrace.java. (nat_source_files): Remove natVMThrowable.cc; add natStackTrace.cc. * Makefile.in: Rebuild. 2002-12-03 Andrew Haley <aph@redhat.com> * class.c (make_class_data): New field, "chain". * decl.c (java_init_decl_processing): Likewise. From-SVN: r59769
2002-12-03 14:50:05 +01:00
java::lang::ClassLoader *loader = NULL;
New Stack Trace infrastructure. 2005-03-10 Bryce McKinlay <mckinlay@redhat.com> New Stack Trace infrastructure. * Makefile.am (libgcj0_convenience_la_SOURCES): Add stacktrace.cc. (gnu/gcj/runtime/StackTrace.lo): Removed. (ordinary_java_source_files): Remove obsolete files. (nat_source_files): Remove obsolete files. Add natVMThrowable.cc. * configure.host (fallback_backtrace_h): Set backtrace header for mingw and cygwin targets. * configure.ac: Make symlink for fallback backtrace headers. * Makefile.in, configure: Rebuilt. * defineclass.cc (_Jv_ClassReader::read_one_code_attribute): Read 'LineNumberTable' attribute. (_Jv_ClassReader::read_one_class_attribute): Read 'SourceFile' attribute. (_Jv_ClassReader::handleCodeAttribute): Initialize method line table fields. * exception.cc: Remove unused include. * interpret.cc (DIRECT_THREADED, insn_slot): Moved to java-interp.h. (SAVE_PC): New macro. Save current PC in the interpreter frame. (NULLCHECK, NULLARRAYCHECK): Use SAVE_PC. (_Jv_InterpMethod::compile): Translate bytecode PC values in the line table to direct threaded instruction values. (_Jv_StartOfInterpreter, _Jv_EndOfInterpreter): Removed. (_Jv_InterpMethod::run): No longer member function. All callers updated. Remove _Unwind calls. Call SAVE_PC whenever a call is made or where an instruction could throw. (_Jv_InterpMethod::get_source_line): New. Look up source line numbers in line_table. * prims.cc (catch_segv): Construct exception after MAKE_THROW_FRAME. (catch_fpe): Likewise. * stacktrace.cc: New file. Stack trace code now here. * gnu/gcj/runtime/MethodRef.java: * gnu/gcj/runtime/NameFinder.java: Mostly reimplemented. Now simply calls addr2line to look up PC addresses in a given binary or shared library. * gnu/gcj/runtime/StackTrace.java, gnu/gcj/runtime/natNameFinder.cc, gnu/gcj/runtime/natStackTrace.cc: Removed. * gnu/java/lang/MainThread.java (call_main): Add comment warning that this function name is specially recognised by the stack trace code and shouldn't be changed. * include/java-interp.h (DIRECT_THREADED, insn_slot): Moved here. (struct _Jv_LineTableEntry, line_table, line_table_len): New. (_Jv_InterpMethod::run): Update declaration. (_Jv_StackTrace_): New friend. NameFinder and StackTrace no longer friends. (_Jv_InterpFrame): Renamed from _Jv_MethodChain. Add PC field. * include/java-stack.h: New file. Declarations for stack tracing. * include/jvm.h (_Jv_Frame_info): Removed. * java/lang/Class.h: Update friend declarations. * java/lang/VMClassLoader.java (getSystemClassLoader): Simplify exception message. * java/lang/VMThrowable.java (fillInStackTrace): Now native. (getStackTrace): Now native. (data): New RawDataManaged field. * java/lang/natClass.cc: Update includes. (forName): Use _Jv_StackTrace::GetCallingClass for calling-classloader check. (getClassLoader): Likewise. * java/lang/natRuntime.cc: Update includes. (_load): Use _Jv_StackTrace::GetFirstNonSystemClassLoader. * java/lang/natVMSecurityManager.cc: Update includes. (getClassContext): Use _Jv_StackTrace::GetClassContext. * java/lang/natVMThrowable.cc: New file. Native methods for VMThrowable. * java/lang/reflect/natArray.cc: Update includes. (newInstance): Use _Jv_StackTrace::GetCallingClass to implement accessibility check. * java/lang/reflect/natConstructor.cc: Update includes. (newInstance): Use _Jv_StackTrace::GetCallingClass to implement accessibility check. * java/lang/reflect/natField.cc: Update includes. (getAddr): Use _Jv_StackTrace::GetCallingClass to implement accessibility check. * java/lang/reflect/natMethod.cc: Update includes. (invoke): Use _Jv_StackTrace::GetCallingClass to implement accessibility check. * java/util/natResourceBundle.cc: Update includes. (getCallingClassLoader): Use _Jv_StackTrace::GetCallingClass. * java/util/logging/natLogger.cc: Update includes. Use _Jv_StackTrace::GetCallerInfo to get call-site info. * sysdep/generic/backtrace.h: Fallback backtrace code. Stub implementation. * sysdep/i386/backtrace.h: New. Fallback backtrace code. i386 implementation. From-SVN: r96253
2005-03-10 20:02:21 +01:00
jclass caller = _Jv_StackTrace::GetCallingClass (&Class::class$);
if (caller)
loader = caller->getClassLoaderInternal();
natClassLoader.cc (_Jv_PrepareCompiledClass): Call _Jv_PushClass. 2002-12-03 Andrew Haley <aph@redhat.com> * java/lang/natClassLoader.cc (_Jv_PrepareCompiledClass): Call _Jv_PushClass. (_Jv_InitNewClassFields): Set protectionDomain and chain = NULL. (_Jv_PopClass): New. (_Jv_PushClass): New. * java/lang/natClass.cc (forName (jstring)): Use a StackTrace to discover the ClassLoader of our caller. (_Jv_CheckArrayStore): Don't check that a class is assignment compatible with Object. * java/lang/natVMTHrowable.cc: Delete. * gnu/gcj/runtime/StackTrace.java: New, partly copied from java.lang.VMThrowable. (StackTrace(), StackTrace(int)): New constructors. (classAt, methodAt, update, methodAtAddress): New methods. (map): New field. * java/lang/VMThrowable.java: Use StackTrace instead of natVMTHrowable. * java/lang/Class.h (getClassLoaderInternal): New. (class Class): Be friendly with _Jv_PopClass and _Jv_PushClass. Be friendly with gnu::gcj::runtime::StackTrace. (Object.chain): New field. * include/java-interp.h (class _Jv_InterpMethod): Be friendly with gnu::gcj::runtime::StackTrace. * prims.cc (_Jv_NewObjectArray): Use getClassLoaderInternal() instead of getClassLoader(). * verify.cc (class _Jv_BytecodeVerifier): Likewise. java::lang::VMThrowable. * Makefile.am (core_java_source_files): Add MethodRef.java, StackTrace.java. (nat_source_files): Remove natVMThrowable.cc; add natStackTrace.cc. * Makefile.in: Rebuild. 2002-12-03 Andrew Haley <aph@redhat.com> * class.c (make_class_data): New field, "chain". * decl.c (java_init_decl_processing): Likewise. From-SVN: r59769
2002-12-03 14:50:05 +01:00
return forName (className, true, loader);
}
java::lang::ClassLoader *
java::lang::Class::getClassLoader (void)
{
java::lang::SecurityManager *s = java::lang::System::getSecurityManager();
if (s != NULL)
Runtime.java: Comment fix. * java/lang/Runtime.java: Comment fix. * java/lang/ClassLoader.java (isAncestorOf): New method. (getParent): Uncommented security check. Use isAncestorOf. * include/jvm.h (_Jv_CheckAccess): Declare. * java/lang/reflect/natConstructor.cc (newInstance): Perform access check. Include IllegalAccessException.h, ArrayIndexOutOfBoundsException.h. * java/lang/reflect/natArray.cc (newInstance): Pass caller's class loader to _Jv_GetArrayClass. Include ArrayIndexOutOfBoundsException.h. * java/lang/reflect/Field.java: Update comment to reflect status. (equals): Fixed indentation. * java/lang/Class.h (Class): Declare memberAccessCheck, not checkMemberAccess. Make _Jv_CheckAccess a friend. * java/lang/Class.java (memberAccessCheck): New method from Classpath. (checkMemberAccess): Removed. (getDeclaredMethod): Use memberAccessCheck. (getField): Likewise. (getMethod): Likewise. * resolve.cc (_Jv_ResolvePoolEntry): Use _Jv_CheckAccess. (_Jv_SearchMethodInClass): Likewise. * prims.cc (_Jv_CheckAccess): New function. * jni.cc (_Jv_JNI_FindClass): Use getClassLoaderInternal. (_Jv_JNI_GetAnyFieldID): Likewise. * java/lang/natClass.cc (forName): Use getClassLoaderInternal. (getClassLoader): Added security check. (getConstructor): Call memberAccessCheck. (getDeclaredClasses): Likewise. (getDeclaredField): Likewise. (getDeclaredFields): Likewise. (_getConstructors): Likewise. (getDeclaredConstructor): Likewise. (getDeclaredMethods): Likewise. (getFields): Likewise. (getMethods): Likewise. (newInstance): Likewise. (_Jv_MakeVTable): Put method name in exception. * java/lang/reflect/natMethod.cc (getType): Use getClassLoaderInternal. (_Jv_GetTypesFromSignature): Likewise. (invoke): Perform access check. (_Jv_CallAnyMethodA): Removed old FIXME comments. Include ArrayIndexOutOfBoundsException.h. * java/lang/reflect/natField.cc (getType): Use getClassLoaderInternal. (_Jv_CheckFieldAccessibility): Removed. (getAddr): Use _Jv_CheckAccess; find caller. Include ArrayIndexOutOfBoundsException.h. From-SVN: r69621
2003-07-21 03:54:06 +02:00
{
New Stack Trace infrastructure. 2005-03-10 Bryce McKinlay <mckinlay@redhat.com> New Stack Trace infrastructure. * Makefile.am (libgcj0_convenience_la_SOURCES): Add stacktrace.cc. (gnu/gcj/runtime/StackTrace.lo): Removed. (ordinary_java_source_files): Remove obsolete files. (nat_source_files): Remove obsolete files. Add natVMThrowable.cc. * configure.host (fallback_backtrace_h): Set backtrace header for mingw and cygwin targets. * configure.ac: Make symlink for fallback backtrace headers. * Makefile.in, configure: Rebuilt. * defineclass.cc (_Jv_ClassReader::read_one_code_attribute): Read 'LineNumberTable' attribute. (_Jv_ClassReader::read_one_class_attribute): Read 'SourceFile' attribute. (_Jv_ClassReader::handleCodeAttribute): Initialize method line table fields. * exception.cc: Remove unused include. * interpret.cc (DIRECT_THREADED, insn_slot): Moved to java-interp.h. (SAVE_PC): New macro. Save current PC in the interpreter frame. (NULLCHECK, NULLARRAYCHECK): Use SAVE_PC. (_Jv_InterpMethod::compile): Translate bytecode PC values in the line table to direct threaded instruction values. (_Jv_StartOfInterpreter, _Jv_EndOfInterpreter): Removed. (_Jv_InterpMethod::run): No longer member function. All callers updated. Remove _Unwind calls. Call SAVE_PC whenever a call is made or where an instruction could throw. (_Jv_InterpMethod::get_source_line): New. Look up source line numbers in line_table. * prims.cc (catch_segv): Construct exception after MAKE_THROW_FRAME. (catch_fpe): Likewise. * stacktrace.cc: New file. Stack trace code now here. * gnu/gcj/runtime/MethodRef.java: * gnu/gcj/runtime/NameFinder.java: Mostly reimplemented. Now simply calls addr2line to look up PC addresses in a given binary or shared library. * gnu/gcj/runtime/StackTrace.java, gnu/gcj/runtime/natNameFinder.cc, gnu/gcj/runtime/natStackTrace.cc: Removed. * gnu/java/lang/MainThread.java (call_main): Add comment warning that this function name is specially recognised by the stack trace code and shouldn't be changed. * include/java-interp.h (DIRECT_THREADED, insn_slot): Moved here. (struct _Jv_LineTableEntry, line_table, line_table_len): New. (_Jv_InterpMethod::run): Update declaration. (_Jv_StackTrace_): New friend. NameFinder and StackTrace no longer friends. (_Jv_InterpFrame): Renamed from _Jv_MethodChain. Add PC field. * include/java-stack.h: New file. Declarations for stack tracing. * include/jvm.h (_Jv_Frame_info): Removed. * java/lang/Class.h: Update friend declarations. * java/lang/VMClassLoader.java (getSystemClassLoader): Simplify exception message. * java/lang/VMThrowable.java (fillInStackTrace): Now native. (getStackTrace): Now native. (data): New RawDataManaged field. * java/lang/natClass.cc: Update includes. (forName): Use _Jv_StackTrace::GetCallingClass for calling-classloader check. (getClassLoader): Likewise. * java/lang/natRuntime.cc: Update includes. (_load): Use _Jv_StackTrace::GetFirstNonSystemClassLoader. * java/lang/natVMSecurityManager.cc: Update includes. (getClassContext): Use _Jv_StackTrace::GetClassContext. * java/lang/natVMThrowable.cc: New file. Native methods for VMThrowable. * java/lang/reflect/natArray.cc: Update includes. (newInstance): Use _Jv_StackTrace::GetCallingClass to implement accessibility check. * java/lang/reflect/natConstructor.cc: Update includes. (newInstance): Use _Jv_StackTrace::GetCallingClass to implement accessibility check. * java/lang/reflect/natField.cc: Update includes. (getAddr): Use _Jv_StackTrace::GetCallingClass to implement accessibility check. * java/lang/reflect/natMethod.cc: Update includes. (invoke): Use _Jv_StackTrace::GetCallingClass to implement accessibility check. * java/util/natResourceBundle.cc: Update includes. (getCallingClassLoader): Use _Jv_StackTrace::GetCallingClass. * java/util/logging/natLogger.cc: Update includes. Use _Jv_StackTrace::GetCallerInfo to get call-site info. * sysdep/generic/backtrace.h: Fallback backtrace code. Stub implementation. * sysdep/i386/backtrace.h: New. Fallback backtrace code. i386 implementation. From-SVN: r96253
2005-03-10 20:02:21 +01:00
jclass caller = _Jv_StackTrace::GetCallingClass (&Class::class$);
return getClassLoader (caller);
}
return loader;
}
java::lang::ClassLoader *
java::lang::Class::getClassLoader (jclass caller)
{
java::lang::SecurityManager *s = java::lang::System::getSecurityManager();
if (s != NULL)
{
ClassLoader *caller_loader = caller->getClassLoaderInternal();
Runtime.java: Comment fix. * java/lang/Runtime.java: Comment fix. * java/lang/ClassLoader.java (isAncestorOf): New method. (getParent): Uncommented security check. Use isAncestorOf. * include/jvm.h (_Jv_CheckAccess): Declare. * java/lang/reflect/natConstructor.cc (newInstance): Perform access check. Include IllegalAccessException.h, ArrayIndexOutOfBoundsException.h. * java/lang/reflect/natArray.cc (newInstance): Pass caller's class loader to _Jv_GetArrayClass. Include ArrayIndexOutOfBoundsException.h. * java/lang/reflect/Field.java: Update comment to reflect status. (equals): Fixed indentation. * java/lang/Class.h (Class): Declare memberAccessCheck, not checkMemberAccess. Make _Jv_CheckAccess a friend. * java/lang/Class.java (memberAccessCheck): New method from Classpath. (checkMemberAccess): Removed. (getDeclaredMethod): Use memberAccessCheck. (getField): Likewise. (getMethod): Likewise. * resolve.cc (_Jv_ResolvePoolEntry): Use _Jv_CheckAccess. (_Jv_SearchMethodInClass): Likewise. * prims.cc (_Jv_CheckAccess): New function. * jni.cc (_Jv_JNI_FindClass): Use getClassLoaderInternal. (_Jv_JNI_GetAnyFieldID): Likewise. * java/lang/natClass.cc (forName): Use getClassLoaderInternal. (getClassLoader): Added security check. (getConstructor): Call memberAccessCheck. (getDeclaredClasses): Likewise. (getDeclaredField): Likewise. (getDeclaredFields): Likewise. (_getConstructors): Likewise. (getDeclaredConstructor): Likewise. (getDeclaredMethods): Likewise. (getFields): Likewise. (getMethods): Likewise. (newInstance): Likewise. (_Jv_MakeVTable): Put method name in exception. * java/lang/reflect/natMethod.cc (getType): Use getClassLoaderInternal. (_Jv_GetTypesFromSignature): Likewise. (invoke): Perform access check. (_Jv_CallAnyMethodA): Removed old FIXME comments. Include ArrayIndexOutOfBoundsException.h. * java/lang/reflect/natField.cc (getType): Use getClassLoaderInternal. (_Jv_CheckFieldAccessibility): Removed. (getAddr): Use _Jv_CheckAccess; find caller. Include ArrayIndexOutOfBoundsException.h. From-SVN: r69621
2003-07-21 03:54:06 +02:00
// If the caller has a non-null class loader, and that loader
// is not this class' loader or an ancestor thereof, then do a
// security check.
if (caller_loader != NULL && ! caller_loader->isAncestorOf(loader))
s->checkPermission (new RuntimePermission (JvNewStringLatin1 ("getClassLoader")));
}
Makefile.in: Rebuilt. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Define TOOLEXECLIBDIR. (libgcj0_convenience_la_SOURCES): Don't include gnu_xml_source_files. (libgcj0_convenience_la_LIBADD): New variable. (libgcj_la_LIBADD): Don't include sax or w3c_dom. (all_java_source_files): javax_imageio_source_files, javax_xml_source_files, and gnu_java_beans_source_files. ($(gnu_xml_source_files:.java=.lo)): Removed target. (gnu-xml.lo): New target. (javax-imageio.lo): Likewise. (javax-xml.lo): Likewise. (gnu-java-beans.lo): Likewise. (gnu_java_beans_source_files): New variable. (javax_imageio_source_files): Likewise. (javax_xml_source_files): Likewise. (javax_source_files): Moved files to other variable. (awt_java_source_files): Likewise. (ordinary_java_source_files): Added BootClassLoader.java. * java/lang/natVMClassLoader.cc (defineClass): Use boot loader, not system class loader. (initBootLoader): New method. (loadClass): Search bootLoader. * java/lang/natClassLoader.cc (_Jv_RegisterInitiatingLoader): Use boot loader, not system class loader. (_Jv_UnregisterInitiatingLoader): Likewise. (_Jv_FindClass): Likewise. Ensure entries in bootstrap_class_list are unique. * java/lang/natClass.cc (getClassLoader): Don't special case system class loader. * java/lang/VMClassLoader.java (bootLoader): New field. (getResource): Use bootLoader. (getResources): Likewise. (initBootLoader): Declare. * gnu/gcj/runtime/BootClassLoader.java: New file. * external/sax/org/xml/sax/helpers/NamespaceSupport.java (EMPTY_ENUMERATION): Now package-private. * external/w3c_com/Makefile.in: Rebuilt. * external/w3c_com/Makefile.am (MULTIBUILDTOP): New variable. (w3c.jar): New target. (classes.stamp): Updated. (toolexeclib_LTLIBRARIES): Renamed from noinst_LTLIBRARIES. Changed name of library. (libw3c_gcj_la_SOURCES): New variable. (libw3c_gcj_la_GCJFLAGS): Likewise. (source_files): Renamed from lib3c_convenience_la_SOURCES. * external/sax/Makefile.in: Rebuilt. * external/sax/Makefile.am (MULTIBUILDTOP): New variable. (sax.jar): New target. (classes.stamp): Updated. (toolexeclib_LTLIBRARIES): Renamed from noinst_LTLIBRARIES. Changed name of library. (libsax_gcj_la_SOURCES): New variable. (libsax_gcj_la_GCJFLAGS): Likewise. (source_files): Renamed from libsax_convenience_la_SOURCES. * stacktrace.cc (non_system_trace_fn): Don't look at system class loader. * prims.cc (_Jv_CreateJavaVM): Initialize the bootstrap class loader. (_Jv_RunMain): Handle case where 'runtime' is NULL at exit. From-SVN: r96960
2005-03-24 01:04:22 +01:00
return loader;
}
1999-04-07 16:42:40 +02:00
java::lang::reflect::Constructor *
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
java::lang::Class::getConstructor (JArray<jclass> *param_types)
1999-04-07 16:42:40 +02:00
{
Runtime.java: Comment fix. * java/lang/Runtime.java: Comment fix. * java/lang/ClassLoader.java (isAncestorOf): New method. (getParent): Uncommented security check. Use isAncestorOf. * include/jvm.h (_Jv_CheckAccess): Declare. * java/lang/reflect/natConstructor.cc (newInstance): Perform access check. Include IllegalAccessException.h, ArrayIndexOutOfBoundsException.h. * java/lang/reflect/natArray.cc (newInstance): Pass caller's class loader to _Jv_GetArrayClass. Include ArrayIndexOutOfBoundsException.h. * java/lang/reflect/Field.java: Update comment to reflect status. (equals): Fixed indentation. * java/lang/Class.h (Class): Declare memberAccessCheck, not checkMemberAccess. Make _Jv_CheckAccess a friend. * java/lang/Class.java (memberAccessCheck): New method from Classpath. (checkMemberAccess): Removed. (getDeclaredMethod): Use memberAccessCheck. (getField): Likewise. (getMethod): Likewise. * resolve.cc (_Jv_ResolvePoolEntry): Use _Jv_CheckAccess. (_Jv_SearchMethodInClass): Likewise. * prims.cc (_Jv_CheckAccess): New function. * jni.cc (_Jv_JNI_FindClass): Use getClassLoaderInternal. (_Jv_JNI_GetAnyFieldID): Likewise. * java/lang/natClass.cc (forName): Use getClassLoaderInternal. (getClassLoader): Added security check. (getConstructor): Call memberAccessCheck. (getDeclaredClasses): Likewise. (getDeclaredField): Likewise. (getDeclaredFields): Likewise. (_getConstructors): Likewise. (getDeclaredConstructor): Likewise. (getDeclaredMethods): Likewise. (getFields): Likewise. (getMethods): Likewise. (newInstance): Likewise. (_Jv_MakeVTable): Put method name in exception. * java/lang/reflect/natMethod.cc (getType): Use getClassLoaderInternal. (_Jv_GetTypesFromSignature): Likewise. (invoke): Perform access check. (_Jv_CallAnyMethodA): Removed old FIXME comments. Include ArrayIndexOutOfBoundsException.h. * java/lang/reflect/natField.cc (getType): Use getClassLoaderInternal. (_Jv_CheckFieldAccessibility): Removed. (getAddr): Use _Jv_CheckAccess; find caller. Include ArrayIndexOutOfBoundsException.h. From-SVN: r69621
2003-07-21 03:54:06 +02:00
memberAccessCheck(java::lang::reflect::Member::PUBLIC);
jstring partial_sig = getSignature (param_types, true);
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
jint hash = partial_sig->hashCode ();
int i = isPrimitive () ? 0 : method_count;
while (--i >= 0)
{
if (_Jv_equalUtf8Consts (methods[i].name, init_name)
&& _Jv_equal (methods[i].signature, partial_sig, hash))
{
// Found it. For getConstructor, the constructor must be
// public.
using namespace java::lang::reflect;
if (! Modifier::isPublic(methods[i].accflags))
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
break;
Constructor *cons = new Constructor ();
cons->offset = (char *) (&methods[i]) - (char *) methods;
cons->declaringClass = this;
return cons;
}
}
throw new java::lang::NoSuchMethodException (_Jv_NewStringUtf8Const (init_name));
1999-04-07 16:42:40 +02:00
}
JArray<java::lang::reflect::Constructor *> *
java::lang::Class::getDeclaredConstructors (jboolean publicOnly)
1999-04-07 16:42:40 +02:00
{
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
int numConstructors = 0;
int max = isPrimitive () ? 0 : method_count;
int i;
for (i = max; --i >= 0; )
{
_Jv_Method *method = &methods[i];
if (method->name == NULL
|| ! _Jv_equalUtf8Consts (method->name, init_name))
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
continue;
if (publicOnly
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
&& ! java::lang::reflect::Modifier::isPublic(method->accflags))
continue;
numConstructors++;
}
JArray<java::lang::reflect::Constructor *> *result
= (JArray<java::lang::reflect::Constructor *> *)
JvNewObjectArray (numConstructors,
&java::lang::reflect::Constructor::class$,
NULL);
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
java::lang::reflect::Constructor** cptr = elements (result);
for (i = 0; i < max; i++)
{
_Jv_Method *method = &methods[i];
if (method->name == NULL
|| ! _Jv_equalUtf8Consts (method->name, init_name))
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
continue;
if (publicOnly
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
&& ! java::lang::reflect::Modifier::isPublic(method->accflags))
continue;
java::lang::reflect::Constructor *cons
= new java::lang::reflect::Constructor ();
cons->offset = (char *) method - (char *) methods;
cons->declaringClass = this;
*cptr++ = cons;
}
return result;
1999-04-07 16:42:40 +02:00
}
java::lang::reflect::Constructor *
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
java::lang::Class::getDeclaredConstructor (JArray<jclass> *param_types)
1999-04-07 16:42:40 +02:00
{
Runtime.java: Comment fix. * java/lang/Runtime.java: Comment fix. * java/lang/ClassLoader.java (isAncestorOf): New method. (getParent): Uncommented security check. Use isAncestorOf. * include/jvm.h (_Jv_CheckAccess): Declare. * java/lang/reflect/natConstructor.cc (newInstance): Perform access check. Include IllegalAccessException.h, ArrayIndexOutOfBoundsException.h. * java/lang/reflect/natArray.cc (newInstance): Pass caller's class loader to _Jv_GetArrayClass. Include ArrayIndexOutOfBoundsException.h. * java/lang/reflect/Field.java: Update comment to reflect status. (equals): Fixed indentation. * java/lang/Class.h (Class): Declare memberAccessCheck, not checkMemberAccess. Make _Jv_CheckAccess a friend. * java/lang/Class.java (memberAccessCheck): New method from Classpath. (checkMemberAccess): Removed. (getDeclaredMethod): Use memberAccessCheck. (getField): Likewise. (getMethod): Likewise. * resolve.cc (_Jv_ResolvePoolEntry): Use _Jv_CheckAccess. (_Jv_SearchMethodInClass): Likewise. * prims.cc (_Jv_CheckAccess): New function. * jni.cc (_Jv_JNI_FindClass): Use getClassLoaderInternal. (_Jv_JNI_GetAnyFieldID): Likewise. * java/lang/natClass.cc (forName): Use getClassLoaderInternal. (getClassLoader): Added security check. (getConstructor): Call memberAccessCheck. (getDeclaredClasses): Likewise. (getDeclaredField): Likewise. (getDeclaredFields): Likewise. (_getConstructors): Likewise. (getDeclaredConstructor): Likewise. (getDeclaredMethods): Likewise. (getFields): Likewise. (getMethods): Likewise. (newInstance): Likewise. (_Jv_MakeVTable): Put method name in exception. * java/lang/reflect/natMethod.cc (getType): Use getClassLoaderInternal. (_Jv_GetTypesFromSignature): Likewise. (invoke): Perform access check. (_Jv_CallAnyMethodA): Removed old FIXME comments. Include ArrayIndexOutOfBoundsException.h. * java/lang/reflect/natField.cc (getType): Use getClassLoaderInternal. (_Jv_CheckFieldAccessibility): Removed. (getAddr): Use _Jv_CheckAccess; find caller. Include ArrayIndexOutOfBoundsException.h. From-SVN: r69621
2003-07-21 03:54:06 +02:00
memberAccessCheck(java::lang::reflect::Member::DECLARED);
jstring partial_sig = getSignature (param_types, true);
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
jint hash = partial_sig->hashCode ();
1999-04-07 16:42:40 +02:00
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
int i = isPrimitive () ? 0 : method_count;
while (--i >= 0)
{
if (_Jv_equalUtf8Consts (methods[i].name, init_name)
&& _Jv_equal (methods[i].signature, partial_sig, hash))
{
// Found it.
using namespace java::lang::reflect;
Constructor *cons = new Constructor ();
cons->offset = (char *) (&methods[i]) - (char *) methods;
cons->declaringClass = this;
return cons;
}
}
throw new java::lang::NoSuchMethodException (_Jv_NewStringUtf8Const (init_name));
1999-04-07 16:42:40 +02:00
}
java::lang::reflect::Field *
java::lang::Class::getField (jstring name, jint hash)
{
java::lang::reflect::Field* rfield;
for (int i = 0; i < field_count; i++)
{
_Jv_Field *field = &fields[i];
if (! _Jv_equal (field->name, name, hash))
continue;
if (! (field->getModifiers() & java::lang::reflect::Modifier::PUBLIC))
continue;
rfield = new java::lang::reflect::Field ();
rfield->offset = (char*) field - (char*) fields;
rfield->declaringClass = this;
rfield->name = name;
return rfield;
}
jclass superclass = getSuperclass();
if (superclass == NULL)
return NULL;
rfield = superclass->getField(name, hash);
for (int i = 0; i < interface_count && rfield == NULL; ++i)
rfield = interfaces[i]->getField (name, hash);
return rfield;
}
java::lang::reflect::Field *
java::lang::Class::getDeclaredField (jstring name)
{
Runtime.java: Comment fix. * java/lang/Runtime.java: Comment fix. * java/lang/ClassLoader.java (isAncestorOf): New method. (getParent): Uncommented security check. Use isAncestorOf. * include/jvm.h (_Jv_CheckAccess): Declare. * java/lang/reflect/natConstructor.cc (newInstance): Perform access check. Include IllegalAccessException.h, ArrayIndexOutOfBoundsException.h. * java/lang/reflect/natArray.cc (newInstance): Pass caller's class loader to _Jv_GetArrayClass. Include ArrayIndexOutOfBoundsException.h. * java/lang/reflect/Field.java: Update comment to reflect status. (equals): Fixed indentation. * java/lang/Class.h (Class): Declare memberAccessCheck, not checkMemberAccess. Make _Jv_CheckAccess a friend. * java/lang/Class.java (memberAccessCheck): New method from Classpath. (checkMemberAccess): Removed. (getDeclaredMethod): Use memberAccessCheck. (getField): Likewise. (getMethod): Likewise. * resolve.cc (_Jv_ResolvePoolEntry): Use _Jv_CheckAccess. (_Jv_SearchMethodInClass): Likewise. * prims.cc (_Jv_CheckAccess): New function. * jni.cc (_Jv_JNI_FindClass): Use getClassLoaderInternal. (_Jv_JNI_GetAnyFieldID): Likewise. * java/lang/natClass.cc (forName): Use getClassLoaderInternal. (getClassLoader): Added security check. (getConstructor): Call memberAccessCheck. (getDeclaredClasses): Likewise. (getDeclaredField): Likewise. (getDeclaredFields): Likewise. (_getConstructors): Likewise. (getDeclaredConstructor): Likewise. (getDeclaredMethods): Likewise. (getFields): Likewise. (getMethods): Likewise. (newInstance): Likewise. (_Jv_MakeVTable): Put method name in exception. * java/lang/reflect/natMethod.cc (getType): Use getClassLoaderInternal. (_Jv_GetTypesFromSignature): Likewise. (invoke): Perform access check. (_Jv_CallAnyMethodA): Removed old FIXME comments. Include ArrayIndexOutOfBoundsException.h. * java/lang/reflect/natField.cc (getType): Use getClassLoaderInternal. (_Jv_CheckFieldAccessibility): Removed. (getAddr): Use _Jv_CheckAccess; find caller. Include ArrayIndexOutOfBoundsException.h. From-SVN: r69621
2003-07-21 03:54:06 +02:00
memberAccessCheck(java::lang::reflect::Member::DECLARED);
1999-04-07 16:42:40 +02:00
int hash = name->hashCode();
for (int i = 0; i < field_count; i++)
{
_Jv_Field *field = &fields[i];
if (! _Jv_equal (field->name, name, hash))
continue;
java::lang::reflect::Field* rfield = new java::lang::reflect::Field ();
rfield->offset = (char*) field - (char*) fields;
rfield->declaringClass = this;
rfield->name = name;
return rfield;
}
throw new java::lang::NoSuchFieldException (name);
1999-04-07 16:42:40 +02:00
}
JArray<java::lang::reflect::Field *> *
java::lang::Class::getDeclaredFields (jboolean public_only)
1999-04-07 16:42:40 +02:00
{
int size;
if (public_only)
{
size = 0;
for (int i = 0; i < field_count; ++i)
{
_Jv_Field *field = &fields[i];
if ((field->flags & java::lang::reflect::Modifier::PUBLIC))
++size;
}
}
else
size = field_count;
1999-04-07 16:42:40 +02:00
JArray<java::lang::reflect::Field *> *result
= (JArray<java::lang::reflect::Field *> *)
JvNewObjectArray (size, &java::lang::reflect::Field::class$, NULL);
1999-04-07 16:42:40 +02:00
java::lang::reflect::Field** fptr = elements (result);
for (int i = 0; i < field_count; i++)
{
_Jv_Field *field = &fields[i];
if (public_only
&& ! (field->flags & java::lang::reflect::Modifier::PUBLIC))
continue;
1999-04-07 16:42:40 +02:00
java::lang::reflect::Field* rfield = new java::lang::reflect::Field ();
rfield->offset = (char*) field - (char*) fields;
rfield->declaringClass = this;
*fptr++ = rfield;
}
return result;
}
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
void
java::lang::Class::getSignature (java::lang::StringBuffer *buffer)
1999-04-07 16:42:40 +02:00
{
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
if (isPrimitive())
buffer->append((jchar) method_count);
else
{
jstring name = getName();
if (name->charAt(0) != '[')
buffer->append((jchar) 'L');
buffer->append(name);
if (name->charAt(0) != '[')
buffer->append((jchar) ';');
}
}
// This doesn't have to be native. It is an implementation detail
// only called from the C++ code, though, so maybe this is clearer.
jstring
java::lang::Class::getSignature (JArray<jclass> *param_types,
jboolean is_constructor)
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
{
java::lang::StringBuffer *buf = new java::lang::StringBuffer ();
buf->append((jchar) '(');
// A NULL param_types means "no parameters".
if (param_types != NULL)
{
jclass *v = elements (param_types);
for (int i = 0; i < param_types->length; ++i)
v[i]->getSignature(buf);
}
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
buf->append((jchar) ')');
if (is_constructor)
buf->append((jchar) 'V');
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
return buf->toString();
}
java::lang::reflect::Method *
java::lang::Class::_getDeclaredMethod (jstring name,
JArray<jclass> *param_types)
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
{
jstring partial_sig = getSignature (param_types, false);
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
jint p_len = partial_sig->length();
_Jv_Utf8Const *utf_name = _Jv_makeUtf8Const (name);
int i = isPrimitive () ? 0 : method_count;
while (--i >= 0)
{
if (_Jv_equalUtf8Consts (methods[i].name, utf_name)
&& _Jv_equaln (methods[i].signature, partial_sig, p_len)
&& (methods[i].accflags
& java::lang::reflect::Modifier::INVISIBLE) == 0)
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
{
// Found it.
using namespace java::lang::reflect;
Method *rmethod = new Method ();
rmethod->offset = (char*) (&methods[i]) - (char*) methods;
rmethod->declaringClass = this;
return rmethod;
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
}
}
return NULL;
1999-04-07 16:42:40 +02:00
}
JArray<java::lang::reflect::Method *> *
java::lang::Class::getDeclaredMethods (void)
{
Runtime.java: Comment fix. * java/lang/Runtime.java: Comment fix. * java/lang/ClassLoader.java (isAncestorOf): New method. (getParent): Uncommented security check. Use isAncestorOf. * include/jvm.h (_Jv_CheckAccess): Declare. * java/lang/reflect/natConstructor.cc (newInstance): Perform access check. Include IllegalAccessException.h, ArrayIndexOutOfBoundsException.h. * java/lang/reflect/natArray.cc (newInstance): Pass caller's class loader to _Jv_GetArrayClass. Include ArrayIndexOutOfBoundsException.h. * java/lang/reflect/Field.java: Update comment to reflect status. (equals): Fixed indentation. * java/lang/Class.h (Class): Declare memberAccessCheck, not checkMemberAccess. Make _Jv_CheckAccess a friend. * java/lang/Class.java (memberAccessCheck): New method from Classpath. (checkMemberAccess): Removed. (getDeclaredMethod): Use memberAccessCheck. (getField): Likewise. (getMethod): Likewise. * resolve.cc (_Jv_ResolvePoolEntry): Use _Jv_CheckAccess. (_Jv_SearchMethodInClass): Likewise. * prims.cc (_Jv_CheckAccess): New function. * jni.cc (_Jv_JNI_FindClass): Use getClassLoaderInternal. (_Jv_JNI_GetAnyFieldID): Likewise. * java/lang/natClass.cc (forName): Use getClassLoaderInternal. (getClassLoader): Added security check. (getConstructor): Call memberAccessCheck. (getDeclaredClasses): Likewise. (getDeclaredField): Likewise. (getDeclaredFields): Likewise. (_getConstructors): Likewise. (getDeclaredConstructor): Likewise. (getDeclaredMethods): Likewise. (getFields): Likewise. (getMethods): Likewise. (newInstance): Likewise. (_Jv_MakeVTable): Put method name in exception. * java/lang/reflect/natMethod.cc (getType): Use getClassLoaderInternal. (_Jv_GetTypesFromSignature): Likewise. (invoke): Perform access check. (_Jv_CallAnyMethodA): Removed old FIXME comments. Include ArrayIndexOutOfBoundsException.h. * java/lang/reflect/natField.cc (getType): Use getClassLoaderInternal. (_Jv_CheckFieldAccessibility): Removed. (getAddr): Use _Jv_CheckAccess; find caller. Include ArrayIndexOutOfBoundsException.h. From-SVN: r69621
2003-07-21 03:54:06 +02:00
memberAccessCheck(java::lang::reflect::Member::DECLARED);
1999-04-07 16:42:40 +02:00
int numMethods = 0;
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
int max = isPrimitive () ? 0 : method_count;
1999-04-07 16:42:40 +02:00
int i;
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
for (i = max; --i >= 0; )
1999-04-07 16:42:40 +02:00
{
_Jv_Method *method = &methods[i];
if (method->name == NULL
|| _Jv_equalUtf8Consts (method->name, clinit_name)
|| _Jv_equalUtf8Consts (method->name, init_name)
|| _Jv_equalUtf8Consts (method->name, finit_name)
|| (methods[i].accflags
& java::lang::reflect::Modifier::INVISIBLE) != 0)
1999-04-07 16:42:40 +02:00
continue;
numMethods++;
}
JArray<java::lang::reflect::Method *> *result
= (JArray<java::lang::reflect::Method *> *)
JvNewObjectArray (numMethods, &java::lang::reflect::Method::class$, NULL);
1999-04-07 16:42:40 +02:00
java::lang::reflect::Method** mptr = elements (result);
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
for (i = 0; i < max; i++)
1999-04-07 16:42:40 +02:00
{
_Jv_Method *method = &methods[i];
if (method->name == NULL
|| _Jv_equalUtf8Consts (method->name, clinit_name)
|| _Jv_equalUtf8Consts (method->name, init_name)
|| _Jv_equalUtf8Consts (method->name, finit_name)
|| (methods[i].accflags
& java::lang::reflect::Modifier::INVISIBLE) != 0)
1999-04-07 16:42:40 +02:00
continue;
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
java::lang::reflect::Method* rmethod
= new java::lang::reflect::Method ();
rmethod->offset = (char*) method - (char*) methods;
1999-04-07 16:42:40 +02:00
rmethod->declaringClass = this;
*mptr++ = rmethod;
}
return result;
}
jstring
java::lang::Class::getName (void)
{
return name->toString();
1999-04-07 16:42:40 +02:00
}
JArray<jclass> *
java::lang::Class::getInterfaces (void)
{
jobjectArray r = JvNewObjectArray (interface_count, getClass (), NULL);
jobject *data = elements (r);
for (int i = 0; i < interface_count; ++i)
{
typedef unsigned int uaddr __attribute__ ((mode (pointer)));
data[i] = interfaces[i];
if ((uaddr)data[i] < (uaddr)constants.size)
fprintf (stderr, "ERROR !!!\n");
}
1999-04-07 16:42:40 +02:00
return reinterpret_cast<JArray<jclass> *> (r);
}
java::lang::reflect::Method *
java::lang::Class::_getMethod (jstring name, JArray<jclass> *param_types)
1999-04-07 16:42:40 +02:00
{
jstring partial_sig = getSignature (param_types, false);
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
jint p_len = partial_sig->length();
_Jv_Utf8Const *utf_name = _Jv_makeUtf8Const (name);
for (Class *klass = this; klass; klass = klass->getSuperclass())
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
{
int i = klass->isPrimitive () ? 0 : klass->method_count;
while (--i >= 0)
{
if (_Jv_equalUtf8Consts (klass->methods[i].name, utf_name)
&& _Jv_equaln (klass->methods[i].signature, partial_sig, p_len)
&& (klass->methods[i].accflags
& java::lang::reflect::Modifier::INVISIBLE) == 0)
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
{
// Found it.
using namespace java::lang::reflect;
// Method must be public.
if (! Modifier::isPublic (klass->methods[i].accflags))
break;
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
Method *rmethod = new Method ();
rmethod->offset = ((char *) (&klass->methods[i])
- (char *) klass->methods);
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
rmethod->declaringClass = klass;
return rmethod;
}
}
}
// If we haven't found a match, and this class is an interface, then
// check all the superinterfaces.
if (isInterface())
{
for (int i = 0; i < interface_count; ++i)
{
using namespace java::lang::reflect;
Method *rmethod = interfaces[i]->_getMethod (name, param_types);
if (rmethod != NULL)
return rmethod;
}
}
return NULL;
1999-04-07 16:42:40 +02:00
}
// This is a very slow implementation, since it re-scans all the
// methods we've already listed to make sure we haven't duplicated a
// method. It also over-estimates the required size, so we have to
// shrink the result array later.
jint
java::lang::Class::_getMethods (JArray<java::lang::reflect::Method *> *result,
jint offset)
{
jint count = 0;
// First examine all local methods
for (int i = isPrimitive () ? 0 : method_count; --i >= 0; )
{
_Jv_Method *method = &methods[i];
if (method->name == NULL
|| _Jv_equalUtf8Consts (method->name, clinit_name)
|| _Jv_equalUtf8Consts (method->name, init_name)
|| _Jv_equalUtf8Consts (method->name, finit_name)
|| (method->accflags
& java::lang::reflect::Modifier::INVISIBLE) != 0)
continue;
// Only want public methods.
if (! java::lang::reflect::Modifier::isPublic (method->accflags))
continue;
// This is where we over-count the slots required if we aren't
// filling the result for real.
if (result != NULL)
{
jboolean add = true;
java::lang::reflect::Method **mp = elements (result);
// If we already have a method with this name and signature,
// then ignore this one. This can happen with virtual
// methods.
for (int j = 0; j < offset; ++j)
{
_Jv_Method *meth_2 = _Jv_FromReflectedMethod (mp[j]);
if (_Jv_equalUtf8Consts (method->name, meth_2->name)
&& _Jv_equalUtf8Consts (method->signature,
meth_2->signature))
{
add = false;
break;
}
}
if (! add)
continue;
}
if (result != NULL)
{
using namespace java::lang::reflect;
Method *rmethod = new Method ();
rmethod->offset = (char *) method - (char *) methods;
rmethod->declaringClass = this;
Method **mp = elements (result);
mp[offset + count] = rmethod;
}
++count;
}
offset += count;
// Now examine superclasses.
if (getSuperclass () != NULL)
{
jint s_count = getSuperclass()->_getMethods (result, offset);
offset += s_count;
count += s_count;
}
// Finally, examine interfaces.
for (int i = 0; i < interface_count; ++i)
{
int f_count = interfaces[i]->_getMethods (result, offset);
count += f_count;
offset += f_count;
}
return count;
}
1999-04-07 16:42:40 +02:00
JArray<java::lang::reflect::Method *> *
java::lang::Class::getMethods (void)
{
using namespace java::lang::reflect;
Runtime.java: Comment fix. * java/lang/Runtime.java: Comment fix. * java/lang/ClassLoader.java (isAncestorOf): New method. (getParent): Uncommented security check. Use isAncestorOf. * include/jvm.h (_Jv_CheckAccess): Declare. * java/lang/reflect/natConstructor.cc (newInstance): Perform access check. Include IllegalAccessException.h, ArrayIndexOutOfBoundsException.h. * java/lang/reflect/natArray.cc (newInstance): Pass caller's class loader to _Jv_GetArrayClass. Include ArrayIndexOutOfBoundsException.h. * java/lang/reflect/Field.java: Update comment to reflect status. (equals): Fixed indentation. * java/lang/Class.h (Class): Declare memberAccessCheck, not checkMemberAccess. Make _Jv_CheckAccess a friend. * java/lang/Class.java (memberAccessCheck): New method from Classpath. (checkMemberAccess): Removed. (getDeclaredMethod): Use memberAccessCheck. (getField): Likewise. (getMethod): Likewise. * resolve.cc (_Jv_ResolvePoolEntry): Use _Jv_CheckAccess. (_Jv_SearchMethodInClass): Likewise. * prims.cc (_Jv_CheckAccess): New function. * jni.cc (_Jv_JNI_FindClass): Use getClassLoaderInternal. (_Jv_JNI_GetAnyFieldID): Likewise. * java/lang/natClass.cc (forName): Use getClassLoaderInternal. (getClassLoader): Added security check. (getConstructor): Call memberAccessCheck. (getDeclaredClasses): Likewise. (getDeclaredField): Likewise. (getDeclaredFields): Likewise. (_getConstructors): Likewise. (getDeclaredConstructor): Likewise. (getDeclaredMethods): Likewise. (getFields): Likewise. (getMethods): Likewise. (newInstance): Likewise. (_Jv_MakeVTable): Put method name in exception. * java/lang/reflect/natMethod.cc (getType): Use getClassLoaderInternal. (_Jv_GetTypesFromSignature): Likewise. (invoke): Perform access check. (_Jv_CallAnyMethodA): Removed old FIXME comments. Include ArrayIndexOutOfBoundsException.h. * java/lang/reflect/natField.cc (getType): Use getClassLoaderInternal. (_Jv_CheckFieldAccessibility): Removed. (getAddr): Use _Jv_CheckAccess; find caller. Include ArrayIndexOutOfBoundsException.h. From-SVN: r69621
2003-07-21 03:54:06 +02:00
memberAccessCheck(Member::PUBLIC);
// This will overestimate the size we need.
jint count = _getMethods (NULL, 0);
JArray<Method *> *result
= ((JArray<Method *> *) JvNewObjectArray (count,
&Method::class$,
NULL));
// When filling the array for real, we get the actual count. Then
// we resize the array.
jint real_count = _getMethods (result, 0);
if (real_count != count)
{
JArray<Method *> *r2
= ((JArray<Method *> *) JvNewObjectArray (real_count,
&Method::class$,
NULL));
Method **destp = elements (r2);
Method **srcp = elements (result);
for (int i = 0; i < real_count; ++i)
*destp++ = *srcp++;
result = r2;
}
return result;
1999-04-07 16:42:40 +02:00
}
jboolean
1999-04-07 16:42:40 +02:00
java::lang::Class::isAssignableFrom (jclass klass)
{
// Arguments may not have been initialized, given ".class" syntax.
// This ensures we can at least look at their superclasses.
_Jv_Linker::wait_for_state (this, JV_STATE_LOADING);
_Jv_Linker::wait_for_state (klass, JV_STATE_LOADING);
return _Jv_IsAssignableFrom (klass, this);
1999-04-07 16:42:40 +02:00
}
jboolean
1999-04-07 16:42:40 +02:00
java::lang::Class::isInstance (jobject obj)
{
if (! obj)
1999-04-07 16:42:40 +02:00
return false;
return _Jv_IsAssignableFrom (JV_CLASS (obj), this);
1999-04-07 16:42:40 +02:00
}
jobject
java::lang::Class::newInstance (void)
{
Runtime.java: Comment fix. * java/lang/Runtime.java: Comment fix. * java/lang/ClassLoader.java (isAncestorOf): New method. (getParent): Uncommented security check. Use isAncestorOf. * include/jvm.h (_Jv_CheckAccess): Declare. * java/lang/reflect/natConstructor.cc (newInstance): Perform access check. Include IllegalAccessException.h, ArrayIndexOutOfBoundsException.h. * java/lang/reflect/natArray.cc (newInstance): Pass caller's class loader to _Jv_GetArrayClass. Include ArrayIndexOutOfBoundsException.h. * java/lang/reflect/Field.java: Update comment to reflect status. (equals): Fixed indentation. * java/lang/Class.h (Class): Declare memberAccessCheck, not checkMemberAccess. Make _Jv_CheckAccess a friend. * java/lang/Class.java (memberAccessCheck): New method from Classpath. (checkMemberAccess): Removed. (getDeclaredMethod): Use memberAccessCheck. (getField): Likewise. (getMethod): Likewise. * resolve.cc (_Jv_ResolvePoolEntry): Use _Jv_CheckAccess. (_Jv_SearchMethodInClass): Likewise. * prims.cc (_Jv_CheckAccess): New function. * jni.cc (_Jv_JNI_FindClass): Use getClassLoaderInternal. (_Jv_JNI_GetAnyFieldID): Likewise. * java/lang/natClass.cc (forName): Use getClassLoaderInternal. (getClassLoader): Added security check. (getConstructor): Call memberAccessCheck. (getDeclaredClasses): Likewise. (getDeclaredField): Likewise. (getDeclaredFields): Likewise. (_getConstructors): Likewise. (getDeclaredConstructor): Likewise. (getDeclaredMethods): Likewise. (getFields): Likewise. (getMethods): Likewise. (newInstance): Likewise. (_Jv_MakeVTable): Put method name in exception. * java/lang/reflect/natMethod.cc (getType): Use getClassLoaderInternal. (_Jv_GetTypesFromSignature): Likewise. (invoke): Perform access check. (_Jv_CallAnyMethodA): Removed old FIXME comments. Include ArrayIndexOutOfBoundsException.h. * java/lang/reflect/natField.cc (getType): Use getClassLoaderInternal. (_Jv_CheckFieldAccessibility): Removed. (getAddr): Use _Jv_CheckAccess; find caller. Include ArrayIndexOutOfBoundsException.h. From-SVN: r69621
2003-07-21 03:54:06 +02:00
memberAccessCheck(java::lang::reflect::Member::PUBLIC);
1999-04-07 16:42:40 +02:00
if (isPrimitive ()
|| isInterface ()
|| isArray ()
|| java::lang::reflect::Modifier::isAbstract(accflags))
throw new java::lang::InstantiationException (getName ());
1999-04-07 16:42:40 +02:00
natClassLoader.cc (_Jv_PrepareCompiledClass): Renamed from _Jv_InternClassStrings. * java/lang/natClassLoader.cc (_Jv_PrepareCompiledClass): Renamed from _Jv_InternClassStrings. * prims.cc (_Jv_RunMain): New function. (JvRunMain): Remove gij-support. * gij.cc (main): Use _Jv_RunMain. * java/util/zip/ZipFile.java: Call readDirectory in constructor. * interpret.cc (PUSHA, PUSHI, PUSHF, PUSHL, PUSHD): Don't store argument in temp variable. (continue1): For all op_x2y insns, use temp variable for intermediate value. Also remove some comments. * java/lang/natClass.cc (newInstance): Call _Jv_InitClass. (forName): Don't call _Jv_InitClass. * java/lang/Class.java (getResource,getResourceAsStream): Implement. * java/util/zip/ZipEntry.java (ZipEntry(ZipEntry)): New construcor. * java/util/jar/JarInputStream.java: New file. * java/util/jar/JarEntry.java: New file. * java/util/jar/JarFile.java: New file. * java/net/URLClassLoader.java: New file. * java/net/JarURLConnection.java: New file. * gnu/gcj/protocol/jar/Handler.java: New file. * gnu/gcj/protocol/jar/Connection.java: New file. * java/security/SecureClassLoader.java: New file. * java/lang/ClassLoader.java (parent): New variable. (ClassLoader (ClassLoader)): new constructor. (findClass): New method. (loadClass): Add default 1.2 implementation. (getSystemResourceAsBytes, getResourceAsBytes): Removed. (readfully): Removed. * gnu/gcj/runtime/VMClassLoader.java: Moved from java/lang. (findSystemClass): New method. (VMClassLoader): Constructor rewritten. (init): New method. All other methods removed. * java/lang/natClassLoader.cc: Change use of java::lang::VMClassLoader to gnu::gcj::runtime::VMClassLoader. (_Jv_InternClassStrings): Use _Jv_ResolvePoolEntry. Also handle class entries. (VMClassLoader::findSystemClass): renamed from findBootClass. * Makefile.am: Add new files. (FirstThread.h, ThreadGroup.h): Add _Jv_Main friend. * Makefile.in: Rebuilt. From-SVN: r28748
1999-08-18 16:16:42 +02:00
_Jv_InitClass (this);
1999-04-07 16:42:40 +02:00
_Jv_Method *meth = _Jv_GetMethodLocal (this, init_name, void_signature);
if (! meth)
throw new java::lang::InstantiationException (getName());
1999-04-07 16:42:40 +02:00
jobject r = _Jv_AllocObject (this);
1999-04-07 16:42:40 +02:00
((void (*) (jobject)) meth->ncode) (r);
return r;
}
void
[multiple changes] 1999-08-09 Anthony Green <green@cygnus.com> * gij.cc: New file. * include/config.h.in: Rebuilt. * acconfig.h: Add INTERPRETER. * configure: Rebuilt. * Makefile.in: Rebuilt. * Makefile.am (libffi_files): Identify the libffi object files for inclusion in libgcj. (LIBFFIINCS): Define. * interpret.cc (gnu::gcj::runtime::MethodInvocation::continue1): Dummy definition for configurations without an interpreter. * java/net/natPlainSocketImpl.cc (getOption): Disamiguate call to java::lang::Boolean constructor. * include/java-interp.h: Always include java-cpool.h. * java/lang/natClassLoader.cc (getVMClassLoader0): Always return 0 when INTERPRETER not defined. * java/lang/Class.h (finalize): Define. * gnu/gcj/util/path/DirectoryPathEntry.java (getURL): Catch IOException from File.getCanonicalPath. (getStream): Likewise. * NEWS: More news. * THANKS: More thanks. 1999-08-09 Kresten Krab Thorup <krab@gnu.org> * resolve.cc (get_ffi_type_from_signature): Generate uint16 for jchar type. (_Jv_PrepareClass): Allow non-abstract classes to have abstract subclasses. (_Jv_ResolvePoolEntry): Revert subclass check for protected fields and methods. * interpret.cc (continue1/perform_invoke): Don't sign extend uint16 return val. (continue1/lshl,lshr): Push long, not int. (continue1/ulshr): Use UINT64, not long long. * defineclass.cc (handleFieldsEnd): Handle case when all fields are static. * java/lang/natClass.cc (forName): Add call to _Jv_InitClass. * java/lang/FirstThread.java (run): Add top-level exception handler. (run0): Renamed from run. 1999-08-08 Kresten Krab Thorup <krab@gnu.org> * configure.in (--with-interpreter): Added. * include/config.h.in (INTERPRETER): Added. * java/lang/ClassLoader.java: File replaced. * java/lang/VMClassLoader.java: New file. * java/lang/natClassLoader.cc: New file. * gnu/gcj/runtime/MethodInvocation.java: New file. * gnu/gcj/util/path/SearchPath.java: New file. * gnu/gcj/util/path/PathEntry.java: New file. * gnu/gcj/util/path/DirectoryPathEntry.java: New file. * gnu/gcj/util/path/ZipPathEntry.java: New file. * gnu/gcj/util/path/URLPathEntry.java: New file. * gnu/gcj/util/path/CacheEntry.java: New file. * include/java-interp.h: New file. * include/java-cpool.h: New file. * include/java-insns.h: New file. * defineclass.cc: New file. * interpret.cc: New file. * resolve.cc: New file. * java/lang/natClass.cc (loaded_classes, _Jv_RegisterClass, _Jv_RegisterClasses, _Jv_FindClassInCache, _Jv_FindClass, _Jv_NewClass, _Jv_FindArrayClass): Moved to natClassLoader.cc. (finalize): New. (STATE_NOTHING, STATE_RESOLVED, STATE_IN_PROGRESS, STATE_DONE, STATE_ERROR): Moved to java/lang/Class.h and renamed with JV_ prefix. (initializeClass): Use new JV_ prefixed names. Also, call ClassLoader::resolveClass instead of _Jv_ResolveClass. * java/lang/Class.h (JV_STATE_PRELOADING, JV_STATE_LOADING, JV_STATE_LOADED, JV_STATE_COMPILED, JV_STATE_PREPARED, JV_STATE_LINKED): New. (_Jv_WaitForState, _Jv_RegisterInitiatingLoader, _Jv_UnregisterClass, _Jv_InternClassStrings): New friends. (_Jv_IsInterpretedClass, _Jv_InitField, _Jv_LookupDeclaredMethod, _Jv_DetermineVTableIndex, _Jv_ResolvePoolEntry, _Jv_PrepareClass, _Jv_ClassReader, _Jv_InterpClass, _Jv_InterpMethod, _Jv_InterpMethodInvocation): New friends for interpreter. (finalize): New. (CONSTANT_Class, CONSTANT_String, etc.): Moved to include/java-cpool.h and renamed with JV_ prefix. * include/jvm.h (_Jv_makeUtf8Const, _Jv_makeUtf8TypeConst): New decls. (_Jv_UnregisterClass): New decl. * java/lang/natClassLoader.cc (_Jv_FindArrayClass): Added class loader argument. (_Jv_FindClass): Use class loader. * prims.cc (_Jv_makeUtf8Const): New function. (_Jv_NewObjectArray): Change use of _Jv_FindArrayClass. (_Jv_NewPrimArray): Ditto. (_Jv_FindClassFromSignature): Ditto. * java/lang/reflect/natArray.cc (newInstance): Ditto. * java/lang/reflect/natMethod.cc (getType): Ditto. * include/java-field.h (_Jv_Field::isRef): Make robust for non-resolved contexts. * boehm.cc (_Jv_MarkObj): Mark interpreter-related fields. Also, don't mark class->next field. * java/lang/VirtualMachineError.java: Added FIXME note. * configure.in (INTERPSPEC): New spec. * libgcj.spec.in: Added INTERPSPEC. * Makefile.am: Added gcjh friends for java/lang/VMClassLoader and gnu/gcj/runtime/MethodInvocation. (libgcj_la_SOURCES): Added resolve.cc defineclass.cc interpret.cc. (ordinary_java_source_files): Added above mentioned java classes. * configure: Rebuilt. * Makefile.in: Rebuilt. From-SVN: r28597
1999-08-08 16:06:23 +02:00
java::lang::Class::finalize (void)
1999-04-07 16:42:40 +02:00
{
engine->unregister(this);
1999-04-07 16:42:40 +02:00
}
configure.ac (INTERPRETER): New AM_CONDITIONAL. * configure.ac (INTERPRETER): New AM_CONDITIONAL. * scripts/makemake.tcl (package_map): Mark jdwp and jvmti packages as being for interpreter only. Place interpreter related files in 'if INTERPRETER' block. (interpreter_package_files): New list. (interpreter_header_vars): Ditto. (emit_package_rule_to_list): Renamed from emit_package_rule with new target list parameter. (emit_package_rule): Rewritten to call emit_package_rule_to_list. (emit_interpreter_rule): New function. (emit_source_var): Place interpreter related files in interpreter_header_vars. * Makefile.am (ACLOCAL_AMFLAGS): Add -I libltdl. (libgcj_interpret_source_files): New variable. (libgcj_la_SOURCES): Move jvmti.cc and interpret.cc to libgcj_interpret_source_files and include libgcj_interpret_source_files. (nat_jdwp_source_files): New variable. (nat_jvmti_source_files): Ditto. (nat_source_files): Move jdwp and jvmti related files to nat_jdwp_source_files and nat_jvmti_source_files and include nat_jdwp_source_files and nat_jvmti_source_files. * Makefile.in: Regenerate. * include/Makefile.in: Ditto. * testsuite/Makefile.in: Ditto. * gcj/Makefile.in: Ditto. * sources.am: Ditto. * configure: Ditto. * include/config.h.in: Ditto. * interpret.cc: Remove #ifdef INTERPRETER block. * stacktrace.cc (UnwindTraceFn): Do not handle proxy frames if interpreter disabled. * include/java-interp.h (_Jv_FrameType): Move outside of #ifdef INTERPRETER block. * include/execution.h (_Jv_IndirectCompiledEngine::do_get_closure_list, _Jv_InterpreterEngine, _Jv_soleInterpreterEngine): Place in #ifdef INTERPRETER block. * jni.cc (jvmti.h, jvmti-int.h): Only include if INTERPRETER is defined. (_Jv_JNI_PopSystemFrame, _Jv_JNI_GetEnv): Only do jvmti processing if INTERPRETER is defined. * prims.cc (jvmti.h, jvmti-int.h, Jdwp.h, VMVirtualMachine.h): Only include if INTERPRETER is defined. (defaultJdwpOptions, jdwpOptions, jvmti_agent_onload_func, jvmti_agent_onunload_func, jvmti_agentonload, jvmti_agentonunload, jvmti_agent_opts, load_jvmti_agent): Only define if INTERPRETER is defined. (parse_x_arg): Only process 'runjdwp:' if INTERPRETER is defined. (parse_init_args): Only process jvmti related options if INTERPRETER is defined. (_Jv_CreateJavaVM): Only call _Jv_JVMTI_Init if INTERPRETER is defined. (_Jv_RunMain): Only do jvmti and jdwp processing if INTERPRETER is defined. * link.cc (jvmti.h, jvmti-int.h): Only include if INTERPRETER is defined. (_Jv_ThrowNoClassDefFoundError, _Jv_Linker::create_error_method): Define if if INTERPRETER is not defined. (_Jv_Linker::wait_for_state): Only do jvmti proccessing if INTERPRETER is defined. * boehm.cc (closure_list_pointer, finalize_closure_list, _Jv_ClosureListFinalizer): Only define if INTERPRETER is defined. * java/lang/natThread.cc (jvmti.h, jvmti-int.h): Only include if INTERPRETER is defined. (finish_, _Jv_NotifyThreadStart): Only do jvmti proccessing if INTERPRETER is defined. * java/lang/Class.h (_Jv_InterpreterEngine): Move declaration and friend declaration inside #ifdef INTERPRETER block. * java/lang/natClass.cc (_Jv_ClosureList::releaseClosures, _Jv_ClosureList::registerClosure, _Jv_GetInterpClassSourceFile): Only define if INTERPRETER is defined. * java/lang/reflect/natVMProxy.cc (UnsupportedOperationException.h): Include. (generateProxyClass): Throw UnsupportedOperationException unless INTERPRETER is defined. From-SVN: r127097
2007-07-31 18:17:21 +02:00
#ifdef INTERPRETER
ffi.h.in (ffi_closure_alloc, [...]): New. libffi/ChangeLog: * include/ffi.h.in (ffi_closure_alloc, ffi_closure_free): New. (ffi_prep_closure_loc): New. (ffi_prep_raw_closure_loc): New. (ffi_prep_java_raw_closure_loc): New. * src/closures.c: New file. * src/dlmalloc.c [FFI_MMAP_EXEC_WRIT] (struct malloc_segment): Replace sflags with exec_offset. [FFI_MMAP_EXEC_WRIT] (mmap_exec_offset, add_segment_exec_offset, sub_segment_exec_offset): New macros. (get_segment_flags, set_segment_flags, check_segment_merge): New macros. (is_mmapped_segment, is_extern_segment): Use get_segment_flags. (add_segment, sys_alloc, create_mspace, create_mspace_with_base, destroy_mspace): Use new macros. (sys_alloc): Silence warning. * Makefile.am (libffi_la_SOURCES): Add src/closures.c. * Makefile.in: Rebuilt. * src/prep_cif [FFI_CLOSURES] (ffi_prep_closure): Implement in terms of ffi_prep_closure_loc. * src/raw_api.c (ffi_prep_raw_closure_loc): Renamed and adjusted from... (ffi_prep_raw_closure): ... this. Re-implement in terms of the renamed version. * src/java_raw_api (ffi_prep_java_raw_closure_loc): Renamed and adjusted from... (ffi_prep_java_raw_closure): ... this. Re-implement in terms of the renamed version. * src/alpha/ffi.c (ffi_prep_closure_loc): Renamed from (ffi_prep_closure): ... this. * src/pa/ffi.c: Likewise. * src/cris/ffi.c: Likewise. Adjust. * src/frv/ffi.c: Likewise. * src/ia64/ffi.c: Likewise. * src/mips/ffi.c: Likewise. * src/powerpc/ffi_darwin.c: Likewise. * src/s390/ffi.c: Likewise. * src/sh/ffi.c: Likewise. * src/sh64/ffi.c: Likewise. * src/sparc/ffi.c: Likewise. * src/x86/ffi64.c: Likewise. * src/x86/ffi.c: Likewise. (FFI_INIT_TRAMPOLINE): Adjust. (ffi_prep_raw_closure_loc): Renamed and adjusted from... (ffi_prep_raw_closure): ... this. * src/powerpc/ffi.c (ffi_prep_closure_loc): Renamed from (ffi_prep_closure): ... this. (flush_icache): Adjust. boehm-gc/ChangeLog: * include/gc.h (GC_REGISTER_FINALIZER_UNREACHABLE): New. (GC_register_finalizer_unreachable): Declare. (GC_debug_register_finalizer_unreachable): Declare. * finalize.c (GC_unreachable_finalize_mark_proc): New. (GC_register_finalizer_unreachable): New. (GC_finalize): Handle it. * dbg_mlc.c (GC_debug_register_finalizer_unreachable): New. (GC_debug_register_finalizer_no_order): Fix whitespace. libjava/ChangeLog: * include/jvm.h (_Jv_ClosureListFinalizer): New. (_Jv_Linker::create_error_method): Adjust. * boehm.cc (_Jv_ClosureListFinalizer): New. * nogc.cc (_Jv_ClosureListFinalizer): New. * java/lang/Class.h (class _Jv_ClosureList): New. (class java::lang::Class): Declare it as friend. * java/lang/natClass.cc (_Jv_ClosureList::releaseClosures): New. (_Jv_ClosureList::registerClousure): New. * include/execution.h (_Jv_ExecutionEngine): Add get_closure_list. (_Jv_CompiledEngine::do_get_closure_list): New. (_Jv_CompiledEngine::_Jv_CompiledEngine): Use it. (_Jv_IndirectCompiledClass): Add closures. (_Jv_IndirectCompiledEngine::get_aux_info): New. (_Jv_IndirectCompiledEngine::do_allocate_field_initializers): Use it. (_Jv_IndirectCompiledEngine::do_get_closure_list): New. (_Jv_IndirectCompiledEngine::_Jv_IndirectCompiledEngine): Use it. (_Jv_InterpreterEngine::do_get_closure_list): Declare. (_Jv_InterpreterEngine::_Jv_InterpreterEngine): Use it. * interpret.cc (FFI_PREP_RAW_CLOSURE): Use _loc variants. (node_closure): Add closure list. (_Jv_InterpMethod::ncode): Add jclass argument. Use ffi_closure_alloc and the separate code pointer. Register the closure for finalization. (_Jv_JNIMethod::ncode): Likewise. (_Jv_InterpreterEngine::do_create_ncode): Pass klass to ncode. (_Jv_InterpreterEngine::do_get_closure_list): New. * include/java-interp.h (_Jv_InterpMethod::ncode): Adjust. (_Jv_InterpClass): Add closures field. (_Jv_JNIMethod::ncode): Adjust. * defineclass.cc (_Jv_ClassReader::handleCodeAttribute): Adjust. (_Jv_ClassReader::handleMethodsEnd): Likewise. * link.cc (struct method_closure): Add closure list. (_Jv_Linker::create_error_method): Add jclass argument. Use ffi_closure_alloc and the separate code pointer. Register the closure for finalization. (_Jv_Linker::link_symbol_table): Remove outdated comment about sharing of otable and atable. Adjust. * java/lang/reflect/natVMProxy.cc (ncode_closure): Add closure list. (ncode): Add jclass argument. Use ffi_closure_alloc and the separate code pointer. Register the closure for finalization. (java::lang::reflect::VMProxy::generateProxyClass): Adjust. * testsuite/libjava.jar/TestClosureGC.java: New. * testsuite/libjava.jar/TestClosureGC.out: New. * testsuite/libjava.jar/TestClosureGC.xfail: New. * testsuite/libjava.jar/TestClosureGC.jar: New. From-SVN: r122652
2007-03-07 08:27:25 +01:00
void
_Jv_ClosureList::releaseClosures (_Jv_ClosureList **closures)
{
if (!closures)
return;
while (_Jv_ClosureList *current = *closures)
{
*closures = current->next;
ffi_closure_free (current->ptr);
}
}
void
_Jv_ClosureList::registerClosure (jclass klass, void *ptr)
{
_Jv_ClosureList **closures = klass->engine->get_closure_list (klass);
this->ptr = ptr;
this->next = *closures;
*closures = this;
}
configure.ac (INTERPRETER): New AM_CONDITIONAL. * configure.ac (INTERPRETER): New AM_CONDITIONAL. * scripts/makemake.tcl (package_map): Mark jdwp and jvmti packages as being for interpreter only. Place interpreter related files in 'if INTERPRETER' block. (interpreter_package_files): New list. (interpreter_header_vars): Ditto. (emit_package_rule_to_list): Renamed from emit_package_rule with new target list parameter. (emit_package_rule): Rewritten to call emit_package_rule_to_list. (emit_interpreter_rule): New function. (emit_source_var): Place interpreter related files in interpreter_header_vars. * Makefile.am (ACLOCAL_AMFLAGS): Add -I libltdl. (libgcj_interpret_source_files): New variable. (libgcj_la_SOURCES): Move jvmti.cc and interpret.cc to libgcj_interpret_source_files and include libgcj_interpret_source_files. (nat_jdwp_source_files): New variable. (nat_jvmti_source_files): Ditto. (nat_source_files): Move jdwp and jvmti related files to nat_jdwp_source_files and nat_jvmti_source_files and include nat_jdwp_source_files and nat_jvmti_source_files. * Makefile.in: Regenerate. * include/Makefile.in: Ditto. * testsuite/Makefile.in: Ditto. * gcj/Makefile.in: Ditto. * sources.am: Ditto. * configure: Ditto. * include/config.h.in: Ditto. * interpret.cc: Remove #ifdef INTERPRETER block. * stacktrace.cc (UnwindTraceFn): Do not handle proxy frames if interpreter disabled. * include/java-interp.h (_Jv_FrameType): Move outside of #ifdef INTERPRETER block. * include/execution.h (_Jv_IndirectCompiledEngine::do_get_closure_list, _Jv_InterpreterEngine, _Jv_soleInterpreterEngine): Place in #ifdef INTERPRETER block. * jni.cc (jvmti.h, jvmti-int.h): Only include if INTERPRETER is defined. (_Jv_JNI_PopSystemFrame, _Jv_JNI_GetEnv): Only do jvmti processing if INTERPRETER is defined. * prims.cc (jvmti.h, jvmti-int.h, Jdwp.h, VMVirtualMachine.h): Only include if INTERPRETER is defined. (defaultJdwpOptions, jdwpOptions, jvmti_agent_onload_func, jvmti_agent_onunload_func, jvmti_agentonload, jvmti_agentonunload, jvmti_agent_opts, load_jvmti_agent): Only define if INTERPRETER is defined. (parse_x_arg): Only process 'runjdwp:' if INTERPRETER is defined. (parse_init_args): Only process jvmti related options if INTERPRETER is defined. (_Jv_CreateJavaVM): Only call _Jv_JVMTI_Init if INTERPRETER is defined. (_Jv_RunMain): Only do jvmti and jdwp processing if INTERPRETER is defined. * link.cc (jvmti.h, jvmti-int.h): Only include if INTERPRETER is defined. (_Jv_ThrowNoClassDefFoundError, _Jv_Linker::create_error_method): Define if if INTERPRETER is not defined. (_Jv_Linker::wait_for_state): Only do jvmti proccessing if INTERPRETER is defined. * boehm.cc (closure_list_pointer, finalize_closure_list, _Jv_ClosureListFinalizer): Only define if INTERPRETER is defined. * java/lang/natThread.cc (jvmti.h, jvmti-int.h): Only include if INTERPRETER is defined. (finish_, _Jv_NotifyThreadStart): Only do jvmti proccessing if INTERPRETER is defined. * java/lang/Class.h (_Jv_InterpreterEngine): Move declaration and friend declaration inside #ifdef INTERPRETER block. * java/lang/natClass.cc (_Jv_ClosureList::releaseClosures, _Jv_ClosureList::registerClosure, _Jv_GetInterpClassSourceFile): Only define if INTERPRETER is defined. * java/lang/reflect/natVMProxy.cc (UnsupportedOperationException.h): Include. (generateProxyClass): Throw UnsupportedOperationException unless INTERPRETER is defined. From-SVN: r127097
2007-07-31 18:17:21 +02:00
#endif
ffi.h.in (ffi_closure_alloc, [...]): New. libffi/ChangeLog: * include/ffi.h.in (ffi_closure_alloc, ffi_closure_free): New. (ffi_prep_closure_loc): New. (ffi_prep_raw_closure_loc): New. (ffi_prep_java_raw_closure_loc): New. * src/closures.c: New file. * src/dlmalloc.c [FFI_MMAP_EXEC_WRIT] (struct malloc_segment): Replace sflags with exec_offset. [FFI_MMAP_EXEC_WRIT] (mmap_exec_offset, add_segment_exec_offset, sub_segment_exec_offset): New macros. (get_segment_flags, set_segment_flags, check_segment_merge): New macros. (is_mmapped_segment, is_extern_segment): Use get_segment_flags. (add_segment, sys_alloc, create_mspace, create_mspace_with_base, destroy_mspace): Use new macros. (sys_alloc): Silence warning. * Makefile.am (libffi_la_SOURCES): Add src/closures.c. * Makefile.in: Rebuilt. * src/prep_cif [FFI_CLOSURES] (ffi_prep_closure): Implement in terms of ffi_prep_closure_loc. * src/raw_api.c (ffi_prep_raw_closure_loc): Renamed and adjusted from... (ffi_prep_raw_closure): ... this. Re-implement in terms of the renamed version. * src/java_raw_api (ffi_prep_java_raw_closure_loc): Renamed and adjusted from... (ffi_prep_java_raw_closure): ... this. Re-implement in terms of the renamed version. * src/alpha/ffi.c (ffi_prep_closure_loc): Renamed from (ffi_prep_closure): ... this. * src/pa/ffi.c: Likewise. * src/cris/ffi.c: Likewise. Adjust. * src/frv/ffi.c: Likewise. * src/ia64/ffi.c: Likewise. * src/mips/ffi.c: Likewise. * src/powerpc/ffi_darwin.c: Likewise. * src/s390/ffi.c: Likewise. * src/sh/ffi.c: Likewise. * src/sh64/ffi.c: Likewise. * src/sparc/ffi.c: Likewise. * src/x86/ffi64.c: Likewise. * src/x86/ffi.c: Likewise. (FFI_INIT_TRAMPOLINE): Adjust. (ffi_prep_raw_closure_loc): Renamed and adjusted from... (ffi_prep_raw_closure): ... this. * src/powerpc/ffi.c (ffi_prep_closure_loc): Renamed from (ffi_prep_closure): ... this. (flush_icache): Adjust. boehm-gc/ChangeLog: * include/gc.h (GC_REGISTER_FINALIZER_UNREACHABLE): New. (GC_register_finalizer_unreachable): Declare. (GC_debug_register_finalizer_unreachable): Declare. * finalize.c (GC_unreachable_finalize_mark_proc): New. (GC_register_finalizer_unreachable): New. (GC_finalize): Handle it. * dbg_mlc.c (GC_debug_register_finalizer_unreachable): New. (GC_debug_register_finalizer_no_order): Fix whitespace. libjava/ChangeLog: * include/jvm.h (_Jv_ClosureListFinalizer): New. (_Jv_Linker::create_error_method): Adjust. * boehm.cc (_Jv_ClosureListFinalizer): New. * nogc.cc (_Jv_ClosureListFinalizer): New. * java/lang/Class.h (class _Jv_ClosureList): New. (class java::lang::Class): Declare it as friend. * java/lang/natClass.cc (_Jv_ClosureList::releaseClosures): New. (_Jv_ClosureList::registerClousure): New. * include/execution.h (_Jv_ExecutionEngine): Add get_closure_list. (_Jv_CompiledEngine::do_get_closure_list): New. (_Jv_CompiledEngine::_Jv_CompiledEngine): Use it. (_Jv_IndirectCompiledClass): Add closures. (_Jv_IndirectCompiledEngine::get_aux_info): New. (_Jv_IndirectCompiledEngine::do_allocate_field_initializers): Use it. (_Jv_IndirectCompiledEngine::do_get_closure_list): New. (_Jv_IndirectCompiledEngine::_Jv_IndirectCompiledEngine): Use it. (_Jv_InterpreterEngine::do_get_closure_list): Declare. (_Jv_InterpreterEngine::_Jv_InterpreterEngine): Use it. * interpret.cc (FFI_PREP_RAW_CLOSURE): Use _loc variants. (node_closure): Add closure list. (_Jv_InterpMethod::ncode): Add jclass argument. Use ffi_closure_alloc and the separate code pointer. Register the closure for finalization. (_Jv_JNIMethod::ncode): Likewise. (_Jv_InterpreterEngine::do_create_ncode): Pass klass to ncode. (_Jv_InterpreterEngine::do_get_closure_list): New. * include/java-interp.h (_Jv_InterpMethod::ncode): Adjust. (_Jv_InterpClass): Add closures field. (_Jv_JNIMethod::ncode): Adjust. * defineclass.cc (_Jv_ClassReader::handleCodeAttribute): Adjust. (_Jv_ClassReader::handleMethodsEnd): Likewise. * link.cc (struct method_closure): Add closure list. (_Jv_Linker::create_error_method): Add jclass argument. Use ffi_closure_alloc and the separate code pointer. Register the closure for finalization. (_Jv_Linker::link_symbol_table): Remove outdated comment about sharing of otable and atable. Adjust. * java/lang/reflect/natVMProxy.cc (ncode_closure): Add closure list. (ncode): Add jclass argument. Use ffi_closure_alloc and the separate code pointer. Register the closure for finalization. (java::lang::reflect::VMProxy::generateProxyClass): Adjust. * testsuite/libjava.jar/TestClosureGC.java: New. * testsuite/libjava.jar/TestClosureGC.out: New. * testsuite/libjava.jar/TestClosureGC.xfail: New. * testsuite/libjava.jar/TestClosureGC.jar: New. From-SVN: r122652
2007-03-07 08:27:25 +01:00
1999-04-07 16:42:40 +02:00
// This implements the initialization process for a class. From Spec
// section 12.4.2.
void
java::lang::Class::initializeClass (void)
{
// Short-circuit to avoid needless locking (expression includes
// JV_STATE_PHANTOM and JV_STATE_DONE).
if (state >= JV_STATE_PHANTOM)
1999-04-07 16:42:40 +02:00
return;
// Step 1. We introduce a new scope so we can synchronize more
// easily.
{
JvSynchronize sync (this);
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
if (state < JV_STATE_LINKED)
{
try
{
_Jv_Linker::wait_for_state(this, JV_STATE_LINKED);
}
catch (java::lang::SecurityException *x)
{
throw x;
}
catch (java::lang::Throwable *x)
{
// Turn into a NoClassDefFoundError.
java::lang::NoClassDefFoundError *result
= new java::lang::NoClassDefFoundError(getName());
result->initCause(x);
throw result;
}
}
// Step 2.
java::lang::Thread *self = java::lang::Thread::currentThread();
self = (java::lang::Thread *) ((long) self | 1);
while (state == JV_STATE_IN_PROGRESS && thread && thread != self)
wait ();
// Steps 3 & 4.
if (state == JV_STATE_DONE || state == JV_STATE_IN_PROGRESS)
return;
1999-04-07 16:42:40 +02:00
// Step 5.
if (state == JV_STATE_ERROR)
throw new java::lang::NoClassDefFoundError (getName());
1999-04-07 16:42:40 +02:00
// Step 6.
thread = self;
_Jv_Linker::wait_for_state (this, JV_STATE_LINKED);
state = JV_STATE_IN_PROGRESS;
}
1999-04-07 16:42:40 +02:00
// Step 7.
if (! isInterface () && superclass)
{
java-interp.h: Don't include MethodInvocation.h. * include/java-interp.h: Don't include MethodInvocation.h. (class _Jv_InterpMethod): Don't make MethodInvocation a friend. * Makefile.in: Rebuilt. * Makefile.am (gnu/gcj/runtime/MethodInvocation.h): Removed. (ordinary_java_source_files): Don't mention MethodInvocation.java. * gnu/gcj/runtime/MethodInvocation.java: Removed. * interpret.cc (MethodInvocation::continue1): Removed. (run): Handle exceptions here. * java/lang/ClassLoader.java (defineClass1, defineClass2): Removed. * java/lang/natClassLoader.cc (defineClass0): Catch exceptions here. (defineClass2): Removed. * java/lang/reflect/Method.java (hack_trampoline, hack_call): Removed. * java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA): Catch exceptions here. (hack_call): Removed. * java/lang/Class.h (Class): Removed hackRunInitializers, hackTrampoline. * java/lang/natClass.cc (hackRunInitializers): Removed. (initializeClass): Catch exceptions here. Include ExceptionInInitializerError.h. * java/lang/Class.java (hackTrampoline, hackRunInitializers): Removed. * java/lang/Object.h (Object): Don't mention hack12_6. * java/lang/natObject.cc (_Jv_FinalizeObject): Catch exceptions here. * java/lang/Object.java (hack12_6): Removed. * java/lang/natThread.cc (run_): Renamed. Catch exceptions here. (start): Use run_, not run__. * java/lang/Thread.java (run_): Renamed from run__; old run_ removed. * jni.cc (_Jv_JNI_FindClass): Handle exceptions. (_Jv_JNI_EnsureLocalCapacity): Likewise. (_Jv_JNI_DefineClass): Likewise. (_Jv_JNI_ThrowNew): Likewise. (_Jv_JNI_AllocObject): Likewise. (_Jv_JNI_GetAnyMethodID): Likewise. (_Jv_JNI_CallAnyMethodV): Likewise. (_Jv_JNI_CallAnyMethodA): Likewise. (_Jv_JNI_CallAnyVoidMethodV): Likewise. (_Jv_JNI_CallAnyVoidMethodA): Likewise. (_Jv_JNI_GetAnyFieldID): Likewise. (_Jv_JNI_NewString): Likewise. (_Jv_JNI_NewStringUTF): Likewise. (_Jv_JNI_GetStringUTFChars): Likewise. (_Jv_JNI_NewObjectArray): Likewise. (_Jv_JNI_NewPrimitiveArray): Likewise. (_Jv_JNI_GetPrimitiveArrayRegion): Likewise. (_Jv_JNI_GetStringRegion): Likewise. (_Jv_JNI_GetStringUTFRegion): Likewise. (_Jv_JNI_SetPrimitiveArrayRegion): Likewise. (_Jv_JNI_MonitorEnter): Likewise. (_Jv_JNI_MonitorExit): Likewise. (_Jv_JNI_ToReflectedField): Likewise. (_Jv_JNI_ToReflectedMethod): Likewise. (_Jv_JNI_RegisterNatives): Likewise. (_Jv_JNI_AttachCurrentThread): Likewise. (_Jv_JNI_DestroyJavaVM): Likewise. From-SVN: r32294
2000-03-02 21:25:20 +01:00
try
{
_Jv_InitClass (superclass);
java-interp.h: Don't include MethodInvocation.h. * include/java-interp.h: Don't include MethodInvocation.h. (class _Jv_InterpMethod): Don't make MethodInvocation a friend. * Makefile.in: Rebuilt. * Makefile.am (gnu/gcj/runtime/MethodInvocation.h): Removed. (ordinary_java_source_files): Don't mention MethodInvocation.java. * gnu/gcj/runtime/MethodInvocation.java: Removed. * interpret.cc (MethodInvocation::continue1): Removed. (run): Handle exceptions here. * java/lang/ClassLoader.java (defineClass1, defineClass2): Removed. * java/lang/natClassLoader.cc (defineClass0): Catch exceptions here. (defineClass2): Removed. * java/lang/reflect/Method.java (hack_trampoline, hack_call): Removed. * java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA): Catch exceptions here. (hack_call): Removed. * java/lang/Class.h (Class): Removed hackRunInitializers, hackTrampoline. * java/lang/natClass.cc (hackRunInitializers): Removed. (initializeClass): Catch exceptions here. Include ExceptionInInitializerError.h. * java/lang/Class.java (hackTrampoline, hackRunInitializers): Removed. * java/lang/Object.h (Object): Don't mention hack12_6. * java/lang/natObject.cc (_Jv_FinalizeObject): Catch exceptions here. * java/lang/Object.java (hack12_6): Removed. * java/lang/natThread.cc (run_): Renamed. Catch exceptions here. (start): Use run_, not run__. * java/lang/Thread.java (run_): Renamed from run__; old run_ removed. * jni.cc (_Jv_JNI_FindClass): Handle exceptions. (_Jv_JNI_EnsureLocalCapacity): Likewise. (_Jv_JNI_DefineClass): Likewise. (_Jv_JNI_ThrowNew): Likewise. (_Jv_JNI_AllocObject): Likewise. (_Jv_JNI_GetAnyMethodID): Likewise. (_Jv_JNI_CallAnyMethodV): Likewise. (_Jv_JNI_CallAnyMethodA): Likewise. (_Jv_JNI_CallAnyVoidMethodV): Likewise. (_Jv_JNI_CallAnyVoidMethodA): Likewise. (_Jv_JNI_GetAnyFieldID): Likewise. (_Jv_JNI_NewString): Likewise. (_Jv_JNI_NewStringUTF): Likewise. (_Jv_JNI_GetStringUTFChars): Likewise. (_Jv_JNI_NewObjectArray): Likewise. (_Jv_JNI_NewPrimitiveArray): Likewise. (_Jv_JNI_GetPrimitiveArrayRegion): Likewise. (_Jv_JNI_GetStringRegion): Likewise. (_Jv_JNI_GetStringUTFRegion): Likewise. (_Jv_JNI_SetPrimitiveArrayRegion): Likewise. (_Jv_JNI_MonitorEnter): Likewise. (_Jv_JNI_MonitorExit): Likewise. (_Jv_JNI_ToReflectedField): Likewise. (_Jv_JNI_ToReflectedMethod): Likewise. (_Jv_JNI_RegisterNatives): Likewise. (_Jv_JNI_AttachCurrentThread): Likewise. (_Jv_JNI_DestroyJavaVM): Likewise. From-SVN: r32294
2000-03-02 21:25:20 +01:00
}
catch (java::lang::SecurityException *x)
{
throw x;
}
java-interp.h: Don't include MethodInvocation.h. * include/java-interp.h: Don't include MethodInvocation.h. (class _Jv_InterpMethod): Don't make MethodInvocation a friend. * Makefile.in: Rebuilt. * Makefile.am (gnu/gcj/runtime/MethodInvocation.h): Removed. (ordinary_java_source_files): Don't mention MethodInvocation.java. * gnu/gcj/runtime/MethodInvocation.java: Removed. * interpret.cc (MethodInvocation::continue1): Removed. (run): Handle exceptions here. * java/lang/ClassLoader.java (defineClass1, defineClass2): Removed. * java/lang/natClassLoader.cc (defineClass0): Catch exceptions here. (defineClass2): Removed. * java/lang/reflect/Method.java (hack_trampoline, hack_call): Removed. * java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA): Catch exceptions here. (hack_call): Removed. * java/lang/Class.h (Class): Removed hackRunInitializers, hackTrampoline. * java/lang/natClass.cc (hackRunInitializers): Removed. (initializeClass): Catch exceptions here. Include ExceptionInInitializerError.h. * java/lang/Class.java (hackTrampoline, hackRunInitializers): Removed. * java/lang/Object.h (Object): Don't mention hack12_6. * java/lang/natObject.cc (_Jv_FinalizeObject): Catch exceptions here. * java/lang/Object.java (hack12_6): Removed. * java/lang/natThread.cc (run_): Renamed. Catch exceptions here. (start): Use run_, not run__. * java/lang/Thread.java (run_): Renamed from run__; old run_ removed. * jni.cc (_Jv_JNI_FindClass): Handle exceptions. (_Jv_JNI_EnsureLocalCapacity): Likewise. (_Jv_JNI_DefineClass): Likewise. (_Jv_JNI_ThrowNew): Likewise. (_Jv_JNI_AllocObject): Likewise. (_Jv_JNI_GetAnyMethodID): Likewise. (_Jv_JNI_CallAnyMethodV): Likewise. (_Jv_JNI_CallAnyMethodA): Likewise. (_Jv_JNI_CallAnyVoidMethodV): Likewise. (_Jv_JNI_CallAnyVoidMethodA): Likewise. (_Jv_JNI_GetAnyFieldID): Likewise. (_Jv_JNI_NewString): Likewise. (_Jv_JNI_NewStringUTF): Likewise. (_Jv_JNI_GetStringUTFChars): Likewise. (_Jv_JNI_NewObjectArray): Likewise. (_Jv_JNI_NewPrimitiveArray): Likewise. (_Jv_JNI_GetPrimitiveArrayRegion): Likewise. (_Jv_JNI_GetStringRegion): Likewise. (_Jv_JNI_GetStringUTFRegion): Likewise. (_Jv_JNI_SetPrimitiveArrayRegion): Likewise. (_Jv_JNI_MonitorEnter): Likewise. (_Jv_JNI_MonitorExit): Likewise. (_Jv_JNI_ToReflectedField): Likewise. (_Jv_JNI_ToReflectedMethod): Likewise. (_Jv_JNI_RegisterNatives): Likewise. (_Jv_JNI_AttachCurrentThread): Likewise. (_Jv_JNI_DestroyJavaVM): Likewise. From-SVN: r32294
2000-03-02 21:25:20 +01:00
catch (java::lang::Throwable *except)
1999-04-07 16:42:40 +02:00
{
// Caught an exception.
JvSynchronize sync (this);
[multiple changes] 1999-08-09 Anthony Green <green@cygnus.com> * gij.cc: New file. * include/config.h.in: Rebuilt. * acconfig.h: Add INTERPRETER. * configure: Rebuilt. * Makefile.in: Rebuilt. * Makefile.am (libffi_files): Identify the libffi object files for inclusion in libgcj. (LIBFFIINCS): Define. * interpret.cc (gnu::gcj::runtime::MethodInvocation::continue1): Dummy definition for configurations without an interpreter. * java/net/natPlainSocketImpl.cc (getOption): Disamiguate call to java::lang::Boolean constructor. * include/java-interp.h: Always include java-cpool.h. * java/lang/natClassLoader.cc (getVMClassLoader0): Always return 0 when INTERPRETER not defined. * java/lang/Class.h (finalize): Define. * gnu/gcj/util/path/DirectoryPathEntry.java (getURL): Catch IOException from File.getCanonicalPath. (getStream): Likewise. * NEWS: More news. * THANKS: More thanks. 1999-08-09 Kresten Krab Thorup <krab@gnu.org> * resolve.cc (get_ffi_type_from_signature): Generate uint16 for jchar type. (_Jv_PrepareClass): Allow non-abstract classes to have abstract subclasses. (_Jv_ResolvePoolEntry): Revert subclass check for protected fields and methods. * interpret.cc (continue1/perform_invoke): Don't sign extend uint16 return val. (continue1/lshl,lshr): Push long, not int. (continue1/ulshr): Use UINT64, not long long. * defineclass.cc (handleFieldsEnd): Handle case when all fields are static. * java/lang/natClass.cc (forName): Add call to _Jv_InitClass. * java/lang/FirstThread.java (run): Add top-level exception handler. (run0): Renamed from run. 1999-08-08 Kresten Krab Thorup <krab@gnu.org> * configure.in (--with-interpreter): Added. * include/config.h.in (INTERPRETER): Added. * java/lang/ClassLoader.java: File replaced. * java/lang/VMClassLoader.java: New file. * java/lang/natClassLoader.cc: New file. * gnu/gcj/runtime/MethodInvocation.java: New file. * gnu/gcj/util/path/SearchPath.java: New file. * gnu/gcj/util/path/PathEntry.java: New file. * gnu/gcj/util/path/DirectoryPathEntry.java: New file. * gnu/gcj/util/path/ZipPathEntry.java: New file. * gnu/gcj/util/path/URLPathEntry.java: New file. * gnu/gcj/util/path/CacheEntry.java: New file. * include/java-interp.h: New file. * include/java-cpool.h: New file. * include/java-insns.h: New file. * defineclass.cc: New file. * interpret.cc: New file. * resolve.cc: New file. * java/lang/natClass.cc (loaded_classes, _Jv_RegisterClass, _Jv_RegisterClasses, _Jv_FindClassInCache, _Jv_FindClass, _Jv_NewClass, _Jv_FindArrayClass): Moved to natClassLoader.cc. (finalize): New. (STATE_NOTHING, STATE_RESOLVED, STATE_IN_PROGRESS, STATE_DONE, STATE_ERROR): Moved to java/lang/Class.h and renamed with JV_ prefix. (initializeClass): Use new JV_ prefixed names. Also, call ClassLoader::resolveClass instead of _Jv_ResolveClass. * java/lang/Class.h (JV_STATE_PRELOADING, JV_STATE_LOADING, JV_STATE_LOADED, JV_STATE_COMPILED, JV_STATE_PREPARED, JV_STATE_LINKED): New. (_Jv_WaitForState, _Jv_RegisterInitiatingLoader, _Jv_UnregisterClass, _Jv_InternClassStrings): New friends. (_Jv_IsInterpretedClass, _Jv_InitField, _Jv_LookupDeclaredMethod, _Jv_DetermineVTableIndex, _Jv_ResolvePoolEntry, _Jv_PrepareClass, _Jv_ClassReader, _Jv_InterpClass, _Jv_InterpMethod, _Jv_InterpMethodInvocation): New friends for interpreter. (finalize): New. (CONSTANT_Class, CONSTANT_String, etc.): Moved to include/java-cpool.h and renamed with JV_ prefix. * include/jvm.h (_Jv_makeUtf8Const, _Jv_makeUtf8TypeConst): New decls. (_Jv_UnregisterClass): New decl. * java/lang/natClassLoader.cc (_Jv_FindArrayClass): Added class loader argument. (_Jv_FindClass): Use class loader. * prims.cc (_Jv_makeUtf8Const): New function. (_Jv_NewObjectArray): Change use of _Jv_FindArrayClass. (_Jv_NewPrimArray): Ditto. (_Jv_FindClassFromSignature): Ditto. * java/lang/reflect/natArray.cc (newInstance): Ditto. * java/lang/reflect/natMethod.cc (getType): Ditto. * include/java-field.h (_Jv_Field::isRef): Make robust for non-resolved contexts. * boehm.cc (_Jv_MarkObj): Mark interpreter-related fields. Also, don't mark class->next field. * java/lang/VirtualMachineError.java: Added FIXME note. * configure.in (INTERPSPEC): New spec. * libgcj.spec.in: Added INTERPSPEC. * Makefile.am: Added gcjh friends for java/lang/VMClassLoader and gnu/gcj/runtime/MethodInvocation. (libgcj_la_SOURCES): Added resolve.cc defineclass.cc interpret.cc. (ordinary_java_source_files): Added above mentioned java classes. * configure: Rebuilt. * Makefile.in: Rebuilt. From-SVN: r28597
1999-08-08 16:06:23 +02:00
state = JV_STATE_ERROR;
notifyAll ();
java-interp.h: Don't include MethodInvocation.h. * include/java-interp.h: Don't include MethodInvocation.h. (class _Jv_InterpMethod): Don't make MethodInvocation a friend. * Makefile.in: Rebuilt. * Makefile.am (gnu/gcj/runtime/MethodInvocation.h): Removed. (ordinary_java_source_files): Don't mention MethodInvocation.java. * gnu/gcj/runtime/MethodInvocation.java: Removed. * interpret.cc (MethodInvocation::continue1): Removed. (run): Handle exceptions here. * java/lang/ClassLoader.java (defineClass1, defineClass2): Removed. * java/lang/natClassLoader.cc (defineClass0): Catch exceptions here. (defineClass2): Removed. * java/lang/reflect/Method.java (hack_trampoline, hack_call): Removed. * java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA): Catch exceptions here. (hack_call): Removed. * java/lang/Class.h (Class): Removed hackRunInitializers, hackTrampoline. * java/lang/natClass.cc (hackRunInitializers): Removed. (initializeClass): Catch exceptions here. Include ExceptionInInitializerError.h. * java/lang/Class.java (hackTrampoline, hackRunInitializers): Removed. * java/lang/Object.h (Object): Don't mention hack12_6. * java/lang/natObject.cc (_Jv_FinalizeObject): Catch exceptions here. * java/lang/Object.java (hack12_6): Removed. * java/lang/natThread.cc (run_): Renamed. Catch exceptions here. (start): Use run_, not run__. * java/lang/Thread.java (run_): Renamed from run__; old run_ removed. * jni.cc (_Jv_JNI_FindClass): Handle exceptions. (_Jv_JNI_EnsureLocalCapacity): Likewise. (_Jv_JNI_DefineClass): Likewise. (_Jv_JNI_ThrowNew): Likewise. (_Jv_JNI_AllocObject): Likewise. (_Jv_JNI_GetAnyMethodID): Likewise. (_Jv_JNI_CallAnyMethodV): Likewise. (_Jv_JNI_CallAnyMethodA): Likewise. (_Jv_JNI_CallAnyVoidMethodV): Likewise. (_Jv_JNI_CallAnyVoidMethodA): Likewise. (_Jv_JNI_GetAnyFieldID): Likewise. (_Jv_JNI_NewString): Likewise. (_Jv_JNI_NewStringUTF): Likewise. (_Jv_JNI_GetStringUTFChars): Likewise. (_Jv_JNI_NewObjectArray): Likewise. (_Jv_JNI_NewPrimitiveArray): Likewise. (_Jv_JNI_GetPrimitiveArrayRegion): Likewise. (_Jv_JNI_GetStringRegion): Likewise. (_Jv_JNI_GetStringUTFRegion): Likewise. (_Jv_JNI_SetPrimitiveArrayRegion): Likewise. (_Jv_JNI_MonitorEnter): Likewise. (_Jv_JNI_MonitorExit): Likewise. (_Jv_JNI_ToReflectedField): Likewise. (_Jv_JNI_ToReflectedMethod): Likewise. (_Jv_JNI_RegisterNatives): Likewise. (_Jv_JNI_AttachCurrentThread): Likewise. (_Jv_JNI_DestroyJavaVM): Likewise. From-SVN: r32294
2000-03-02 21:25:20 +01:00
throw except;
1999-04-07 16:42:40 +02:00
}
}
java-interp.h: Don't include MethodInvocation.h. * include/java-interp.h: Don't include MethodInvocation.h. (class _Jv_InterpMethod): Don't make MethodInvocation a friend. * Makefile.in: Rebuilt. * Makefile.am (gnu/gcj/runtime/MethodInvocation.h): Removed. (ordinary_java_source_files): Don't mention MethodInvocation.java. * gnu/gcj/runtime/MethodInvocation.java: Removed. * interpret.cc (MethodInvocation::continue1): Removed. (run): Handle exceptions here. * java/lang/ClassLoader.java (defineClass1, defineClass2): Removed. * java/lang/natClassLoader.cc (defineClass0): Catch exceptions here. (defineClass2): Removed. * java/lang/reflect/Method.java (hack_trampoline, hack_call): Removed. * java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA): Catch exceptions here. (hack_call): Removed. * java/lang/Class.h (Class): Removed hackRunInitializers, hackTrampoline. * java/lang/natClass.cc (hackRunInitializers): Removed. (initializeClass): Catch exceptions here. Include ExceptionInInitializerError.h. * java/lang/Class.java (hackTrampoline, hackRunInitializers): Removed. * java/lang/Object.h (Object): Don't mention hack12_6. * java/lang/natObject.cc (_Jv_FinalizeObject): Catch exceptions here. * java/lang/Object.java (hack12_6): Removed. * java/lang/natThread.cc (run_): Renamed. Catch exceptions here. (start): Use run_, not run__. * java/lang/Thread.java (run_): Renamed from run__; old run_ removed. * jni.cc (_Jv_JNI_FindClass): Handle exceptions. (_Jv_JNI_EnsureLocalCapacity): Likewise. (_Jv_JNI_DefineClass): Likewise. (_Jv_JNI_ThrowNew): Likewise. (_Jv_JNI_AllocObject): Likewise. (_Jv_JNI_GetAnyMethodID): Likewise. (_Jv_JNI_CallAnyMethodV): Likewise. (_Jv_JNI_CallAnyMethodA): Likewise. (_Jv_JNI_CallAnyVoidMethodV): Likewise. (_Jv_JNI_CallAnyVoidMethodA): Likewise. (_Jv_JNI_GetAnyFieldID): Likewise. (_Jv_JNI_NewString): Likewise. (_Jv_JNI_NewStringUTF): Likewise. (_Jv_JNI_GetStringUTFChars): Likewise. (_Jv_JNI_NewObjectArray): Likewise. (_Jv_JNI_NewPrimitiveArray): Likewise. (_Jv_JNI_GetPrimitiveArrayRegion): Likewise. (_Jv_JNI_GetStringRegion): Likewise. (_Jv_JNI_GetStringUTFRegion): Likewise. (_Jv_JNI_SetPrimitiveArrayRegion): Likewise. (_Jv_JNI_MonitorEnter): Likewise. (_Jv_JNI_MonitorExit): Likewise. (_Jv_JNI_ToReflectedField): Likewise. (_Jv_JNI_ToReflectedMethod): Likewise. (_Jv_JNI_RegisterNatives): Likewise. (_Jv_JNI_AttachCurrentThread): Likewise. (_Jv_JNI_DestroyJavaVM): Likewise. From-SVN: r32294
2000-03-02 21:25:20 +01:00
// Steps 8, 9, 10, 11.
try
1999-04-07 16:42:40 +02:00
{
java-interp.h: Don't include MethodInvocation.h. * include/java-interp.h: Don't include MethodInvocation.h. (class _Jv_InterpMethod): Don't make MethodInvocation a friend. * Makefile.in: Rebuilt. * Makefile.am (gnu/gcj/runtime/MethodInvocation.h): Removed. (ordinary_java_source_files): Don't mention MethodInvocation.java. * gnu/gcj/runtime/MethodInvocation.java: Removed. * interpret.cc (MethodInvocation::continue1): Removed. (run): Handle exceptions here. * java/lang/ClassLoader.java (defineClass1, defineClass2): Removed. * java/lang/natClassLoader.cc (defineClass0): Catch exceptions here. (defineClass2): Removed. * java/lang/reflect/Method.java (hack_trampoline, hack_call): Removed. * java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA): Catch exceptions here. (hack_call): Removed. * java/lang/Class.h (Class): Removed hackRunInitializers, hackTrampoline. * java/lang/natClass.cc (hackRunInitializers): Removed. (initializeClass): Catch exceptions here. Include ExceptionInInitializerError.h. * java/lang/Class.java (hackTrampoline, hackRunInitializers): Removed. * java/lang/Object.h (Object): Don't mention hack12_6. * java/lang/natObject.cc (_Jv_FinalizeObject): Catch exceptions here. * java/lang/Object.java (hack12_6): Removed. * java/lang/natThread.cc (run_): Renamed. Catch exceptions here. (start): Use run_, not run__. * java/lang/Thread.java (run_): Renamed from run__; old run_ removed. * jni.cc (_Jv_JNI_FindClass): Handle exceptions. (_Jv_JNI_EnsureLocalCapacity): Likewise. (_Jv_JNI_DefineClass): Likewise. (_Jv_JNI_ThrowNew): Likewise. (_Jv_JNI_AllocObject): Likewise. (_Jv_JNI_GetAnyMethodID): Likewise. (_Jv_JNI_CallAnyMethodV): Likewise. (_Jv_JNI_CallAnyMethodA): Likewise. (_Jv_JNI_CallAnyVoidMethodV): Likewise. (_Jv_JNI_CallAnyVoidMethodA): Likewise. (_Jv_JNI_GetAnyFieldID): Likewise. (_Jv_JNI_NewString): Likewise. (_Jv_JNI_NewStringUTF): Likewise. (_Jv_JNI_GetStringUTFChars): Likewise. (_Jv_JNI_NewObjectArray): Likewise. (_Jv_JNI_NewPrimitiveArray): Likewise. (_Jv_JNI_GetPrimitiveArrayRegion): Likewise. (_Jv_JNI_GetStringRegion): Likewise. (_Jv_JNI_GetStringUTFRegion): Likewise. (_Jv_JNI_SetPrimitiveArrayRegion): Likewise. (_Jv_JNI_MonitorEnter): Likewise. (_Jv_JNI_MonitorExit): Likewise. (_Jv_JNI_ToReflectedField): Likewise. (_Jv_JNI_ToReflectedMethod): Likewise. (_Jv_JNI_RegisterNatives): Likewise. (_Jv_JNI_AttachCurrentThread): Likewise. (_Jv_JNI_DestroyJavaVM): Likewise. From-SVN: r32294
2000-03-02 21:25:20 +01:00
_Jv_Method *meth = _Jv_GetMethodLocal (this, clinit_name,
void_signature);
if (meth)
((void (*) (void)) meth->ncode) ();
1999-04-07 16:42:40 +02:00
}
catch (java::lang::SecurityException *x)
{
throw x;
}
java-interp.h: Don't include MethodInvocation.h. * include/java-interp.h: Don't include MethodInvocation.h. (class _Jv_InterpMethod): Don't make MethodInvocation a friend. * Makefile.in: Rebuilt. * Makefile.am (gnu/gcj/runtime/MethodInvocation.h): Removed. (ordinary_java_source_files): Don't mention MethodInvocation.java. * gnu/gcj/runtime/MethodInvocation.java: Removed. * interpret.cc (MethodInvocation::continue1): Removed. (run): Handle exceptions here. * java/lang/ClassLoader.java (defineClass1, defineClass2): Removed. * java/lang/natClassLoader.cc (defineClass0): Catch exceptions here. (defineClass2): Removed. * java/lang/reflect/Method.java (hack_trampoline, hack_call): Removed. * java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA): Catch exceptions here. (hack_call): Removed. * java/lang/Class.h (Class): Removed hackRunInitializers, hackTrampoline. * java/lang/natClass.cc (hackRunInitializers): Removed. (initializeClass): Catch exceptions here. Include ExceptionInInitializerError.h. * java/lang/Class.java (hackTrampoline, hackRunInitializers): Removed. * java/lang/Object.h (Object): Don't mention hack12_6. * java/lang/natObject.cc (_Jv_FinalizeObject): Catch exceptions here. * java/lang/Object.java (hack12_6): Removed. * java/lang/natThread.cc (run_): Renamed. Catch exceptions here. (start): Use run_, not run__. * java/lang/Thread.java (run_): Renamed from run__; old run_ removed. * jni.cc (_Jv_JNI_FindClass): Handle exceptions. (_Jv_JNI_EnsureLocalCapacity): Likewise. (_Jv_JNI_DefineClass): Likewise. (_Jv_JNI_ThrowNew): Likewise. (_Jv_JNI_AllocObject): Likewise. (_Jv_JNI_GetAnyMethodID): Likewise. (_Jv_JNI_CallAnyMethodV): Likewise. (_Jv_JNI_CallAnyMethodA): Likewise. (_Jv_JNI_CallAnyVoidMethodV): Likewise. (_Jv_JNI_CallAnyVoidMethodA): Likewise. (_Jv_JNI_GetAnyFieldID): Likewise. (_Jv_JNI_NewString): Likewise. (_Jv_JNI_NewStringUTF): Likewise. (_Jv_JNI_GetStringUTFChars): Likewise. (_Jv_JNI_NewObjectArray): Likewise. (_Jv_JNI_NewPrimitiveArray): Likewise. (_Jv_JNI_GetPrimitiveArrayRegion): Likewise. (_Jv_JNI_GetStringRegion): Likewise. (_Jv_JNI_GetStringUTFRegion): Likewise. (_Jv_JNI_SetPrimitiveArrayRegion): Likewise. (_Jv_JNI_MonitorEnter): Likewise. (_Jv_JNI_MonitorExit): Likewise. (_Jv_JNI_ToReflectedField): Likewise. (_Jv_JNI_ToReflectedMethod): Likewise. (_Jv_JNI_RegisterNatives): Likewise. (_Jv_JNI_AttachCurrentThread): Likewise. (_Jv_JNI_DestroyJavaVM): Likewise. From-SVN: r32294
2000-03-02 21:25:20 +01:00
catch (java::lang::Throwable *except)
1999-04-07 16:42:40 +02:00
{
if (! java::lang::Error::class$.isInstance(except))
1999-04-07 16:42:40 +02:00
{
java-interp.h: Don't include MethodInvocation.h. * include/java-interp.h: Don't include MethodInvocation.h. (class _Jv_InterpMethod): Don't make MethodInvocation a friend. * Makefile.in: Rebuilt. * Makefile.am (gnu/gcj/runtime/MethodInvocation.h): Removed. (ordinary_java_source_files): Don't mention MethodInvocation.java. * gnu/gcj/runtime/MethodInvocation.java: Removed. * interpret.cc (MethodInvocation::continue1): Removed. (run): Handle exceptions here. * java/lang/ClassLoader.java (defineClass1, defineClass2): Removed. * java/lang/natClassLoader.cc (defineClass0): Catch exceptions here. (defineClass2): Removed. * java/lang/reflect/Method.java (hack_trampoline, hack_call): Removed. * java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA): Catch exceptions here. (hack_call): Removed. * java/lang/Class.h (Class): Removed hackRunInitializers, hackTrampoline. * java/lang/natClass.cc (hackRunInitializers): Removed. (initializeClass): Catch exceptions here. Include ExceptionInInitializerError.h. * java/lang/Class.java (hackTrampoline, hackRunInitializers): Removed. * java/lang/Object.h (Object): Don't mention hack12_6. * java/lang/natObject.cc (_Jv_FinalizeObject): Catch exceptions here. * java/lang/Object.java (hack12_6): Removed. * java/lang/natThread.cc (run_): Renamed. Catch exceptions here. (start): Use run_, not run__. * java/lang/Thread.java (run_): Renamed from run__; old run_ removed. * jni.cc (_Jv_JNI_FindClass): Handle exceptions. (_Jv_JNI_EnsureLocalCapacity): Likewise. (_Jv_JNI_DefineClass): Likewise. (_Jv_JNI_ThrowNew): Likewise. (_Jv_JNI_AllocObject): Likewise. (_Jv_JNI_GetAnyMethodID): Likewise. (_Jv_JNI_CallAnyMethodV): Likewise. (_Jv_JNI_CallAnyMethodA): Likewise. (_Jv_JNI_CallAnyVoidMethodV): Likewise. (_Jv_JNI_CallAnyVoidMethodA): Likewise. (_Jv_JNI_GetAnyFieldID): Likewise. (_Jv_JNI_NewString): Likewise. (_Jv_JNI_NewStringUTF): Likewise. (_Jv_JNI_GetStringUTFChars): Likewise. (_Jv_JNI_NewObjectArray): Likewise. (_Jv_JNI_NewPrimitiveArray): Likewise. (_Jv_JNI_GetPrimitiveArrayRegion): Likewise. (_Jv_JNI_GetStringRegion): Likewise. (_Jv_JNI_GetStringUTFRegion): Likewise. (_Jv_JNI_SetPrimitiveArrayRegion): Likewise. (_Jv_JNI_MonitorEnter): Likewise. (_Jv_JNI_MonitorExit): Likewise. (_Jv_JNI_ToReflectedField): Likewise. (_Jv_JNI_ToReflectedMethod): Likewise. (_Jv_JNI_RegisterNatives): Likewise. (_Jv_JNI_AttachCurrentThread): Likewise. (_Jv_JNI_DestroyJavaVM): Likewise. From-SVN: r32294
2000-03-02 21:25:20 +01:00
try
{
except = new ExceptionInInitializerError (except);
}
catch (java::lang::Throwable *t)
{
except = t;
}
1999-04-07 16:42:40 +02:00
}
JvSynchronize sync (this);
[multiple changes] 1999-08-09 Anthony Green <green@cygnus.com> * gij.cc: New file. * include/config.h.in: Rebuilt. * acconfig.h: Add INTERPRETER. * configure: Rebuilt. * Makefile.in: Rebuilt. * Makefile.am (libffi_files): Identify the libffi object files for inclusion in libgcj. (LIBFFIINCS): Define. * interpret.cc (gnu::gcj::runtime::MethodInvocation::continue1): Dummy definition for configurations without an interpreter. * java/net/natPlainSocketImpl.cc (getOption): Disamiguate call to java::lang::Boolean constructor. * include/java-interp.h: Always include java-cpool.h. * java/lang/natClassLoader.cc (getVMClassLoader0): Always return 0 when INTERPRETER not defined. * java/lang/Class.h (finalize): Define. * gnu/gcj/util/path/DirectoryPathEntry.java (getURL): Catch IOException from File.getCanonicalPath. (getStream): Likewise. * NEWS: More news. * THANKS: More thanks. 1999-08-09 Kresten Krab Thorup <krab@gnu.org> * resolve.cc (get_ffi_type_from_signature): Generate uint16 for jchar type. (_Jv_PrepareClass): Allow non-abstract classes to have abstract subclasses. (_Jv_ResolvePoolEntry): Revert subclass check for protected fields and methods. * interpret.cc (continue1/perform_invoke): Don't sign extend uint16 return val. (continue1/lshl,lshr): Push long, not int. (continue1/ulshr): Use UINT64, not long long. * defineclass.cc (handleFieldsEnd): Handle case when all fields are static. * java/lang/natClass.cc (forName): Add call to _Jv_InitClass. * java/lang/FirstThread.java (run): Add top-level exception handler. (run0): Renamed from run. 1999-08-08 Kresten Krab Thorup <krab@gnu.org> * configure.in (--with-interpreter): Added. * include/config.h.in (INTERPRETER): Added. * java/lang/ClassLoader.java: File replaced. * java/lang/VMClassLoader.java: New file. * java/lang/natClassLoader.cc: New file. * gnu/gcj/runtime/MethodInvocation.java: New file. * gnu/gcj/util/path/SearchPath.java: New file. * gnu/gcj/util/path/PathEntry.java: New file. * gnu/gcj/util/path/DirectoryPathEntry.java: New file. * gnu/gcj/util/path/ZipPathEntry.java: New file. * gnu/gcj/util/path/URLPathEntry.java: New file. * gnu/gcj/util/path/CacheEntry.java: New file. * include/java-interp.h: New file. * include/java-cpool.h: New file. * include/java-insns.h: New file. * defineclass.cc: New file. * interpret.cc: New file. * resolve.cc: New file. * java/lang/natClass.cc (loaded_classes, _Jv_RegisterClass, _Jv_RegisterClasses, _Jv_FindClassInCache, _Jv_FindClass, _Jv_NewClass, _Jv_FindArrayClass): Moved to natClassLoader.cc. (finalize): New. (STATE_NOTHING, STATE_RESOLVED, STATE_IN_PROGRESS, STATE_DONE, STATE_ERROR): Moved to java/lang/Class.h and renamed with JV_ prefix. (initializeClass): Use new JV_ prefixed names. Also, call ClassLoader::resolveClass instead of _Jv_ResolveClass. * java/lang/Class.h (JV_STATE_PRELOADING, JV_STATE_LOADING, JV_STATE_LOADED, JV_STATE_COMPILED, JV_STATE_PREPARED, JV_STATE_LINKED): New. (_Jv_WaitForState, _Jv_RegisterInitiatingLoader, _Jv_UnregisterClass, _Jv_InternClassStrings): New friends. (_Jv_IsInterpretedClass, _Jv_InitField, _Jv_LookupDeclaredMethod, _Jv_DetermineVTableIndex, _Jv_ResolvePoolEntry, _Jv_PrepareClass, _Jv_ClassReader, _Jv_InterpClass, _Jv_InterpMethod, _Jv_InterpMethodInvocation): New friends for interpreter. (finalize): New. (CONSTANT_Class, CONSTANT_String, etc.): Moved to include/java-cpool.h and renamed with JV_ prefix. * include/jvm.h (_Jv_makeUtf8Const, _Jv_makeUtf8TypeConst): New decls. (_Jv_UnregisterClass): New decl. * java/lang/natClassLoader.cc (_Jv_FindArrayClass): Added class loader argument. (_Jv_FindClass): Use class loader. * prims.cc (_Jv_makeUtf8Const): New function. (_Jv_NewObjectArray): Change use of _Jv_FindArrayClass. (_Jv_NewPrimArray): Ditto. (_Jv_FindClassFromSignature): Ditto. * java/lang/reflect/natArray.cc (newInstance): Ditto. * java/lang/reflect/natMethod.cc (getType): Ditto. * include/java-field.h (_Jv_Field::isRef): Make robust for non-resolved contexts. * boehm.cc (_Jv_MarkObj): Mark interpreter-related fields. Also, don't mark class->next field. * java/lang/VirtualMachineError.java: Added FIXME note. * configure.in (INTERPSPEC): New spec. * libgcj.spec.in: Added INTERPSPEC. * Makefile.am: Added gcjh friends for java/lang/VMClassLoader and gnu/gcj/runtime/MethodInvocation. (libgcj_la_SOURCES): Added resolve.cc defineclass.cc interpret.cc. (ordinary_java_source_files): Added above mentioned java classes. * configure: Rebuilt. * Makefile.in: Rebuilt. From-SVN: r28597
1999-08-08 16:06:23 +02:00
state = JV_STATE_ERROR;
java-interp.h: Don't include MethodInvocation.h. * include/java-interp.h: Don't include MethodInvocation.h. (class _Jv_InterpMethod): Don't make MethodInvocation a friend. * Makefile.in: Rebuilt. * Makefile.am (gnu/gcj/runtime/MethodInvocation.h): Removed. (ordinary_java_source_files): Don't mention MethodInvocation.java. * gnu/gcj/runtime/MethodInvocation.java: Removed. * interpret.cc (MethodInvocation::continue1): Removed. (run): Handle exceptions here. * java/lang/ClassLoader.java (defineClass1, defineClass2): Removed. * java/lang/natClassLoader.cc (defineClass0): Catch exceptions here. (defineClass2): Removed. * java/lang/reflect/Method.java (hack_trampoline, hack_call): Removed. * java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA): Catch exceptions here. (hack_call): Removed. * java/lang/Class.h (Class): Removed hackRunInitializers, hackTrampoline. * java/lang/natClass.cc (hackRunInitializers): Removed. (initializeClass): Catch exceptions here. Include ExceptionInInitializerError.h. * java/lang/Class.java (hackTrampoline, hackRunInitializers): Removed. * java/lang/Object.h (Object): Don't mention hack12_6. * java/lang/natObject.cc (_Jv_FinalizeObject): Catch exceptions here. * java/lang/Object.java (hack12_6): Removed. * java/lang/natThread.cc (run_): Renamed. Catch exceptions here. (start): Use run_, not run__. * java/lang/Thread.java (run_): Renamed from run__; old run_ removed. * jni.cc (_Jv_JNI_FindClass): Handle exceptions. (_Jv_JNI_EnsureLocalCapacity): Likewise. (_Jv_JNI_DefineClass): Likewise. (_Jv_JNI_ThrowNew): Likewise. (_Jv_JNI_AllocObject): Likewise. (_Jv_JNI_GetAnyMethodID): Likewise. (_Jv_JNI_CallAnyMethodV): Likewise. (_Jv_JNI_CallAnyMethodA): Likewise. (_Jv_JNI_CallAnyVoidMethodV): Likewise. (_Jv_JNI_CallAnyVoidMethodA): Likewise. (_Jv_JNI_GetAnyFieldID): Likewise. (_Jv_JNI_NewString): Likewise. (_Jv_JNI_NewStringUTF): Likewise. (_Jv_JNI_GetStringUTFChars): Likewise. (_Jv_JNI_NewObjectArray): Likewise. (_Jv_JNI_NewPrimitiveArray): Likewise. (_Jv_JNI_GetPrimitiveArrayRegion): Likewise. (_Jv_JNI_GetStringRegion): Likewise. (_Jv_JNI_GetStringUTFRegion): Likewise. (_Jv_JNI_SetPrimitiveArrayRegion): Likewise. (_Jv_JNI_MonitorEnter): Likewise. (_Jv_JNI_MonitorExit): Likewise. (_Jv_JNI_ToReflectedField): Likewise. (_Jv_JNI_ToReflectedMethod): Likewise. (_Jv_JNI_RegisterNatives): Likewise. (_Jv_JNI_AttachCurrentThread): Likewise. (_Jv_JNI_DestroyJavaVM): Likewise. From-SVN: r32294
2000-03-02 21:25:20 +01:00
notifyAll ();
throw except;
1999-04-07 16:42:40 +02:00
}
java-interp.h: Don't include MethodInvocation.h. * include/java-interp.h: Don't include MethodInvocation.h. (class _Jv_InterpMethod): Don't make MethodInvocation a friend. * Makefile.in: Rebuilt. * Makefile.am (gnu/gcj/runtime/MethodInvocation.h): Removed. (ordinary_java_source_files): Don't mention MethodInvocation.java. * gnu/gcj/runtime/MethodInvocation.java: Removed. * interpret.cc (MethodInvocation::continue1): Removed. (run): Handle exceptions here. * java/lang/ClassLoader.java (defineClass1, defineClass2): Removed. * java/lang/natClassLoader.cc (defineClass0): Catch exceptions here. (defineClass2): Removed. * java/lang/reflect/Method.java (hack_trampoline, hack_call): Removed. * java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA): Catch exceptions here. (hack_call): Removed. * java/lang/Class.h (Class): Removed hackRunInitializers, hackTrampoline. * java/lang/natClass.cc (hackRunInitializers): Removed. (initializeClass): Catch exceptions here. Include ExceptionInInitializerError.h. * java/lang/Class.java (hackTrampoline, hackRunInitializers): Removed. * java/lang/Object.h (Object): Don't mention hack12_6. * java/lang/natObject.cc (_Jv_FinalizeObject): Catch exceptions here. * java/lang/Object.java (hack12_6): Removed. * java/lang/natThread.cc (run_): Renamed. Catch exceptions here. (start): Use run_, not run__. * java/lang/Thread.java (run_): Renamed from run__; old run_ removed. * jni.cc (_Jv_JNI_FindClass): Handle exceptions. (_Jv_JNI_EnsureLocalCapacity): Likewise. (_Jv_JNI_DefineClass): Likewise. (_Jv_JNI_ThrowNew): Likewise. (_Jv_JNI_AllocObject): Likewise. (_Jv_JNI_GetAnyMethodID): Likewise. (_Jv_JNI_CallAnyMethodV): Likewise. (_Jv_JNI_CallAnyMethodA): Likewise. (_Jv_JNI_CallAnyVoidMethodV): Likewise. (_Jv_JNI_CallAnyVoidMethodA): Likewise. (_Jv_JNI_GetAnyFieldID): Likewise. (_Jv_JNI_NewString): Likewise. (_Jv_JNI_NewStringUTF): Likewise. (_Jv_JNI_GetStringUTFChars): Likewise. (_Jv_JNI_NewObjectArray): Likewise. (_Jv_JNI_NewPrimitiveArray): Likewise. (_Jv_JNI_GetPrimitiveArrayRegion): Likewise. (_Jv_JNI_GetStringRegion): Likewise. (_Jv_JNI_GetStringUTFRegion): Likewise. (_Jv_JNI_SetPrimitiveArrayRegion): Likewise. (_Jv_JNI_MonitorEnter): Likewise. (_Jv_JNI_MonitorExit): Likewise. (_Jv_JNI_ToReflectedField): Likewise. (_Jv_JNI_ToReflectedMethod): Likewise. (_Jv_JNI_RegisterNatives): Likewise. (_Jv_JNI_AttachCurrentThread): Likewise. (_Jv_JNI_DestroyJavaVM): Likewise. From-SVN: r32294
2000-03-02 21:25:20 +01:00
JvSynchronize sync (this);
java-interp.h: Don't include MethodInvocation.h. * include/java-interp.h: Don't include MethodInvocation.h. (class _Jv_InterpMethod): Don't make MethodInvocation a friend. * Makefile.in: Rebuilt. * Makefile.am (gnu/gcj/runtime/MethodInvocation.h): Removed. (ordinary_java_source_files): Don't mention MethodInvocation.java. * gnu/gcj/runtime/MethodInvocation.java: Removed. * interpret.cc (MethodInvocation::continue1): Removed. (run): Handle exceptions here. * java/lang/ClassLoader.java (defineClass1, defineClass2): Removed. * java/lang/natClassLoader.cc (defineClass0): Catch exceptions here. (defineClass2): Removed. * java/lang/reflect/Method.java (hack_trampoline, hack_call): Removed. * java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA): Catch exceptions here. (hack_call): Removed. * java/lang/Class.h (Class): Removed hackRunInitializers, hackTrampoline. * java/lang/natClass.cc (hackRunInitializers): Removed. (initializeClass): Catch exceptions here. Include ExceptionInInitializerError.h. * java/lang/Class.java (hackTrampoline, hackRunInitializers): Removed. * java/lang/Object.h (Object): Don't mention hack12_6. * java/lang/natObject.cc (_Jv_FinalizeObject): Catch exceptions here. * java/lang/Object.java (hack12_6): Removed. * java/lang/natThread.cc (run_): Renamed. Catch exceptions here. (start): Use run_, not run__. * java/lang/Thread.java (run_): Renamed from run__; old run_ removed. * jni.cc (_Jv_JNI_FindClass): Handle exceptions. (_Jv_JNI_EnsureLocalCapacity): Likewise. (_Jv_JNI_DefineClass): Likewise. (_Jv_JNI_ThrowNew): Likewise. (_Jv_JNI_AllocObject): Likewise. (_Jv_JNI_GetAnyMethodID): Likewise. (_Jv_JNI_CallAnyMethodV): Likewise. (_Jv_JNI_CallAnyMethodA): Likewise. (_Jv_JNI_CallAnyVoidMethodV): Likewise. (_Jv_JNI_CallAnyVoidMethodA): Likewise. (_Jv_JNI_GetAnyFieldID): Likewise. (_Jv_JNI_NewString): Likewise. (_Jv_JNI_NewStringUTF): Likewise. (_Jv_JNI_GetStringUTFChars): Likewise. (_Jv_JNI_NewObjectArray): Likewise. (_Jv_JNI_NewPrimitiveArray): Likewise. (_Jv_JNI_GetPrimitiveArrayRegion): Likewise. (_Jv_JNI_GetStringRegion): Likewise. (_Jv_JNI_GetStringUTFRegion): Likewise. (_Jv_JNI_SetPrimitiveArrayRegion): Likewise. (_Jv_JNI_MonitorEnter): Likewise. (_Jv_JNI_MonitorExit): Likewise. (_Jv_JNI_ToReflectedField): Likewise. (_Jv_JNI_ToReflectedMethod): Likewise. (_Jv_JNI_RegisterNatives): Likewise. (_Jv_JNI_AttachCurrentThread): Likewise. (_Jv_JNI_DestroyJavaVM): Likewise. From-SVN: r32294
2000-03-02 21:25:20 +01:00
state = JV_STATE_DONE;
notifyAll ();
}
// Only used by serialization
java::lang::reflect::Field *
java::lang::Class::getPrivateField (jstring name)
{
int hash = name->hashCode ();
java::lang::reflect::Field* rfield;
for (int i = 0; i < field_count; i++)
{
_Jv_Field *field = &fields[i];
if (! _Jv_equal (field->name, name, hash))
continue;
rfield = new java::lang::reflect::Field ();
rfield->offset = (char*) field - (char*) fields;
rfield->declaringClass = this;
rfield->name = name;
return rfield;
}
jclass superclass = getSuperclass();
if (superclass == NULL)
return NULL;
rfield = superclass->getPrivateField(name);
for (int i = 0; i < interface_count && rfield == NULL; ++i)
rfield = interfaces[i]->getPrivateField (name);
return rfield;
}
// Only used by serialization
java::lang::reflect::Method *
java::lang::Class::getPrivateMethod (jstring name, JArray<jclass> *param_types)
{
jstring partial_sig = getSignature (param_types, false);
jint p_len = partial_sig->length();
_Jv_Utf8Const *utf_name = _Jv_makeUtf8Const (name);
for (Class *klass = this; klass; klass = klass->getSuperclass())
{
int i = klass->isPrimitive () ? 0 : klass->method_count;
while (--i >= 0)
{
if (_Jv_equalUtf8Consts (klass->methods[i].name, utf_name)
&& _Jv_equaln (klass->methods[i].signature, partial_sig, p_len))
{
// Found it.
using namespace java::lang::reflect;
Method *rmethod = new Method ();
rmethod->offset = ((char *) (&klass->methods[i])
- (char *) klass->methods);
rmethod->declaringClass = klass;
return rmethod;
}
}
}
throw new java::lang::NoSuchMethodException (name);
}
// Private accessor method for Java code to retrieve the protection domain.
java::security::ProtectionDomain *
java::lang::Class::getProtectionDomain0 ()
{
return protectionDomain;
}
JArray<jobject> *
java::lang::Class::getSigners()
{
return hack_signers;
}
void
java::lang::Class::setSigners(JArray<jobject> *s)
{
hack_signers = s;
1999-04-07 16:42:40 +02:00
}
static unsigned char
read_u1 (unsigned char *&p)
{
return *p++;
}
static unsigned char
read_u1 (unsigned char *&p, unsigned char *next)
{
if (next - p < 1)
throw new java::lang::InternalError();
return *p++;
}
static unsigned int
read_u2 (unsigned char *&p)
{
unsigned int b1 = *p++;
unsigned int b2 = *p++;
return (b1 << 8) | b2;
}
static unsigned int
read_u2 (unsigned char *&p, unsigned char *next)
{
if (next - p < 2)
throw new java::lang::InternalError();
return read_u2 (p);
}
static int
read_4 (unsigned char *&p)
{
int b1 = *p++;
int b2 = *p++;
int b3 = *p++;
int b4 = *p++;
return (b1 << 24) | (b2 << 16) | (b3 << 8) | b4;
}
jstring
java::lang::Class::getReflectionSignature (jint /*jv_attr_type*/ type,
jint obj_index)
{
// We just re-parse the bytecode for this data each time. If
// necessary we can cache results, but I suspect this is not
// performance sensitive.
unsigned char *bytes = reflection_data;
if (bytes == NULL)
return NULL;
while (true)
{
int kind = read_u1 (bytes);
if (kind == JV_DONE_ATTR)
return NULL;
int len = read_4 (bytes);
unsigned char *next = bytes + len;
if (kind != type)
{
bytes = next;
continue;
}
if (type != JV_CLASS_ATTR)
{
unsigned short index = read_u2 (bytes, next);
if (index != obj_index)
{
bytes = next;
continue;
}
}
int nt = read_u1 (bytes, next);
if (nt != JV_SIGNATURE_KIND)
{
bytes = next;
continue;
}
unsigned int cpool_idx = read_u2 (bytes, next);
if (cpool_idx >= (unsigned int) constants.size
|| constants.tags[cpool_idx] != JV_CONSTANT_Utf8)
{
// We just ignore errors for now. It isn't clear what is
// best to do here, as an encoding error here means a bug
// either in the compiler or in defineclass.cc.
return NULL;
}
return _Jv_NewStringUtf8Const (constants.data[cpool_idx].utf8);
}
}
jstring
java::lang::Class::getReflectionSignature (::java::lang::reflect::Constructor *c)
{
_Jv_Method *meth = _Jv_FromReflectedConstructor (c);
unsigned short meth_index = meth - methods;
return getReflectionSignature (JV_METHOD_ATTR, meth_index);
}
jstring
java::lang::Class::getReflectionSignature (::java::lang::reflect::Method *m)
{
_Jv_Method *meth = _Jv_FromReflectedMethod (m);
unsigned short meth_index = meth - methods;
return getReflectionSignature (JV_METHOD_ATTR, meth_index);
}
jstring
java::lang::Class::getReflectionSignature (::java::lang::reflect::Field *f)
{
_Jv_Field *fld = _Jv_FromReflectedField (f);
unsigned short fld_index = fld - fields;
return getReflectionSignature (JV_FIELD_ATTR, fld_index);
}
jstring
java::lang::Class::getClassSignature()
{
return getReflectionSignature (JV_CLASS_ATTR, 0);
}
jint
java::lang::Class::getEnclosingMethodData()
{
unsigned char *bytes = reflection_data;
if (bytes == NULL)
return 0;
while (true)
{
int kind = read_u1 (bytes);
if (kind == JV_DONE_ATTR)
return 0;
int len = read_4 (bytes);
unsigned char *next = bytes + len;
if (kind != JV_CLASS_ATTR)
{
bytes = next;
continue;
}
int type = read_u1 (bytes, next);
if (type != JV_ENCLOSING_METHOD_KIND)
{
bytes = next;
continue;
}
int class_index = read_u2 (bytes, next);
int method_index = read_u2 (bytes, next);
_Jv_word result;
_Jv_storeIndexes (&result, class_index, method_index);
return result.i;
}
}
jclass
java::lang::Class::getEnclosingClass()
{
_Jv_word indexes;
indexes.i = getEnclosingMethodData();
if (indexes.i == 0)
return NULL;
_Jv_ushort class_index, method_index;
_Jv_loadIndexes (&indexes, class_index, method_index);
return _Jv_Linker::resolve_pool_entry (this, class_index).clazz;
}
::java::lang::reflect::Method *
java::lang::Class::getEnclosingMethod()
{
_Jv_word indexes;
indexes.i = getEnclosingMethodData();
if (indexes.i == 0)
return NULL;
_Jv_ushort class_index, method_index;
_Jv_loadIndexes (&indexes, class_index, method_index);
jclass found_class;
_Jv_Method *method = _Jv_Linker::resolve_method_entry (this, found_class,
class_index,
method_index,
false, false);
using namespace java::lang::reflect;
Method *rmethod = new Method ();
rmethod->offset = (char *) method - (char *) found_class->methods;
rmethod->declaringClass = found_class;
return rmethod;
}
::java::lang::reflect::Constructor *
java::lang::Class::getEnclosingConstructor()
{
_Jv_word indexes;
indexes.i = getEnclosingMethodData();
if (indexes.i == 0)
return NULL;
_Jv_ushort class_index, method_index;
_Jv_loadIndexes (&indexes, class_index, method_index);
jclass found_class;
_Jv_Method *method = _Jv_Linker::resolve_method_entry (this, found_class,
class_index,
method_index,
false, false);
using namespace java::lang::reflect;
Constructor *cons = new Constructor ();
cons->offset = (char *) method - (char *) found_class->methods;
cons->declaringClass = this;
return cons;
}
static void
check_constant (_Jv_Constants *pool, jint cpool_index, jint type)
{
if (cpool_index <= 0 || cpool_index >= pool->size)
throw new InternalError(JvNewStringLatin1("invalid constant pool index"));
if ((pool->tags[cpool_index] &
~(JV_CONSTANT_ResolvedFlag|JV_CONSTANT_LazyFlag)) != type)
{
::java::lang::StringBuffer *sb = new ::java::lang::StringBuffer();
sb->append(JvNewStringLatin1("expected pool constant "));
sb->append(type);
sb->append(JvNewStringLatin1(" but got "));
sb->append(jint (pool->tags[cpool_index]));
throw new InternalError(sb->toString());
}
}
// Forward declaration
static ::java::lang::annotation::Annotation *
parseAnnotation(jclass klass, _Jv_Constants *pool,
unsigned char *&bytes, unsigned char *last);
static jobject
parseAnnotationElement(jclass klass, _Jv_Constants *pool,
unsigned char *&bytes, unsigned char *last)
{
int tag = read_u1 (bytes, last);
jobject result;
switch (tag)
{
case 'B':
{
int cindex = read_u2 (bytes, last);
check_constant (pool, cindex, JV_CONSTANT_Integer);
result = Byte::valueOf (pool->data[cindex].i);
}
break;
case 'C':
{
int cindex = read_u2 (bytes, last);
check_constant (pool, cindex, JV_CONSTANT_Integer);
result = Character::valueOf (pool->data[cindex].i);
}
break;
case 'S':
{
int cindex = read_u2 (bytes, last);
check_constant (pool, cindex, JV_CONSTANT_Integer);
result = Short::valueOf (pool->data[cindex].i);
}
break;
case 'Z':
{
int cindex = read_u2 (bytes, last);
check_constant (pool, cindex, JV_CONSTANT_Integer);
result = Boolean::valueOf (jboolean (pool->data[cindex].i));
}
break;
case 'I':
{
int cindex = read_u2 (bytes, last);
check_constant (pool, cindex, JV_CONSTANT_Integer);
result = Integer::valueOf (pool->data[cindex].i);
}
break;
case 'D':
{
int cindex = read_u2 (bytes, last);
check_constant (pool, cindex, JV_CONSTANT_Double);
_Jv_word2 word;
memcpy (&word, &pool->data[cindex], 2 * sizeof (_Jv_word));
result = Double::valueOf (word.d);
}
break;
case 'F':
{
int cindex = read_u2 (bytes, last);
check_constant (pool, cindex, JV_CONSTANT_Float);
result = Float::valueOf (pool->data[cindex].f);
}
break;
case 'J':
{
int cindex = read_u2 (bytes, last);
check_constant (pool, cindex, JV_CONSTANT_Long);
_Jv_word2 word;
memcpy (&word, &pool->data[cindex], 2 * sizeof (_Jv_word));
result = Long::valueOf (word.l);
}
break;
case 's':
{
int cindex = read_u2 (bytes, last);
// Despite what the JVM spec says, compilers generate a Utf8
// constant here, not a String.
check_constant (pool, cindex, JV_CONSTANT_Utf8);
result = pool->data[cindex].utf8->toString();
}
break;
case 'e':
{
int type_name_index = read_u2 (bytes, last);
check_constant (pool, type_name_index, JV_CONSTANT_Utf8);
int const_name_index = read_u2 (bytes, last);
check_constant (pool, const_name_index, JV_CONSTANT_Utf8);
_Jv_Utf8Const *u_name = pool->data[type_name_index].utf8;
_Jv_Utf8Const *e_name = pool->data[const_name_index].utf8;
// FIXME: throw correct exceptions at the correct times.
jclass e_class = _Jv_FindClassFromSignature(u_name->chars(),
klass->getClassLoaderInternal());
result = ::java::lang::Enum::valueOf(e_class, e_name->toString());
}
break;
case 'c':
{
int cindex = read_u2 (bytes, last);
check_constant (pool, cindex, JV_CONSTANT_Utf8);
_Jv_Utf8Const *u_name = pool->data[cindex].utf8;
jclass anno_class
= _Jv_FindClassFromSignatureNoException(u_name->chars(),
klass->getClassLoaderInternal());
// FIXME: not correct: we should lazily do this when trying to
// read the element. This means that
// AnnotationInvocationHandler needs to have a special case.
if (! anno_class)
// FIXME: original exception...
throw new TypeNotPresentException(u_name->toString(), NULL);
result = anno_class;
}
break;
case '@':
result = parseAnnotation (klass, pool, bytes, last);
break;
case '[':
{
int n_array_elts = read_u2 (bytes, last);
jobjectArray aresult = _Jv_NewObjectArray (n_array_elts,
&Object::class$, NULL);
jobject *elts = elements (aresult);
for (int i = 0; i < n_array_elts; ++i)
elts[i] = parseAnnotationElement(klass, pool, bytes, last);
result = aresult;
}
break;
default:
throw new java::lang::InternalError();
}
return result;
}
static ::java::lang::annotation::Annotation *
parseAnnotation(jclass klass, _Jv_Constants *pool,
unsigned char *&bytes, unsigned char *last)
{
int type_index = read_u2 (bytes, last);
check_constant (pool, type_index, JV_CONSTANT_Utf8);
_Jv_Utf8Const *u_name = pool->data[type_index].utf8;
jclass anno_class = _Jv_FindClassFromSignatureNoException(u_name->chars(),
klass->getClassLoaderInternal());
// FIXME: what to do if anno_class==NULL?
::java::util::HashMap *hmap = new ::java::util::HashMap();
int npairs = read_u2 (bytes, last);
for (int i = 0; i < npairs; ++i)
{
int name_index = read_u2 (bytes, last);
check_constant (pool, name_index, JV_CONSTANT_Utf8);
jstring name = _Jv_NewStringUtf8Const (pool->data[name_index].utf8);
jobject value = parseAnnotationElement (klass, pool, bytes, last);
// FIXME: any checks needed for name?
hmap->put(name, value);
}
using namespace ::sun::reflect::annotation;
return AnnotationInvocationHandler::create (anno_class,
(::java::util::Map *) hmap);
}
static jobjectArray
parseAnnotations(jclass klass, _Jv_Constants *pool,
unsigned char *&bytes, unsigned char *last)
{
int num = read_u2 (bytes, last);
jobjectArray result = _Jv_NewObjectArray (num,
&::java::lang::annotation::Annotation::class$,
NULL);
jobject *elts = elements (result);
for (int i = 0; i < num; ++i)
elts[i] = parseAnnotation(klass, pool, bytes, last);
return result;
}
static jobjectArray
parseParameterAnnotations(jclass klass, _Jv_Constants *pool,
unsigned char *&bytes, unsigned char *last)
{
jclass anno = &::java::lang::annotation::Annotation::class$;
jclass annoary = _Jv_GetArrayClass (anno, anno->getClassLoaderInternal());
// FIXME: something should check the number of params versus the
// method
int n_params = read_u1 (bytes, last);
jobjectArray result = _Jv_NewObjectArray (n_params, annoary, NULL);
jobject *elts = elements (result);
for (int i = 0; i < n_params; ++i)
elts[i] = parseAnnotations(klass, pool, bytes, last);
return result;
}
jobject
java::lang::Class::getMethodDefaultValue(::java::lang::reflect::Method *meth)
{
// FIXME: could cache the value here...
unsigned char *bytes = reflection_data;
if (bytes == NULL)
return 0;
unsigned short meth_index = _Jv_FromReflectedMethod (meth) - methods;
while (true)
{
int type = read_u1 (bytes);
if (type == JV_DONE_ATTR)
return NULL;
int len = read_4 (bytes);
unsigned char *next = bytes + len;
if (type != JV_METHOD_ATTR)
{
bytes = next;
continue;
}
int kind = read_u1 (bytes, next);
if (kind != JV_ANNOTATION_DEFAULT_KIND)
{
bytes = next;
continue;
}
int index = read_u2 (bytes, next);
if (meth_index != index)
{
bytes = next;
continue;
}
// FIXME: could cache here. If we do then we have to clone any
// array result.
return parseAnnotationElement(this, &this->constants, bytes, next);
}
}
jobjectArray
java::lang::Class::getDeclaredAnnotations(jint /* jv_attr_type */ member_type,
jint member_index,
jint /* jv_attr_kind */ kind_req)
{
using namespace java::lang::annotation;
jobjectArray result;
unsigned char *bytes = reflection_data;
if (bytes == NULL)
return 0;
if (loader == NULL)
loader = (ClassLoader *)VMClassLoader::bootLoader;
result = (loader->getDeclaredAnnotations
(this, member_type, member_index, kind_req));
if (result)
return result;
for (;;)
{
int type = read_u1 (bytes);
if (type == JV_DONE_ATTR)
return NULL;
int len = read_4 (bytes);
unsigned char *next = bytes + len;
if (type != member_type)
{
bytes = next;
continue;
}
int kind = read_u1 (bytes, next);
if (kind != kind_req)
{
bytes = next;
continue;
}
if (member_type != JV_CLASS_ATTR)
{
int index = read_u2 (bytes, next);
if (member_index != index)
{
bytes = next;
continue;
}
}
if (kind_req == JV_PARAMETER_ANNOTATIONS_KIND)
result = ((parseParameterAnnotations
(this, &this->constants, bytes, next)));
else
result = ((parseAnnotations (this, &this->constants, bytes, next)));
break;
}
return (loader->putDeclaredAnnotations
(this, member_type, member_index, kind_req, result));
}
jobjectArray
java::lang::Class::getDeclaredAnnotations(::java::lang::reflect::Method *meth,
jboolean is_param)
{
unsigned short meth_index = _Jv_FromReflectedMethod (meth) - methods;
return getDeclaredAnnotations(JV_METHOD_ATTR, meth_index,
(is_param
? JV_PARAMETER_ANNOTATIONS_KIND
: JV_ANNOTATIONS_KIND));
}
jobjectArray
java::lang::Class::getDeclaredAnnotations(::java::lang::reflect::Constructor *cons,
jboolean is_param)
{
unsigned short meth_index = _Jv_FromReflectedConstructor (cons) - methods;
return getDeclaredAnnotations(JV_METHOD_ATTR, meth_index,
(is_param
? JV_PARAMETER_ANNOTATIONS_KIND
: JV_ANNOTATIONS_KIND));
}
jobjectArray
java::lang::Class::getDeclaredAnnotations(::java::lang::reflect::Field *fld)
{
unsigned short field_index = _Jv_FromReflectedField (fld) - fields;
return getDeclaredAnnotations(JV_FIELD_ATTR, field_index,
JV_ANNOTATIONS_KIND);
}
JArray< ::java::lang::annotation::Annotation *> *
java::lang::Class::getDeclaredAnnotationsInternal()
{
return (JArray< ::java::lang::annotation::Annotation *> *) getDeclaredAnnotations(JV_CLASS_ATTR, 0, JV_ANNOTATIONS_KIND);
}
static jclass
resolve_class_constant (jclass klass, _Jv_Constants *pool, int cpool_index)
{
check_constant (pool, cpool_index, JV_CONSTANT_Class);
// FIXME: what is the correct thing to do with an exception here?
return _Jv_Linker::resolve_pool_entry (klass, cpool_index, false).clazz;
}
jint
java::lang::Class::findInnerClassAttribute()
{
unsigned char *bytes = reflection_data;
if (bytes == NULL)
return -1;
while (true)
{
int type = read_u1 (bytes);
if (type == JV_DONE_ATTR)
break;
// After the type but before the length.
unsigned char *save = bytes;
int len = read_4 (bytes);
unsigned char *next = bytes + len;
if (type != JV_CLASS_ATTR)
{
bytes = next;
continue;
}
int kind = read_u1 (bytes, next);
if (kind != JV_INNER_CLASSES_KIND)
{
bytes = next;
continue;
}
return save - reflection_data;
}
return -1;
}
jint
java::lang::Class::findDeclaredClasses(JArray<jclass> *result,
jboolean publicOnly,
jint offset)
{
unsigned char *bytes = reflection_data + offset;
int len = read_4 (bytes);
unsigned char *next = bytes + len;
// Skip a byte.
read_u1 (bytes, next);
int n_classes = read_u2 (bytes, next);
int count = 0;
for (int i = 0; i < n_classes; ++i)
{
int inner_class_index = read_u2 (bytes, next);
int outer_class_index = read_u2 (bytes, next);
/*int inner_name_index = */ read_u2 (bytes, next);
int inner_flags = read_u2 (bytes, next);
if (inner_class_index == 0 || outer_class_index == 0)
continue;
if (resolve_class_constant (this, &constants, outer_class_index) == this)
{
jclass inner = resolve_class_constant (this, &constants,
inner_class_index);
if (! publicOnly
|| ((inner_flags
& java::lang::reflect::Modifier::PUBLIC) != 0))
{
if (result)
{
jclass *elts = elements (result);
elts[count] = inner;
}
++count;
}
}
}
return count;
}
JArray<jclass> *
java::lang::Class::getDeclaredClasses (jboolean publicOnly)
{
int offset = findInnerClassAttribute();
int count;
if (offset == -1)
{
// No InnerClasses attribute, so no declared classes.
count = 0;
}
else
count = findDeclaredClasses(NULL, publicOnly, offset);
JArray<jclass> *result
= (JArray<jclass> *) JvNewObjectArray (count, &java::lang::Class::class$,
NULL);
if (count > 0)
findDeclaredClasses(result, publicOnly, offset);
return result;
}
jclass
java::lang::Class::getDeclaringClass (void)
{
int offset = findInnerClassAttribute();
if (offset == -1)
return NULL;
unsigned char *bytes = reflection_data + offset;
int len = read_4 (bytes);
unsigned char *next = bytes + len;
// Skip a byte.
read_u1 (bytes, next);
int n_classes = read_u2 (bytes, next);
for (int i = 0; i < n_classes; ++i)
{
int inner_class_index = read_u2 (bytes, next);
int outer_class_index = read_u2 (bytes, next);
/*int inner_name_index = */read_u2 (bytes, next);
/*int inner_flags = */read_u2 (bytes, next);
if (inner_class_index == 0 || outer_class_index == 0)
continue;
if (resolve_class_constant (this, &constants, inner_class_index) == this)
return resolve_class_constant (this, &constants, outer_class_index);
}
return NULL;
}
jboolean
java::lang::Class::isAnonymousClass()
{
int offset = findInnerClassAttribute();
if (offset == -1)
return false;
unsigned char *bytes = reflection_data + offset;
int len = read_4 (bytes);
unsigned char *next = bytes + len;
// Skip a byte.
read_u1 (bytes, next);
int n_classes = read_u2 (bytes, next);
for (int i = 0; i < n_classes; ++i)
{
int inner_class_index = read_u2 (bytes, next);
/*int outer_class_index = */read_u2 (bytes, next);
int inner_name_index = read_u2 (bytes, next);
/*int inner_flags = */read_u2 (bytes, next);
if (inner_class_index == 0)
continue;
if (resolve_class_constant (this, &constants, inner_class_index) == this)
return inner_name_index == 0;
}
return false;
}
jboolean
java::lang::Class::isLocalClass()
{
_Jv_word indexes;
indexes.i = getEnclosingMethodData();
return indexes.i != 0;
}
jboolean
java::lang::Class::isMemberClass()
{
// FIXME: is this correct?
return !isLocalClass() && getDeclaringClass() != NULL;
}
1999-04-07 16:42:40 +02:00
//
// Some class-related convenience functions.
//
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
// Find a method declared in the class. If it is not declared locally
// (or if it is inherited), return NULL.
1999-04-07 16:42:40 +02:00
_Jv_Method *
_Jv_GetMethodLocal (jclass klass, _Jv_Utf8Const *name,
_Jv_Utf8Const *signature)
{
for (int i = 0; i < klass->method_count; ++i)
{
if (_Jv_equalUtf8Consts (name, klass->methods[i].name)
&& _Jv_equalUtf8Consts (signature, klass->methods[i].signature))
return &klass->methods[i];
}
return NULL;
}
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
_Jv_Method *
_Jv_LookupDeclaredMethod (jclass klass, _Jv_Utf8Const *name,
_Jv_Utf8Const *signature,
jclass *declarer_result)
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
{
for (; klass; klass = klass->getSuperclass())
{
_Jv_Method *meth = _Jv_GetMethodLocal (klass, name, signature);
if (meth)
{
if (declarer_result)
*declarer_result = klass;
return meth;
}
[multiple changes] 2000-01-04 Tom Tromey <tromey@cygnus.com> * java/lang/reflect/natConstructor.cc (newInstance): Pass declaring class as return_type argument to _Jv_CallNonvirtualMethodA. * java/lang/reflect/natMethod.cc (_Jv_CallNonvirtualMethodA): In constructor case, create object and use it as `this' argument. * java/lang/Class.h (_getConstructors): Declare. (_getFields): Declare. * java/lang/Class.java (getConstructors): Wrote. (_getConstructors): New native method. (getDeclaredConstructors): Wrote. (_getFields): Declare new native method. * java/lang/natClass.cc (_Jv_LookupInterfaceMethod): Removed incorrect comment. (getMethod): Work correctly when class is primitive. (getDeclaredMethods): Likewise. Compute offset using `method', not `mptr'. (getDeclaredMethod): Likewise. (getConstructor): Wrote. (ConstructorClass): New define. (getDeclaredConstructor): Wrote. (_getConstructors): New method. (_getFields): New method. (getFields): Wrote. * Makefile.in: Rebuilt. * Makefile.am (AM_CXXFLAGS): Added -D_GNU_SOURCE. * prims.cc: Remove `#pragma implementation'. * gcj/array.h: Remove `#pragma interface'. * prims.cc (_Jv_equaln): New function. * java/lang/Class.java (getSignature): Declare. * resolve.cc (_Jv_LookupDeclaredMethod): Moved to natClass.cc. * java/lang/natClass.cc (_Jv_LookupDeclaredMethod): Moved from resolve.cc. (getSignature): New method. (getDeclaredMethod): Wrote. (getMethod): Wrote. Include StringBuffer.h. * java/lang/Class.h (Class): Added _Jv_FromReflectedConstructor as a friend. Unconditionally declare _Jv_LookupDeclaredMethod as a friend. (getSignature): Declare. * include/jvm.h (_Jv_GetTypesFromSignature): Declare. (_Jv_equaln): Declare. (_Jv_CallNonvirtualMethodA): Declare. * Makefile.in: Rebuilt. * Makefile.am (nat_source_files): Added natConstructor.cc. (java/lang/reflect/Constructor.h): New target. * java/lang/reflect/natConstructor.cc: New file. * java/lang/reflect/Constructor.java (newInstance): Now native. (declaringClass): Renamed from decl_class. (offset): Renamed from index. (getType): New native method. (getModifiers): Now native. (getParameterTypes): Call getType if required. (hashCode): Include hash code from declaring class. (modifiers): Removed. (toString): Call getType if required. * gcj/method.h (_Jv_FromReflectedConstructor): New function. * java/lang/reflect/natMethod.cc (hack_call): New method. Removed `#if 0' around FFI code. Include <gnu/gcj/RawData.h>. (invoke): Use _Jv_CallNonvirtualMethodA. Throw IllegalArgumentException when argument object and class disagree. (_Jv_GetTypesFromSignature): New function. (getType): Use it. (ObjectClass): New define. (_Jv_CallNonvirtualMethodA): New function. * java/lang/reflect/Method.java (hack_trampoline): New method. (hack_call): New native method. 1999-12-21 Per Bothner <per@bothner.com> * java/lang/natClass.cc (getDeclaredMethods): Correctly compute offset in new Method. From-SVN: r31199
2000-01-04 09:46:52 +01:00
}
return NULL;
}
java::lang::reflect::Method *
_Jv_GetReflectedMethod (jclass klass, _Jv_Utf8Const *name,
_Jv_Utf8Const *signature)
{
for (; klass; klass = klass->getSuperclass())
{
_Jv_Method *meth = _Jv_GetMethodLocal (klass, name, signature);
if (meth)
{
using namespace java::lang::reflect;
Method *rmethod = new Method ();
rmethod->offset = (char*) meth - (char*) klass->methods;
rmethod->declaringClass = klass;
return rmethod;
}
}
return NULL;
}
#ifdef HAVE_TLS
// NOTE: MCACHE_SIZE should be a power of 2 minus one.
#define MCACHE_SIZE 31
[multiple changes] 1999-08-09 Anthony Green <green@cygnus.com> * gij.cc: New file. * include/config.h.in: Rebuilt. * acconfig.h: Add INTERPRETER. * configure: Rebuilt. * Makefile.in: Rebuilt. * Makefile.am (libffi_files): Identify the libffi object files for inclusion in libgcj. (LIBFFIINCS): Define. * interpret.cc (gnu::gcj::runtime::MethodInvocation::continue1): Dummy definition for configurations without an interpreter. * java/net/natPlainSocketImpl.cc (getOption): Disamiguate call to java::lang::Boolean constructor. * include/java-interp.h: Always include java-cpool.h. * java/lang/natClassLoader.cc (getVMClassLoader0): Always return 0 when INTERPRETER not defined. * java/lang/Class.h (finalize): Define. * gnu/gcj/util/path/DirectoryPathEntry.java (getURL): Catch IOException from File.getCanonicalPath. (getStream): Likewise. * NEWS: More news. * THANKS: More thanks. 1999-08-09 Kresten Krab Thorup <krab@gnu.org> * resolve.cc (get_ffi_type_from_signature): Generate uint16 for jchar type. (_Jv_PrepareClass): Allow non-abstract classes to have abstract subclasses. (_Jv_ResolvePoolEntry): Revert subclass check for protected fields and methods. * interpret.cc (continue1/perform_invoke): Don't sign extend uint16 return val. (continue1/lshl,lshr): Push long, not int. (continue1/ulshr): Use UINT64, not long long. * defineclass.cc (handleFieldsEnd): Handle case when all fields are static. * java/lang/natClass.cc (forName): Add call to _Jv_InitClass. * java/lang/FirstThread.java (run): Add top-level exception handler. (run0): Renamed from run. 1999-08-08 Kresten Krab Thorup <krab@gnu.org> * configure.in (--with-interpreter): Added. * include/config.h.in (INTERPRETER): Added. * java/lang/ClassLoader.java: File replaced. * java/lang/VMClassLoader.java: New file. * java/lang/natClassLoader.cc: New file. * gnu/gcj/runtime/MethodInvocation.java: New file. * gnu/gcj/util/path/SearchPath.java: New file. * gnu/gcj/util/path/PathEntry.java: New file. * gnu/gcj/util/path/DirectoryPathEntry.java: New file. * gnu/gcj/util/path/ZipPathEntry.java: New file. * gnu/gcj/util/path/URLPathEntry.java: New file. * gnu/gcj/util/path/CacheEntry.java: New file. * include/java-interp.h: New file. * include/java-cpool.h: New file. * include/java-insns.h: New file. * defineclass.cc: New file. * interpret.cc: New file. * resolve.cc: New file. * java/lang/natClass.cc (loaded_classes, _Jv_RegisterClass, _Jv_RegisterClasses, _Jv_FindClassInCache, _Jv_FindClass, _Jv_NewClass, _Jv_FindArrayClass): Moved to natClassLoader.cc. (finalize): New. (STATE_NOTHING, STATE_RESOLVED, STATE_IN_PROGRESS, STATE_DONE, STATE_ERROR): Moved to java/lang/Class.h and renamed with JV_ prefix. (initializeClass): Use new JV_ prefixed names. Also, call ClassLoader::resolveClass instead of _Jv_ResolveClass. * java/lang/Class.h (JV_STATE_PRELOADING, JV_STATE_LOADING, JV_STATE_LOADED, JV_STATE_COMPILED, JV_STATE_PREPARED, JV_STATE_LINKED): New. (_Jv_WaitForState, _Jv_RegisterInitiatingLoader, _Jv_UnregisterClass, _Jv_InternClassStrings): New friends. (_Jv_IsInterpretedClass, _Jv_InitField, _Jv_LookupDeclaredMethod, _Jv_DetermineVTableIndex, _Jv_ResolvePoolEntry, _Jv_PrepareClass, _Jv_ClassReader, _Jv_InterpClass, _Jv_InterpMethod, _Jv_InterpMethodInvocation): New friends for interpreter. (finalize): New. (CONSTANT_Class, CONSTANT_String, etc.): Moved to include/java-cpool.h and renamed with JV_ prefix. * include/jvm.h (_Jv_makeUtf8Const, _Jv_makeUtf8TypeConst): New decls. (_Jv_UnregisterClass): New decl. * java/lang/natClassLoader.cc (_Jv_FindArrayClass): Added class loader argument. (_Jv_FindClass): Use class loader. * prims.cc (_Jv_makeUtf8Const): New function. (_Jv_NewObjectArray): Change use of _Jv_FindArrayClass. (_Jv_NewPrimArray): Ditto. (_Jv_FindClassFromSignature): Ditto. * java/lang/reflect/natArray.cc (newInstance): Ditto. * java/lang/reflect/natMethod.cc (getType): Ditto. * include/java-field.h (_Jv_Field::isRef): Make robust for non-resolved contexts. * boehm.cc (_Jv_MarkObj): Mark interpreter-related fields. Also, don't mark class->next field. * java/lang/VirtualMachineError.java: Added FIXME note. * configure.in (INTERPSPEC): New spec. * libgcj.spec.in: Added INTERPSPEC. * Makefile.am: Added gcjh friends for java/lang/VMClassLoader and gnu/gcj/runtime/MethodInvocation. (libgcj_la_SOURCES): Added resolve.cc defineclass.cc interpret.cc. (ordinary_java_source_files): Added above mentioned java classes. * configure: Rebuilt. * Makefile.in: Rebuilt. From-SVN: r28597
1999-08-08 16:06:23 +02:00
struct _Jv_mcache
{
[multiple changes] 1999-08-09 Anthony Green <green@cygnus.com> * gij.cc: New file. * include/config.h.in: Rebuilt. * acconfig.h: Add INTERPRETER. * configure: Rebuilt. * Makefile.in: Rebuilt. * Makefile.am (libffi_files): Identify the libffi object files for inclusion in libgcj. (LIBFFIINCS): Define. * interpret.cc (gnu::gcj::runtime::MethodInvocation::continue1): Dummy definition for configurations without an interpreter. * java/net/natPlainSocketImpl.cc (getOption): Disamiguate call to java::lang::Boolean constructor. * include/java-interp.h: Always include java-cpool.h. * java/lang/natClassLoader.cc (getVMClassLoader0): Always return 0 when INTERPRETER not defined. * java/lang/Class.h (finalize): Define. * gnu/gcj/util/path/DirectoryPathEntry.java (getURL): Catch IOException from File.getCanonicalPath. (getStream): Likewise. * NEWS: More news. * THANKS: More thanks. 1999-08-09 Kresten Krab Thorup <krab@gnu.org> * resolve.cc (get_ffi_type_from_signature): Generate uint16 for jchar type. (_Jv_PrepareClass): Allow non-abstract classes to have abstract subclasses. (_Jv_ResolvePoolEntry): Revert subclass check for protected fields and methods. * interpret.cc (continue1/perform_invoke): Don't sign extend uint16 return val. (continue1/lshl,lshr): Push long, not int. (continue1/ulshr): Use UINT64, not long long. * defineclass.cc (handleFieldsEnd): Handle case when all fields are static. * java/lang/natClass.cc (forName): Add call to _Jv_InitClass. * java/lang/FirstThread.java (run): Add top-level exception handler. (run0): Renamed from run. 1999-08-08 Kresten Krab Thorup <krab@gnu.org> * configure.in (--with-interpreter): Added. * include/config.h.in (INTERPRETER): Added. * java/lang/ClassLoader.java: File replaced. * java/lang/VMClassLoader.java: New file. * java/lang/natClassLoader.cc: New file. * gnu/gcj/runtime/MethodInvocation.java: New file. * gnu/gcj/util/path/SearchPath.java: New file. * gnu/gcj/util/path/PathEntry.java: New file. * gnu/gcj/util/path/DirectoryPathEntry.java: New file. * gnu/gcj/util/path/ZipPathEntry.java: New file. * gnu/gcj/util/path/URLPathEntry.java: New file. * gnu/gcj/util/path/CacheEntry.java: New file. * include/java-interp.h: New file. * include/java-cpool.h: New file. * include/java-insns.h: New file. * defineclass.cc: New file. * interpret.cc: New file. * resolve.cc: New file. * java/lang/natClass.cc (loaded_classes, _Jv_RegisterClass, _Jv_RegisterClasses, _Jv_FindClassInCache, _Jv_FindClass, _Jv_NewClass, _Jv_FindArrayClass): Moved to natClassLoader.cc. (finalize): New. (STATE_NOTHING, STATE_RESOLVED, STATE_IN_PROGRESS, STATE_DONE, STATE_ERROR): Moved to java/lang/Class.h and renamed with JV_ prefix. (initializeClass): Use new JV_ prefixed names. Also, call ClassLoader::resolveClass instead of _Jv_ResolveClass. * java/lang/Class.h (JV_STATE_PRELOADING, JV_STATE_LOADING, JV_STATE_LOADED, JV_STATE_COMPILED, JV_STATE_PREPARED, JV_STATE_LINKED): New. (_Jv_WaitForState, _Jv_RegisterInitiatingLoader, _Jv_UnregisterClass, _Jv_InternClassStrings): New friends. (_Jv_IsInterpretedClass, _Jv_InitField, _Jv_LookupDeclaredMethod, _Jv_DetermineVTableIndex, _Jv_ResolvePoolEntry, _Jv_PrepareClass, _Jv_ClassReader, _Jv_InterpClass, _Jv_InterpMethod, _Jv_InterpMethodInvocation): New friends for interpreter. (finalize): New. (CONSTANT_Class, CONSTANT_String, etc.): Moved to include/java-cpool.h and renamed with JV_ prefix. * include/jvm.h (_Jv_makeUtf8Const, _Jv_makeUtf8TypeConst): New decls. (_Jv_UnregisterClass): New decl. * java/lang/natClassLoader.cc (_Jv_FindArrayClass): Added class loader argument. (_Jv_FindClass): Use class loader. * prims.cc (_Jv_makeUtf8Const): New function. (_Jv_NewObjectArray): Change use of _Jv_FindArrayClass. (_Jv_NewPrimArray): Ditto. (_Jv_FindClassFromSignature): Ditto. * java/lang/reflect/natArray.cc (newInstance): Ditto. * java/lang/reflect/natMethod.cc (getType): Ditto. * include/java-field.h (_Jv_Field::isRef): Make robust for non-resolved contexts. * boehm.cc (_Jv_MarkObj): Mark interpreter-related fields. Also, don't mark class->next field. * java/lang/VirtualMachineError.java: Added FIXME note. * configure.in (INTERPSPEC): New spec. * libgcj.spec.in: Added INTERPSPEC. * Makefile.am: Added gcjh friends for java/lang/VMClassLoader and gnu/gcj/runtime/MethodInvocation. (libgcj_la_SOURCES): Added resolve.cc defineclass.cc interpret.cc. (ordinary_java_source_files): Added above mentioned java classes. * configure: Rebuilt. * Makefile.in: Rebuilt. From-SVN: r28597
1999-08-08 16:06:23 +02:00
jclass klass;
_Jv_Method *method;
};
static __thread _Jv_mcache *method_cache;
#endif // HAVE_TLS
[multiple changes] 1999-08-09 Anthony Green <green@cygnus.com> * gij.cc: New file. * include/config.h.in: Rebuilt. * acconfig.h: Add INTERPRETER. * configure: Rebuilt. * Makefile.in: Rebuilt. * Makefile.am (libffi_files): Identify the libffi object files for inclusion in libgcj. (LIBFFIINCS): Define. * interpret.cc (gnu::gcj::runtime::MethodInvocation::continue1): Dummy definition for configurations without an interpreter. * java/net/natPlainSocketImpl.cc (getOption): Disamiguate call to java::lang::Boolean constructor. * include/java-interp.h: Always include java-cpool.h. * java/lang/natClassLoader.cc (getVMClassLoader0): Always return 0 when INTERPRETER not defined. * java/lang/Class.h (finalize): Define. * gnu/gcj/util/path/DirectoryPathEntry.java (getURL): Catch IOException from File.getCanonicalPath. (getStream): Likewise. * NEWS: More news. * THANKS: More thanks. 1999-08-09 Kresten Krab Thorup <krab@gnu.org> * resolve.cc (get_ffi_type_from_signature): Generate uint16 for jchar type. (_Jv_PrepareClass): Allow non-abstract classes to have abstract subclasses. (_Jv_ResolvePoolEntry): Revert subclass check for protected fields and methods. * interpret.cc (continue1/perform_invoke): Don't sign extend uint16 return val. (continue1/lshl,lshr): Push long, not int. (continue1/ulshr): Use UINT64, not long long. * defineclass.cc (handleFieldsEnd): Handle case when all fields are static. * java/lang/natClass.cc (forName): Add call to _Jv_InitClass. * java/lang/FirstThread.java (run): Add top-level exception handler. (run0): Renamed from run. 1999-08-08 Kresten Krab Thorup <krab@gnu.org> * configure.in (--with-interpreter): Added. * include/config.h.in (INTERPRETER): Added. * java/lang/ClassLoader.java: File replaced. * java/lang/VMClassLoader.java: New file. * java/lang/natClassLoader.cc: New file. * gnu/gcj/runtime/MethodInvocation.java: New file. * gnu/gcj/util/path/SearchPath.java: New file. * gnu/gcj/util/path/PathEntry.java: New file. * gnu/gcj/util/path/DirectoryPathEntry.java: New file. * gnu/gcj/util/path/ZipPathEntry.java: New file. * gnu/gcj/util/path/URLPathEntry.java: New file. * gnu/gcj/util/path/CacheEntry.java: New file. * include/java-interp.h: New file. * include/java-cpool.h: New file. * include/java-insns.h: New file. * defineclass.cc: New file. * interpret.cc: New file. * resolve.cc: New file. * java/lang/natClass.cc (loaded_classes, _Jv_RegisterClass, _Jv_RegisterClasses, _Jv_FindClassInCache, _Jv_FindClass, _Jv_NewClass, _Jv_FindArrayClass): Moved to natClassLoader.cc. (finalize): New. (STATE_NOTHING, STATE_RESOLVED, STATE_IN_PROGRESS, STATE_DONE, STATE_ERROR): Moved to java/lang/Class.h and renamed with JV_ prefix. (initializeClass): Use new JV_ prefixed names. Also, call ClassLoader::resolveClass instead of _Jv_ResolveClass. * java/lang/Class.h (JV_STATE_PRELOADING, JV_STATE_LOADING, JV_STATE_LOADED, JV_STATE_COMPILED, JV_STATE_PREPARED, JV_STATE_LINKED): New. (_Jv_WaitForState, _Jv_RegisterInitiatingLoader, _Jv_UnregisterClass, _Jv_InternClassStrings): New friends. (_Jv_IsInterpretedClass, _Jv_InitField, _Jv_LookupDeclaredMethod, _Jv_DetermineVTableIndex, _Jv_ResolvePoolEntry, _Jv_PrepareClass, _Jv_ClassReader, _Jv_InterpClass, _Jv_InterpMethod, _Jv_InterpMethodInvocation): New friends for interpreter. (finalize): New. (CONSTANT_Class, CONSTANT_String, etc.): Moved to include/java-cpool.h and renamed with JV_ prefix. * include/jvm.h (_Jv_makeUtf8Const, _Jv_makeUtf8TypeConst): New decls. (_Jv_UnregisterClass): New decl. * java/lang/natClassLoader.cc (_Jv_FindArrayClass): Added class loader argument. (_Jv_FindClass): Use class loader. * prims.cc (_Jv_makeUtf8Const): New function. (_Jv_NewObjectArray): Change use of _Jv_FindArrayClass. (_Jv_NewPrimArray): Ditto. (_Jv_FindClassFromSignature): Ditto. * java/lang/reflect/natArray.cc (newInstance): Ditto. * java/lang/reflect/natMethod.cc (getType): Ditto. * include/java-field.h (_Jv_Field::isRef): Make robust for non-resolved contexts. * boehm.cc (_Jv_MarkObj): Mark interpreter-related fields. Also, don't mark class->next field. * java/lang/VirtualMachineError.java: Added FIXME note. * configure.in (INTERPSPEC): New spec. * libgcj.spec.in: Added INTERPSPEC. * Makefile.am: Added gcjh friends for java/lang/VMClassLoader and gnu/gcj/runtime/MethodInvocation. (libgcj_la_SOURCES): Added resolve.cc defineclass.cc interpret.cc. (ordinary_java_source_files): Added above mentioned java classes. * configure: Rebuilt. * Makefile.in: Rebuilt. From-SVN: r28597
1999-08-08 16:06:23 +02:00
static void *
_Jv_FindMethodInCache (jclass klass MAYBE_UNUSED,
_Jv_Utf8Const *name MAYBE_UNUSED,
_Jv_Utf8Const *signature MAYBE_UNUSED)
[multiple changes] 1999-08-09 Anthony Green <green@cygnus.com> * gij.cc: New file. * include/config.h.in: Rebuilt. * acconfig.h: Add INTERPRETER. * configure: Rebuilt. * Makefile.in: Rebuilt. * Makefile.am (libffi_files): Identify the libffi object files for inclusion in libgcj. (LIBFFIINCS): Define. * interpret.cc (gnu::gcj::runtime::MethodInvocation::continue1): Dummy definition for configurations without an interpreter. * java/net/natPlainSocketImpl.cc (getOption): Disamiguate call to java::lang::Boolean constructor. * include/java-interp.h: Always include java-cpool.h. * java/lang/natClassLoader.cc (getVMClassLoader0): Always return 0 when INTERPRETER not defined. * java/lang/Class.h (finalize): Define. * gnu/gcj/util/path/DirectoryPathEntry.java (getURL): Catch IOException from File.getCanonicalPath. (getStream): Likewise. * NEWS: More news. * THANKS: More thanks. 1999-08-09 Kresten Krab Thorup <krab@gnu.org> * resolve.cc (get_ffi_type_from_signature): Generate uint16 for jchar type. (_Jv_PrepareClass): Allow non-abstract classes to have abstract subclasses. (_Jv_ResolvePoolEntry): Revert subclass check for protected fields and methods. * interpret.cc (continue1/perform_invoke): Don't sign extend uint16 return val. (continue1/lshl,lshr): Push long, not int. (continue1/ulshr): Use UINT64, not long long. * defineclass.cc (handleFieldsEnd): Handle case when all fields are static. * java/lang/natClass.cc (forName): Add call to _Jv_InitClass. * java/lang/FirstThread.java (run): Add top-level exception handler. (run0): Renamed from run. 1999-08-08 Kresten Krab Thorup <krab@gnu.org> * configure.in (--with-interpreter): Added. * include/config.h.in (INTERPRETER): Added. * java/lang/ClassLoader.java: File replaced. * java/lang/VMClassLoader.java: New file. * java/lang/natClassLoader.cc: New file. * gnu/gcj/runtime/MethodInvocation.java: New file. * gnu/gcj/util/path/SearchPath.java: New file. * gnu/gcj/util/path/PathEntry.java: New file. * gnu/gcj/util/path/DirectoryPathEntry.java: New file. * gnu/gcj/util/path/ZipPathEntry.java: New file. * gnu/gcj/util/path/URLPathEntry.java: New file. * gnu/gcj/util/path/CacheEntry.java: New file. * include/java-interp.h: New file. * include/java-cpool.h: New file. * include/java-insns.h: New file. * defineclass.cc: New file. * interpret.cc: New file. * resolve.cc: New file. * java/lang/natClass.cc (loaded_classes, _Jv_RegisterClass, _Jv_RegisterClasses, _Jv_FindClassInCache, _Jv_FindClass, _Jv_NewClass, _Jv_FindArrayClass): Moved to natClassLoader.cc. (finalize): New. (STATE_NOTHING, STATE_RESOLVED, STATE_IN_PROGRESS, STATE_DONE, STATE_ERROR): Moved to java/lang/Class.h and renamed with JV_ prefix. (initializeClass): Use new JV_ prefixed names. Also, call ClassLoader::resolveClass instead of _Jv_ResolveClass. * java/lang/Class.h (JV_STATE_PRELOADING, JV_STATE_LOADING, JV_STATE_LOADED, JV_STATE_COMPILED, JV_STATE_PREPARED, JV_STATE_LINKED): New. (_Jv_WaitForState, _Jv_RegisterInitiatingLoader, _Jv_UnregisterClass, _Jv_InternClassStrings): New friends. (_Jv_IsInterpretedClass, _Jv_InitField, _Jv_LookupDeclaredMethod, _Jv_DetermineVTableIndex, _Jv_ResolvePoolEntry, _Jv_PrepareClass, _Jv_ClassReader, _Jv_InterpClass, _Jv_InterpMethod, _Jv_InterpMethodInvocation): New friends for interpreter. (finalize): New. (CONSTANT_Class, CONSTANT_String, etc.): Moved to include/java-cpool.h and renamed with JV_ prefix. * include/jvm.h (_Jv_makeUtf8Const, _Jv_makeUtf8TypeConst): New decls. (_Jv_UnregisterClass): New decl. * java/lang/natClassLoader.cc (_Jv_FindArrayClass): Added class loader argument. (_Jv_FindClass): Use class loader. * prims.cc (_Jv_makeUtf8Const): New function. (_Jv_NewObjectArray): Change use of _Jv_FindArrayClass. (_Jv_NewPrimArray): Ditto. (_Jv_FindClassFromSignature): Ditto. * java/lang/reflect/natArray.cc (newInstance): Ditto. * java/lang/reflect/natMethod.cc (getType): Ditto. * include/java-field.h (_Jv_Field::isRef): Make robust for non-resolved contexts. * boehm.cc (_Jv_MarkObj): Mark interpreter-related fields. Also, don't mark class->next field. * java/lang/VirtualMachineError.java: Added FIXME note. * configure.in (INTERPSPEC): New spec. * libgcj.spec.in: Added INTERPSPEC. * Makefile.am: Added gcjh friends for java/lang/VMClassLoader and gnu/gcj/runtime/MethodInvocation. (libgcj_la_SOURCES): Added resolve.cc defineclass.cc interpret.cc. (ordinary_java_source_files): Added above mentioned java classes. * configure: Rebuilt. * Makefile.in: Rebuilt. From-SVN: r28597
1999-08-08 16:06:23 +02:00
{
#ifdef HAVE_TLS
_Jv_mcache *cache = method_cache;
if (cache)
{
int index = name->hash16 () & MCACHE_SIZE;
_Jv_mcache *mc = &cache[index];
_Jv_Method *m = mc->method;
if (mc->klass == klass
&& _Jv_equalUtf8Consts (m->name, name)
&& _Jv_equalUtf8Consts (m->signature, signature))
return mc->method->ncode;
}
#endif // HAVE_TLS
[multiple changes] 1999-08-09 Anthony Green <green@cygnus.com> * gij.cc: New file. * include/config.h.in: Rebuilt. * acconfig.h: Add INTERPRETER. * configure: Rebuilt. * Makefile.in: Rebuilt. * Makefile.am (libffi_files): Identify the libffi object files for inclusion in libgcj. (LIBFFIINCS): Define. * interpret.cc (gnu::gcj::runtime::MethodInvocation::continue1): Dummy definition for configurations without an interpreter. * java/net/natPlainSocketImpl.cc (getOption): Disamiguate call to java::lang::Boolean constructor. * include/java-interp.h: Always include java-cpool.h. * java/lang/natClassLoader.cc (getVMClassLoader0): Always return 0 when INTERPRETER not defined. * java/lang/Class.h (finalize): Define. * gnu/gcj/util/path/DirectoryPathEntry.java (getURL): Catch IOException from File.getCanonicalPath. (getStream): Likewise. * NEWS: More news. * THANKS: More thanks. 1999-08-09 Kresten Krab Thorup <krab@gnu.org> * resolve.cc (get_ffi_type_from_signature): Generate uint16 for jchar type. (_Jv_PrepareClass): Allow non-abstract classes to have abstract subclasses. (_Jv_ResolvePoolEntry): Revert subclass check for protected fields and methods. * interpret.cc (continue1/perform_invoke): Don't sign extend uint16 return val. (continue1/lshl,lshr): Push long, not int. (continue1/ulshr): Use UINT64, not long long. * defineclass.cc (handleFieldsEnd): Handle case when all fields are static. * java/lang/natClass.cc (forName): Add call to _Jv_InitClass. * java/lang/FirstThread.java (run): Add top-level exception handler. (run0): Renamed from run. 1999-08-08 Kresten Krab Thorup <krab@gnu.org> * configure.in (--with-interpreter): Added. * include/config.h.in (INTERPRETER): Added. * java/lang/ClassLoader.java: File replaced. * java/lang/VMClassLoader.java: New file. * java/lang/natClassLoader.cc: New file. * gnu/gcj/runtime/MethodInvocation.java: New file. * gnu/gcj/util/path/SearchPath.java: New file. * gnu/gcj/util/path/PathEntry.java: New file. * gnu/gcj/util/path/DirectoryPathEntry.java: New file. * gnu/gcj/util/path/ZipPathEntry.java: New file. * gnu/gcj/util/path/URLPathEntry.java: New file. * gnu/gcj/util/path/CacheEntry.java: New file. * include/java-interp.h: New file. * include/java-cpool.h: New file. * include/java-insns.h: New file. * defineclass.cc: New file. * interpret.cc: New file. * resolve.cc: New file. * java/lang/natClass.cc (loaded_classes, _Jv_RegisterClass, _Jv_RegisterClasses, _Jv_FindClassInCache, _Jv_FindClass, _Jv_NewClass, _Jv_FindArrayClass): Moved to natClassLoader.cc. (finalize): New. (STATE_NOTHING, STATE_RESOLVED, STATE_IN_PROGRESS, STATE_DONE, STATE_ERROR): Moved to java/lang/Class.h and renamed with JV_ prefix. (initializeClass): Use new JV_ prefixed names. Also, call ClassLoader::resolveClass instead of _Jv_ResolveClass. * java/lang/Class.h (JV_STATE_PRELOADING, JV_STATE_LOADING, JV_STATE_LOADED, JV_STATE_COMPILED, JV_STATE_PREPARED, JV_STATE_LINKED): New. (_Jv_WaitForState, _Jv_RegisterInitiatingLoader, _Jv_UnregisterClass, _Jv_InternClassStrings): New friends. (_Jv_IsInterpretedClass, _Jv_InitField, _Jv_LookupDeclaredMethod, _Jv_DetermineVTableIndex, _Jv_ResolvePoolEntry, _Jv_PrepareClass, _Jv_ClassReader, _Jv_InterpClass, _Jv_InterpMethod, _Jv_InterpMethodInvocation): New friends for interpreter. (finalize): New. (CONSTANT_Class, CONSTANT_String, etc.): Moved to include/java-cpool.h and renamed with JV_ prefix. * include/jvm.h (_Jv_makeUtf8Const, _Jv_makeUtf8TypeConst): New decls. (_Jv_UnregisterClass): New decl. * java/lang/natClassLoader.cc (_Jv_FindArrayClass): Added class loader argument. (_Jv_FindClass): Use class loader. * prims.cc (_Jv_makeUtf8Const): New function. (_Jv_NewObjectArray): Change use of _Jv_FindArrayClass. (_Jv_NewPrimArray): Ditto. (_Jv_FindClassFromSignature): Ditto. * java/lang/reflect/natArray.cc (newInstance): Ditto. * java/lang/reflect/natMethod.cc (getType): Ditto. * include/java-field.h (_Jv_Field::isRef): Make robust for non-resolved contexts. * boehm.cc (_Jv_MarkObj): Mark interpreter-related fields. Also, don't mark class->next field. * java/lang/VirtualMachineError.java: Added FIXME note. * configure.in (INTERPSPEC): New spec. * libgcj.spec.in: Added INTERPSPEC. * Makefile.am: Added gcjh friends for java/lang/VMClassLoader and gnu/gcj/runtime/MethodInvocation. (libgcj_la_SOURCES): Added resolve.cc defineclass.cc interpret.cc. (ordinary_java_source_files): Added above mentioned java classes. * configure: Rebuilt. * Makefile.in: Rebuilt. From-SVN: r28597
1999-08-08 16:06:23 +02:00
return NULL;
}
static void
_Jv_AddMethodToCache (jclass klass MAYBE_UNUSED,
_Jv_Method *method MAYBE_UNUSED)
{
#ifdef HAVE_TLS
if (method_cache == NULL)
method_cache = (_Jv_mcache *) _Jv_MallocUnchecked((MCACHE_SIZE + 1)
* sizeof (_Jv_mcache));
// If the allocation failed, just keep going.
if (method_cache != NULL)
{
int index = method->name->hash16 () & MCACHE_SIZE;
method_cache[index].method = method;
method_cache[index].klass = klass;
}
#endif // HAVE_TLS
}
[multiple changes] 1999-08-09 Anthony Green <green@cygnus.com> * gij.cc: New file. * include/config.h.in: Rebuilt. * acconfig.h: Add INTERPRETER. * configure: Rebuilt. * Makefile.in: Rebuilt. * Makefile.am (libffi_files): Identify the libffi object files for inclusion in libgcj. (LIBFFIINCS): Define. * interpret.cc (gnu::gcj::runtime::MethodInvocation::continue1): Dummy definition for configurations without an interpreter. * java/net/natPlainSocketImpl.cc (getOption): Disamiguate call to java::lang::Boolean constructor. * include/java-interp.h: Always include java-cpool.h. * java/lang/natClassLoader.cc (getVMClassLoader0): Always return 0 when INTERPRETER not defined. * java/lang/Class.h (finalize): Define. * gnu/gcj/util/path/DirectoryPathEntry.java (getURL): Catch IOException from File.getCanonicalPath. (getStream): Likewise. * NEWS: More news. * THANKS: More thanks. 1999-08-09 Kresten Krab Thorup <krab@gnu.org> * resolve.cc (get_ffi_type_from_signature): Generate uint16 for jchar type. (_Jv_PrepareClass): Allow non-abstract classes to have abstract subclasses. (_Jv_ResolvePoolEntry): Revert subclass check for protected fields and methods. * interpret.cc (continue1/perform_invoke): Don't sign extend uint16 return val. (continue1/lshl,lshr): Push long, not int. (continue1/ulshr): Use UINT64, not long long. * defineclass.cc (handleFieldsEnd): Handle case when all fields are static. * java/lang/natClass.cc (forName): Add call to _Jv_InitClass. * java/lang/FirstThread.java (run): Add top-level exception handler. (run0): Renamed from run. 1999-08-08 Kresten Krab Thorup <krab@gnu.org> * configure.in (--with-interpreter): Added. * include/config.h.in (INTERPRETER): Added. * java/lang/ClassLoader.java: File replaced. * java/lang/VMClassLoader.java: New file. * java/lang/natClassLoader.cc: New file. * gnu/gcj/runtime/MethodInvocation.java: New file. * gnu/gcj/util/path/SearchPath.java: New file. * gnu/gcj/util/path/PathEntry.java: New file. * gnu/gcj/util/path/DirectoryPathEntry.java: New file. * gnu/gcj/util/path/ZipPathEntry.java: New file. * gnu/gcj/util/path/URLPathEntry.java: New file. * gnu/gcj/util/path/CacheEntry.java: New file. * include/java-interp.h: New file. * include/java-cpool.h: New file. * include/java-insns.h: New file. * defineclass.cc: New file. * interpret.cc: New file. * resolve.cc: New file. * java/lang/natClass.cc (loaded_classes, _Jv_RegisterClass, _Jv_RegisterClasses, _Jv_FindClassInCache, _Jv_FindClass, _Jv_NewClass, _Jv_FindArrayClass): Moved to natClassLoader.cc. (finalize): New. (STATE_NOTHING, STATE_RESOLVED, STATE_IN_PROGRESS, STATE_DONE, STATE_ERROR): Moved to java/lang/Class.h and renamed with JV_ prefix. (initializeClass): Use new JV_ prefixed names. Also, call ClassLoader::resolveClass instead of _Jv_ResolveClass. * java/lang/Class.h (JV_STATE_PRELOADING, JV_STATE_LOADING, JV_STATE_LOADED, JV_STATE_COMPILED, JV_STATE_PREPARED, JV_STATE_LINKED): New. (_Jv_WaitForState, _Jv_RegisterInitiatingLoader, _Jv_UnregisterClass, _Jv_InternClassStrings): New friends. (_Jv_IsInterpretedClass, _Jv_InitField, _Jv_LookupDeclaredMethod, _Jv_DetermineVTableIndex, _Jv_ResolvePoolEntry, _Jv_PrepareClass, _Jv_ClassReader, _Jv_InterpClass, _Jv_InterpMethod, _Jv_InterpMethodInvocation): New friends for interpreter. (finalize): New. (CONSTANT_Class, CONSTANT_String, etc.): Moved to include/java-cpool.h and renamed with JV_ prefix. * include/jvm.h (_Jv_makeUtf8Const, _Jv_makeUtf8TypeConst): New decls. (_Jv_UnregisterClass): New decl. * java/lang/natClassLoader.cc (_Jv_FindArrayClass): Added class loader argument. (_Jv_FindClass): Use class loader. * prims.cc (_Jv_makeUtf8Const): New function. (_Jv_NewObjectArray): Change use of _Jv_FindArrayClass. (_Jv_NewPrimArray): Ditto. (_Jv_FindClassFromSignature): Ditto. * java/lang/reflect/natArray.cc (newInstance): Ditto. * java/lang/reflect/natMethod.cc (getType): Ditto. * include/java-field.h (_Jv_Field::isRef): Make robust for non-resolved contexts. * boehm.cc (_Jv_MarkObj): Mark interpreter-related fields. Also, don't mark class->next field. * java/lang/VirtualMachineError.java: Added FIXME note. * configure.in (INTERPSPEC): New spec. * libgcj.spec.in: Added INTERPSPEC. * Makefile.am: Added gcjh friends for java/lang/VMClassLoader and gnu/gcj/runtime/MethodInvocation. (libgcj_la_SOURCES): Added resolve.cc defineclass.cc interpret.cc. (ordinary_java_source_files): Added above mentioned java classes. * configure: Rebuilt. * Makefile.in: Rebuilt. From-SVN: r28597
1999-08-08 16:06:23 +02:00
// Free this thread's method cache. We explicitly manage this memory
// as the GC does not yet know how to scan TLS on all platforms.
void
_Jv_FreeMethodCache ()
{
#ifdef HAVE_TLS
if (method_cache != NULL)
{
_Jv_Free(method_cache);
method_cache = NULL;
}
#endif // HAVE_TLS
[multiple changes] 1999-08-09 Anthony Green <green@cygnus.com> * gij.cc: New file. * include/config.h.in: Rebuilt. * acconfig.h: Add INTERPRETER. * configure: Rebuilt. * Makefile.in: Rebuilt. * Makefile.am (libffi_files): Identify the libffi object files for inclusion in libgcj. (LIBFFIINCS): Define. * interpret.cc (gnu::gcj::runtime::MethodInvocation::continue1): Dummy definition for configurations without an interpreter. * java/net/natPlainSocketImpl.cc (getOption): Disamiguate call to java::lang::Boolean constructor. * include/java-interp.h: Always include java-cpool.h. * java/lang/natClassLoader.cc (getVMClassLoader0): Always return 0 when INTERPRETER not defined. * java/lang/Class.h (finalize): Define. * gnu/gcj/util/path/DirectoryPathEntry.java (getURL): Catch IOException from File.getCanonicalPath. (getStream): Likewise. * NEWS: More news. * THANKS: More thanks. 1999-08-09 Kresten Krab Thorup <krab@gnu.org> * resolve.cc (get_ffi_type_from_signature): Generate uint16 for jchar type. (_Jv_PrepareClass): Allow non-abstract classes to have abstract subclasses. (_Jv_ResolvePoolEntry): Revert subclass check for protected fields and methods. * interpret.cc (continue1/perform_invoke): Don't sign extend uint16 return val. (continue1/lshl,lshr): Push long, not int. (continue1/ulshr): Use UINT64, not long long. * defineclass.cc (handleFieldsEnd): Handle case when all fields are static. * java/lang/natClass.cc (forName): Add call to _Jv_InitClass. * java/lang/FirstThread.java (run): Add top-level exception handler. (run0): Renamed from run. 1999-08-08 Kresten Krab Thorup <krab@gnu.org> * configure.in (--with-interpreter): Added. * include/config.h.in (INTERPRETER): Added. * java/lang/ClassLoader.java: File replaced. * java/lang/VMClassLoader.java: New file. * java/lang/natClassLoader.cc: New file. * gnu/gcj/runtime/MethodInvocation.java: New file. * gnu/gcj/util/path/SearchPath.java: New file. * gnu/gcj/util/path/PathEntry.java: New file. * gnu/gcj/util/path/DirectoryPathEntry.java: New file. * gnu/gcj/util/path/ZipPathEntry.java: New file. * gnu/gcj/util/path/URLPathEntry.java: New file. * gnu/gcj/util/path/CacheEntry.java: New file. * include/java-interp.h: New file. * include/java-cpool.h: New file. * include/java-insns.h: New file. * defineclass.cc: New file. * interpret.cc: New file. * resolve.cc: New file. * java/lang/natClass.cc (loaded_classes, _Jv_RegisterClass, _Jv_RegisterClasses, _Jv_FindClassInCache, _Jv_FindClass, _Jv_NewClass, _Jv_FindArrayClass): Moved to natClassLoader.cc. (finalize): New. (STATE_NOTHING, STATE_RESOLVED, STATE_IN_PROGRESS, STATE_DONE, STATE_ERROR): Moved to java/lang/Class.h and renamed with JV_ prefix. (initializeClass): Use new JV_ prefixed names. Also, call ClassLoader::resolveClass instead of _Jv_ResolveClass. * java/lang/Class.h (JV_STATE_PRELOADING, JV_STATE_LOADING, JV_STATE_LOADED, JV_STATE_COMPILED, JV_STATE_PREPARED, JV_STATE_LINKED): New. (_Jv_WaitForState, _Jv_RegisterInitiatingLoader, _Jv_UnregisterClass, _Jv_InternClassStrings): New friends. (_Jv_IsInterpretedClass, _Jv_InitField, _Jv_LookupDeclaredMethod, _Jv_DetermineVTableIndex, _Jv_ResolvePoolEntry, _Jv_PrepareClass, _Jv_ClassReader, _Jv_InterpClass, _Jv_InterpMethod, _Jv_InterpMethodInvocation): New friends for interpreter. (finalize): New. (CONSTANT_Class, CONSTANT_String, etc.): Moved to include/java-cpool.h and renamed with JV_ prefix. * include/jvm.h (_Jv_makeUtf8Const, _Jv_makeUtf8TypeConst): New decls. (_Jv_UnregisterClass): New decl. * java/lang/natClassLoader.cc (_Jv_FindArrayClass): Added class loader argument. (_Jv_FindClass): Use class loader. * prims.cc (_Jv_makeUtf8Const): New function. (_Jv_NewObjectArray): Change use of _Jv_FindArrayClass. (_Jv_NewPrimArray): Ditto. (_Jv_FindClassFromSignature): Ditto. * java/lang/reflect/natArray.cc (newInstance): Ditto. * java/lang/reflect/natMethod.cc (getType): Ditto. * include/java-field.h (_Jv_Field::isRef): Make robust for non-resolved contexts. * boehm.cc (_Jv_MarkObj): Mark interpreter-related fields. Also, don't mark class->next field. * java/lang/VirtualMachineError.java: Added FIXME note. * configure.in (INTERPSPEC): New spec. * libgcj.spec.in: Added INTERPSPEC. * Makefile.am: Added gcjh friends for java/lang/VMClassLoader and gnu/gcj/runtime/MethodInvocation. (libgcj_la_SOURCES): Added resolve.cc defineclass.cc interpret.cc. (ordinary_java_source_files): Added above mentioned java classes. * configure: Rebuilt. * Makefile.in: Rebuilt. From-SVN: r28597
1999-08-08 16:06:23 +02:00
}
1999-04-07 16:42:40 +02:00
void *
_Jv_LookupInterfaceMethod (jclass klass, _Jv_Utf8Const *name,
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
_Jv_Utf8Const *signature)
1999-04-07 16:42:40 +02:00
{
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
using namespace java::lang::reflect;
[multiple changes] 1999-08-09 Anthony Green <green@cygnus.com> * gij.cc: New file. * include/config.h.in: Rebuilt. * acconfig.h: Add INTERPRETER. * configure: Rebuilt. * Makefile.in: Rebuilt. * Makefile.am (libffi_files): Identify the libffi object files for inclusion in libgcj. (LIBFFIINCS): Define. * interpret.cc (gnu::gcj::runtime::MethodInvocation::continue1): Dummy definition for configurations without an interpreter. * java/net/natPlainSocketImpl.cc (getOption): Disamiguate call to java::lang::Boolean constructor. * include/java-interp.h: Always include java-cpool.h. * java/lang/natClassLoader.cc (getVMClassLoader0): Always return 0 when INTERPRETER not defined. * java/lang/Class.h (finalize): Define. * gnu/gcj/util/path/DirectoryPathEntry.java (getURL): Catch IOException from File.getCanonicalPath. (getStream): Likewise. * NEWS: More news. * THANKS: More thanks. 1999-08-09 Kresten Krab Thorup <krab@gnu.org> * resolve.cc (get_ffi_type_from_signature): Generate uint16 for jchar type. (_Jv_PrepareClass): Allow non-abstract classes to have abstract subclasses. (_Jv_ResolvePoolEntry): Revert subclass check for protected fields and methods. * interpret.cc (continue1/perform_invoke): Don't sign extend uint16 return val. (continue1/lshl,lshr): Push long, not int. (continue1/ulshr): Use UINT64, not long long. * defineclass.cc (handleFieldsEnd): Handle case when all fields are static. * java/lang/natClass.cc (forName): Add call to _Jv_InitClass. * java/lang/FirstThread.java (run): Add top-level exception handler. (run0): Renamed from run. 1999-08-08 Kresten Krab Thorup <krab@gnu.org> * configure.in (--with-interpreter): Added. * include/config.h.in (INTERPRETER): Added. * java/lang/ClassLoader.java: File replaced. * java/lang/VMClassLoader.java: New file. * java/lang/natClassLoader.cc: New file. * gnu/gcj/runtime/MethodInvocation.java: New file. * gnu/gcj/util/path/SearchPath.java: New file. * gnu/gcj/util/path/PathEntry.java: New file. * gnu/gcj/util/path/DirectoryPathEntry.java: New file. * gnu/gcj/util/path/ZipPathEntry.java: New file. * gnu/gcj/util/path/URLPathEntry.java: New file. * gnu/gcj/util/path/CacheEntry.java: New file. * include/java-interp.h: New file. * include/java-cpool.h: New file. * include/java-insns.h: New file. * defineclass.cc: New file. * interpret.cc: New file. * resolve.cc: New file. * java/lang/natClass.cc (loaded_classes, _Jv_RegisterClass, _Jv_RegisterClasses, _Jv_FindClassInCache, _Jv_FindClass, _Jv_NewClass, _Jv_FindArrayClass): Moved to natClassLoader.cc. (finalize): New. (STATE_NOTHING, STATE_RESOLVED, STATE_IN_PROGRESS, STATE_DONE, STATE_ERROR): Moved to java/lang/Class.h and renamed with JV_ prefix. (initializeClass): Use new JV_ prefixed names. Also, call ClassLoader::resolveClass instead of _Jv_ResolveClass. * java/lang/Class.h (JV_STATE_PRELOADING, JV_STATE_LOADING, JV_STATE_LOADED, JV_STATE_COMPILED, JV_STATE_PREPARED, JV_STATE_LINKED): New. (_Jv_WaitForState, _Jv_RegisterInitiatingLoader, _Jv_UnregisterClass, _Jv_InternClassStrings): New friends. (_Jv_IsInterpretedClass, _Jv_InitField, _Jv_LookupDeclaredMethod, _Jv_DetermineVTableIndex, _Jv_ResolvePoolEntry, _Jv_PrepareClass, _Jv_ClassReader, _Jv_InterpClass, _Jv_InterpMethod, _Jv_InterpMethodInvocation): New friends for interpreter. (finalize): New. (CONSTANT_Class, CONSTANT_String, etc.): Moved to include/java-cpool.h and renamed with JV_ prefix. * include/jvm.h (_Jv_makeUtf8Const, _Jv_makeUtf8TypeConst): New decls. (_Jv_UnregisterClass): New decl. * java/lang/natClassLoader.cc (_Jv_FindArrayClass): Added class loader argument. (_Jv_FindClass): Use class loader. * prims.cc (_Jv_makeUtf8Const): New function. (_Jv_NewObjectArray): Change use of _Jv_FindArrayClass. (_Jv_NewPrimArray): Ditto. (_Jv_FindClassFromSignature): Ditto. * java/lang/reflect/natArray.cc (newInstance): Ditto. * java/lang/reflect/natMethod.cc (getType): Ditto. * include/java-field.h (_Jv_Field::isRef): Make robust for non-resolved contexts. * boehm.cc (_Jv_MarkObj): Mark interpreter-related fields. Also, don't mark class->next field. * java/lang/VirtualMachineError.java: Added FIXME note. * configure.in (INTERPSPEC): New spec. * libgcj.spec.in: Added INTERPSPEC. * Makefile.am: Added gcjh friends for java/lang/VMClassLoader and gnu/gcj/runtime/MethodInvocation. (libgcj_la_SOURCES): Added resolve.cc defineclass.cc interpret.cc. (ordinary_java_source_files): Added above mentioned java classes. * configure: Rebuilt. * Makefile.in: Rebuilt. From-SVN: r28597
1999-08-08 16:06:23 +02:00
void *ncode = _Jv_FindMethodInCache (klass, name, signature);
if (ncode != 0)
return ncode;
1999-04-07 16:42:40 +02:00
for (; klass; klass = klass->getSuperclass())
{
_Jv_Method *meth = _Jv_GetMethodLocal (klass, name, signature);
if (! meth)
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
continue;
if (Modifier::isStatic(meth->accflags))
throw new java::lang::IncompatibleClassChangeError
(_Jv_GetMethodString (klass, meth));
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
if (Modifier::isAbstract(meth->accflags))
throw new java::lang::AbstractMethodError
(_Jv_GetMethodString (klass, meth));
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
if (! Modifier::isPublic(meth->accflags))
throw new java::lang::IllegalAccessError
(_Jv_GetMethodString (klass, meth));
1999-04-07 16:42:40 +02:00
[multiple changes] 1999-08-09 Anthony Green <green@cygnus.com> * gij.cc: New file. * include/config.h.in: Rebuilt. * acconfig.h: Add INTERPRETER. * configure: Rebuilt. * Makefile.in: Rebuilt. * Makefile.am (libffi_files): Identify the libffi object files for inclusion in libgcj. (LIBFFIINCS): Define. * interpret.cc (gnu::gcj::runtime::MethodInvocation::continue1): Dummy definition for configurations without an interpreter. * java/net/natPlainSocketImpl.cc (getOption): Disamiguate call to java::lang::Boolean constructor. * include/java-interp.h: Always include java-cpool.h. * java/lang/natClassLoader.cc (getVMClassLoader0): Always return 0 when INTERPRETER not defined. * java/lang/Class.h (finalize): Define. * gnu/gcj/util/path/DirectoryPathEntry.java (getURL): Catch IOException from File.getCanonicalPath. (getStream): Likewise. * NEWS: More news. * THANKS: More thanks. 1999-08-09 Kresten Krab Thorup <krab@gnu.org> * resolve.cc (get_ffi_type_from_signature): Generate uint16 for jchar type. (_Jv_PrepareClass): Allow non-abstract classes to have abstract subclasses. (_Jv_ResolvePoolEntry): Revert subclass check for protected fields and methods. * interpret.cc (continue1/perform_invoke): Don't sign extend uint16 return val. (continue1/lshl,lshr): Push long, not int. (continue1/ulshr): Use UINT64, not long long. * defineclass.cc (handleFieldsEnd): Handle case when all fields are static. * java/lang/natClass.cc (forName): Add call to _Jv_InitClass. * java/lang/FirstThread.java (run): Add top-level exception handler. (run0): Renamed from run. 1999-08-08 Kresten Krab Thorup <krab@gnu.org> * configure.in (--with-interpreter): Added. * include/config.h.in (INTERPRETER): Added. * java/lang/ClassLoader.java: File replaced. * java/lang/VMClassLoader.java: New file. * java/lang/natClassLoader.cc: New file. * gnu/gcj/runtime/MethodInvocation.java: New file. * gnu/gcj/util/path/SearchPath.java: New file. * gnu/gcj/util/path/PathEntry.java: New file. * gnu/gcj/util/path/DirectoryPathEntry.java: New file. * gnu/gcj/util/path/ZipPathEntry.java: New file. * gnu/gcj/util/path/URLPathEntry.java: New file. * gnu/gcj/util/path/CacheEntry.java: New file. * include/java-interp.h: New file. * include/java-cpool.h: New file. * include/java-insns.h: New file. * defineclass.cc: New file. * interpret.cc: New file. * resolve.cc: New file. * java/lang/natClass.cc (loaded_classes, _Jv_RegisterClass, _Jv_RegisterClasses, _Jv_FindClassInCache, _Jv_FindClass, _Jv_NewClass, _Jv_FindArrayClass): Moved to natClassLoader.cc. (finalize): New. (STATE_NOTHING, STATE_RESOLVED, STATE_IN_PROGRESS, STATE_DONE, STATE_ERROR): Moved to java/lang/Class.h and renamed with JV_ prefix. (initializeClass): Use new JV_ prefixed names. Also, call ClassLoader::resolveClass instead of _Jv_ResolveClass. * java/lang/Class.h (JV_STATE_PRELOADING, JV_STATE_LOADING, JV_STATE_LOADED, JV_STATE_COMPILED, JV_STATE_PREPARED, JV_STATE_LINKED): New. (_Jv_WaitForState, _Jv_RegisterInitiatingLoader, _Jv_UnregisterClass, _Jv_InternClassStrings): New friends. (_Jv_IsInterpretedClass, _Jv_InitField, _Jv_LookupDeclaredMethod, _Jv_DetermineVTableIndex, _Jv_ResolvePoolEntry, _Jv_PrepareClass, _Jv_ClassReader, _Jv_InterpClass, _Jv_InterpMethod, _Jv_InterpMethodInvocation): New friends for interpreter. (finalize): New. (CONSTANT_Class, CONSTANT_String, etc.): Moved to include/java-cpool.h and renamed with JV_ prefix. * include/jvm.h (_Jv_makeUtf8Const, _Jv_makeUtf8TypeConst): New decls. (_Jv_UnregisterClass): New decl. * java/lang/natClassLoader.cc (_Jv_FindArrayClass): Added class loader argument. (_Jv_FindClass): Use class loader. * prims.cc (_Jv_makeUtf8Const): New function. (_Jv_NewObjectArray): Change use of _Jv_FindArrayClass. (_Jv_NewPrimArray): Ditto. (_Jv_FindClassFromSignature): Ditto. * java/lang/reflect/natArray.cc (newInstance): Ditto. * java/lang/reflect/natMethod.cc (getType): Ditto. * include/java-field.h (_Jv_Field::isRef): Make robust for non-resolved contexts. * boehm.cc (_Jv_MarkObj): Mark interpreter-related fields. Also, don't mark class->next field. * java/lang/VirtualMachineError.java: Added FIXME note. * configure.in (INTERPSPEC): New spec. * libgcj.spec.in: Added INTERPSPEC. * Makefile.am: Added gcjh friends for java/lang/VMClassLoader and gnu/gcj/runtime/MethodInvocation. (libgcj_la_SOURCES): Added resolve.cc defineclass.cc interpret.cc. (ordinary_java_source_files): Added above mentioned java classes. * configure: Rebuilt. * Makefile.in: Rebuilt. From-SVN: r28597
1999-08-08 16:06:23 +02:00
_Jv_AddMethodToCache (klass, meth);
1999-04-07 16:42:40 +02:00
return meth->ncode;
}
throw new java::lang::IncompatibleClassChangeError;
1999-04-07 16:42:40 +02:00
}
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
// Fast interface method lookup by index.
void *
_Jv_LookupInterfaceMethodIdx (jclass klass, jclass iface, int method_idx)
{
_Jv_IDispatchTable *cldt = klass->idt;
int idx = iface->ioffsets[cldt->iindex] + method_idx;
return cldt->itable[idx];
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
}
jboolean
_Jv_IsAssignableFrom (jclass source, jclass target)
1999-04-07 16:42:40 +02:00
{
if (source == target)
return true;
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
// If target is array, so must source be.
while (target->isArray ())
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
{
if (! source->isArray())
return false;
target = target->getComponentType();
source = source->getComponentType();
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
}
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
if (target->isInterface())
{
// Abstract classes have no IDT, and IDTs provide no way to check
// two interfaces for assignability.
if (__builtin_expect
In gcc/java: * class.c (make_class_data): Push initial value for "arrayclass". * decl.c (init_decl_processing): Add new class field "arrayclass". In libjava: * java/lang/Class.h (_Jv_InitClass): Use __builtin_expect. (_Jv_NewArrayClass): Renamed from _Jv_FindArrayClass. (_Jv_GetArrayClass): New inline function. (arrayclass): New field. * prims.cc (_Jv_NewObjectArray): Use _Jv_GetArrayClass. Don't use _Jv_GetArrayElementFromElementType. (_Jv_NewPrimArray): Ditto. (_Jv_PrimClass constructor): Initialize "depth", "ancestors", and "idt" for completeness. Initialze "arrayclass" using _Jv_NewArrayClass. Set Modifier::ABSTRACT. * java/lang/natClassLoader.cc (_Jv_NewClass): Initialize "arrayclass". (_Jv_NewArrayClass): Renamed from _Jv_FindArrayClass. Now void. Now synchronized. Array classes are now referenced from elementClass->arrayclass. Don't use _Jv_FindClassInCache. Set array classes' accessibility flags correctly. Optimize so that all array classes share the same IDT. * java/lang/reflect/natArray.cc (newInstance): Use _Jv_GetArrayClass. * java/lang/reflect/natMethod.cc (_Jv_GetTypesFromSignature): Ditto. * java/lang/natClass.cc (_getFields): Increment offset. Prevent fields in superclasses from overwriting classes own fields. (_Jv_IsAssignableFrom): Check for NULL source idt instead of calling Modifier::isAbstract(). (null_idt): New static field. (_Jv_PrepareConstantTimeTables): Optimize case where class implements no interfaces. (_Jv_IndexOf): Made inline. * boehm.cc (_Jv_MarkObj): Mark "arrayclass" field. From-SVN: r38808
2001-01-09 00:28:56 +01:00
(source->idt == NULL || source->isInterface(), false))
return _Jv_InterfaceAssignableFrom (source, target);
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
_Jv_IDispatchTable *cl_idt = source->idt;
if (__builtin_expect ((target->ioffsets == NULL), false))
return false; // No class implementing TARGET has been loaded.
jshort cl_iindex = cl_idt->iindex;
if (cl_iindex < target->ioffsets[0])
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
{
jshort offset = target->ioffsets[cl_iindex];
if (offset != -1 && offset < cl_idt->itable_length
&& cl_idt->itable[offset] == target)
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
return true;
}
return false;
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
}
// Primitive TYPE classes are only assignable to themselves.
if (__builtin_expect (target->isPrimitive() || source->isPrimitive(), false))
return false;
if (target == &java::lang::Object::class$)
return true;
else if (source->ancestors == NULL || target->ancestors == NULL)
{
// We need this case when either SOURCE or TARGET has not has
// its constant-time tables prepared.
// At this point we know that TARGET can't be Object, so it is
// safe to use that as the termination point.
while (source && source != &java::lang::Object::class$)
{
if (source == target)
return true;
source = source->getSuperclass();
}
}
else if (source->depth >= target->depth
&& source->ancestors[source->depth - target->depth] == target)
return true;
return false;
1999-04-07 16:42:40 +02:00
}
// Interface type checking, the slow way. Returns TRUE if IFACE is a
// superinterface of SOURCE. This is used when SOURCE is also an interface,
// or a class with no interface dispatch table.
jboolean
_Jv_InterfaceAssignableFrom (jclass source, jclass iface)
{
for (int i = 0; i < source->interface_count; i++)
{
jclass interface = source->interfaces[i];
if (iface == interface
|| _Jv_InterfaceAssignableFrom (interface, iface))
return true;
}
if (!source->isInterface()
&& source->superclass
&& _Jv_InterfaceAssignableFrom (source->superclass, iface))
return true;
return false;
}
1999-04-07 16:42:40 +02:00
jboolean
_Jv_IsInstanceOf(jobject obj, jclass cl)
{
if (__builtin_expect (!obj, false))
return false;
return _Jv_IsAssignableFrom (JV_CLASS (obj), cl);
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
}
void *
_Jv_CheckCast (jclass c, jobject obj)
{
if (__builtin_expect
(obj != NULL && ! _Jv_IsAssignableFrom(JV_CLASS (obj), c), false))
throw new java::lang::ClassCastException
((new java::lang::StringBuffer
(obj->getClass()->getName()))->append
(JvNewStringUTF(" cannot be cast to "))->append
(c->getName())->toString());
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
return obj;
}
void
_Jv_CheckArrayStore (jobject arr, jobject obj)
{
if (obj)
{
JvAssert (arr != NULL);
jclass elt_class = (JV_CLASS (arr))->getComponentType();
natClassLoader.cc (_Jv_PrepareCompiledClass): Call _Jv_PushClass. 2002-12-03 Andrew Haley <aph@redhat.com> * java/lang/natClassLoader.cc (_Jv_PrepareCompiledClass): Call _Jv_PushClass. (_Jv_InitNewClassFields): Set protectionDomain and chain = NULL. (_Jv_PopClass): New. (_Jv_PushClass): New. * java/lang/natClass.cc (forName (jstring)): Use a StackTrace to discover the ClassLoader of our caller. (_Jv_CheckArrayStore): Don't check that a class is assignment compatible with Object. * java/lang/natVMTHrowable.cc: Delete. * gnu/gcj/runtime/StackTrace.java: New, partly copied from java.lang.VMThrowable. (StackTrace(), StackTrace(int)): New constructors. (classAt, methodAt, update, methodAtAddress): New methods. (map): New field. * java/lang/VMThrowable.java: Use StackTrace instead of natVMTHrowable. * java/lang/Class.h (getClassLoaderInternal): New. (class Class): Be friendly with _Jv_PopClass and _Jv_PushClass. Be friendly with gnu::gcj::runtime::StackTrace. (Object.chain): New field. * include/java-interp.h (class _Jv_InterpMethod): Be friendly with gnu::gcj::runtime::StackTrace. * prims.cc (_Jv_NewObjectArray): Use getClassLoaderInternal() instead of getClassLoader(). * verify.cc (class _Jv_BytecodeVerifier): Likewise. java::lang::VMThrowable. * Makefile.am (core_java_source_files): Add MethodRef.java, StackTrace.java. (nat_source_files): Remove natVMThrowable.cc; add natStackTrace.cc. * Makefile.in: Rebuild. 2002-12-03 Andrew Haley <aph@redhat.com> * class.c (make_class_data): New field, "chain". * decl.c (java_init_decl_processing): Likewise. From-SVN: r59769
2002-12-03 14:50:05 +01:00
if (elt_class == &java::lang::Object::class$)
return;
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
jclass obj_class = JV_CLASS (obj);
if (__builtin_expect
(! _Jv_IsAssignableFrom (obj_class, elt_class), false))
throw new java::lang::ArrayStoreException
((new java::lang::StringBuffer
(JvNewStringUTF("Cannot store ")))->append
(obj_class->getName())->append
(JvNewStringUTF(" in array of type "))->append
(elt_class->getName())->toString());
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
}
}
jboolean
_Jv_IsAssignableFromSlow (jclass source, jclass target)
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
{
// First, strip arrays.
while (target->isArray ())
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
{
// If target is array, source must be as well.
if (! source->isArray ())
return false;
target = target->getComponentType ();
source = source->getComponentType ();
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
}
// Quick success.
if (target == &java::lang::Object::class$)
return true;
// Ensure that the classes have their supers installed.
_Jv_Linker::wait_for_state (source, JV_STATE_LOADING);
_Jv_Linker::wait_for_state (target, JV_STATE_LOADING);
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
do
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
{
if (source == target)
return true;
if (target->isPrimitive () || source->isPrimitive ())
return false;
if (target->isInterface ())
{
for (int i = 0; i < source->interface_count; ++i)
{
// We use a recursive call because we also need to
// check superinterfaces.
if (_Jv_IsAssignableFromSlow (source->getInterface (i), target))
return true;
}
}
source = source->getSuperclass ();
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
}
while (source != NULL);
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
return false;
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
}
// Lookup an interface method by name. This is very similar to
// purpose to _getMethod, but the interfaces are quite different. It
// might be a good idea for _getMethod to call this function.
resolve.cc (_Jv_SearchMethodInClass): New function. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * resolve.cc (_Jv_SearchMethodInClass): New function. (_Jv_ResolvePoolEntry): Search superinterfaces for interface methods. * java/lang/Class.h (_Jv_SearchMethodInClass): New prototype. 2000-03-07 Bryce McKinlay <bryce@albatross.co.nz> * java/lang/Class.h (union _Jv_IDispatchTable): New declaration. (struct _Jv_ifaces): New declaration. JV_CLASS: New macro definition. (getComponentType): Relocate below isArray() for inlining. (getModifiers): Declare `inline'. (getSuperclass): Ditto. (isArray): Ditto. (isPrimitive): Ditto. (_Jv_IsAssignableFrom): New prototype. (_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C" linkage. (_Jv_InitClass): Move from natClass.cc. Declare `inline'. Check for JV_STATE_DONE before invoking initializeClass(). (_Jv_PrepareConstantTimeTables): New prototype. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. (_Jv_FindIIndex): Ditto. depth, ancestors, idt: New class fields. * java/lang/natClass.cc (isAssignableFrom): Move functionality to inline function `_Jv_IsAssignableFrom'. Use that function. (isInstance): Declare `inline'. (initializeClass): Get lock on class before checking `state'. Unlock before calling resolveClass0. Call _Jv_PrepareConstantTimeTables with the lock held. (_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString. (_Jv_IsAssignableFrom): New inline function. Test assignability using class->depth and ancestor table. (_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom. (_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and _Jv_IsAssignableFrom. (_Jv_CheckArrayStore): Ditto. (_Jv_LookupInterfaceMethodIdx): New function. INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines. (_Jv_PrepareConstantTimeTables): New function. (_Jv_IndexOf): Ditto. (_Jv_GetInterfaces): Ditto. (_Jv_GenerateITable): Ditto. (_Jv_GetMethodString): Ditto. (_Jv_AppendPartialITable): Ditto. iindex_mutex, iindex_mutex_initialized: New static fields. (_Jv_FindIIndex): New function. * java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields. * prims.cc (_Jv_CheckCast): Moved to natClass.cc. (_Jv_CheckArrayStore): Ditto. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Moved to gcj/array.h. (_Jv_Realloc): New function. * gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h. * gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h. (JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray): Implementations moved from prims.cc and declared `inline'. * gcj/javaprims.h (_Jv_Realloc): Prototype. * include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype. From-SVN: r32382
2000-03-07 10:52:56 +01:00
//
// Return true of the method is found, with the class in FOUND_CLASS
// and the index in INDEX.
bool
_Jv_getInterfaceMethod (jclass search_class, jclass &found_class, int &index,
const _Jv_Utf8Const *utf_name,
const _Jv_Utf8Const *utf_sig)
{
for (jclass klass = search_class; klass; klass = klass->getSuperclass())
{
// FIXME: Throw an exception?
if (!klass->isInterface ())
return false;
int max = klass->method_count;
int offset = 0;
for (int i = 0; i < max; ++i)
{
// Skip <clinit> here, as it will not be in the IDT.
if (klass->methods[i].name->first() == '<')
continue;
if (_Jv_equalUtf8Consts (klass->methods[i].name, utf_name)
&& _Jv_equalUtf8Consts (klass->methods[i].signature, utf_sig))
{
// Found it.
using namespace java::lang::reflect;
// FIXME: Method must be public. Throw an exception?
if (! Modifier::isPublic (klass->methods[i].accflags))
break;
lang.c (LANG_HOOKS_GET_CALLEE_FNDECL): New. 2003-10-22 Andrew Haley <aph@redhat.com> * lang.c (LANG_HOOKS_GET_CALLEE_FNDECL): New. (java_get_callee_fndecl): New. * jcf-parse.c (java_parse_file): Call emit_catch_table(). * java-tree.h (ctable_decl): New. (catch_classes): New. (java_tree_index): Add JTI_CTABLE_DECL, JTI_CATCH_CLASSES. * decl.c (java_init_decl_processing): Add catch_class_type. Add ctable_decl. Add catch_classes field. * class.c (build_indirect_class_ref): Break out from build_class_ref. (make_field_value): Check flag_indirect_dispatch. (make_class_data): Ditto. Tidy uses of PUSH_FIELD_VALUE. Add field catch_classes. (make_catch_class_record): New. * java-tree.h (PUSH_FIELD_VALUE): Tidy. 2003-10-22 Andrew Haley <aph@redhat.com> * java/lang/natClass.cc (initializeClass): Call _Jv_linkExceptionClassTable. (_Jv_LinkSymbolTable): Call )_Jv_ThrowNoSuchMethodError. Call _Jv_Defer_Resolution on a method whose ncode is NULL. (_Jv_linkExceptionClassTable): New function. (_Jv_LayoutVTableMethods): If superclass looks like a constant pool entry, look it up. * java/lang/Class.h (struct _Jv_CatchClass): New. (_Jv_linkExceptionClassTable): New friend. (_Jv_Defer_Resolution): New friend. (class Class.catch_classes): New field. * include/java-interp.h (Jv_Defer_Resolution): New method. (_Jv_PrepareClass): Make a friend of _Jv_MethodBase. (_Jv_MethodBase.deferred): New field. (_Jv_Defer_Resolution): New function. * resolve.cc (_Jv_PrepareClass): Resolve deferred handlers. * exception.cc (get_ttype_entry): Change return type to void**. (PERSONALITY_FUNCTION): Remove all code related to using a Utf8Const* for a match type. Change match type to be a pointer to a pointer, rather than a pointer to a Class. * defineclass.cc (handleCodeAttribute): Initialize method->deferred. (handleMethodsEnd): Likewise. From-SVN: r72886
2003-10-24 11:29:43 +02:00
found_class = klass;
// Interface method indexes count from 1.
index = offset + 1;
return true;
lang.c (LANG_HOOKS_GET_CALLEE_FNDECL): New. 2003-10-22 Andrew Haley <aph@redhat.com> * lang.c (LANG_HOOKS_GET_CALLEE_FNDECL): New. (java_get_callee_fndecl): New. * jcf-parse.c (java_parse_file): Call emit_catch_table(). * java-tree.h (ctable_decl): New. (catch_classes): New. (java_tree_index): Add JTI_CTABLE_DECL, JTI_CATCH_CLASSES. * decl.c (java_init_decl_processing): Add catch_class_type. Add ctable_decl. Add catch_classes field. * class.c (build_indirect_class_ref): Break out from build_class_ref. (make_field_value): Check flag_indirect_dispatch. (make_class_data): Ditto. Tidy uses of PUSH_FIELD_VALUE. Add field catch_classes. (make_catch_class_record): New. * java-tree.h (PUSH_FIELD_VALUE): Tidy. 2003-10-22 Andrew Haley <aph@redhat.com> * java/lang/natClass.cc (initializeClass): Call _Jv_linkExceptionClassTable. (_Jv_LinkSymbolTable): Call )_Jv_ThrowNoSuchMethodError. Call _Jv_Defer_Resolution on a method whose ncode is NULL. (_Jv_linkExceptionClassTable): New function. (_Jv_LayoutVTableMethods): If superclass looks like a constant pool entry, look it up. * java/lang/Class.h (struct _Jv_CatchClass): New. (_Jv_linkExceptionClassTable): New friend. (_Jv_Defer_Resolution): New friend. (class Class.catch_classes): New field. * include/java-interp.h (Jv_Defer_Resolution): New method. (_Jv_PrepareClass): Make a friend of _Jv_MethodBase. (_Jv_MethodBase.deferred): New field. (_Jv_Defer_Resolution): New function. * resolve.cc (_Jv_PrepareClass): Resolve deferred handlers. * exception.cc (get_ttype_entry): Change return type to void**. (PERSONALITY_FUNCTION): Remove all code related to using a Utf8Const* for a match type. Change match type to be a pointer to a pointer, rather than a pointer to a Class. * defineclass.cc (handleCodeAttribute): Initialize method->deferred. (handleMethodsEnd): Likewise. From-SVN: r72886
2003-10-24 11:29:43 +02:00
}
++offset;
lang.c (LANG_HOOKS_GET_CALLEE_FNDECL): New. 2003-10-22 Andrew Haley <aph@redhat.com> * lang.c (LANG_HOOKS_GET_CALLEE_FNDECL): New. (java_get_callee_fndecl): New. * jcf-parse.c (java_parse_file): Call emit_catch_table(). * java-tree.h (ctable_decl): New. (catch_classes): New. (java_tree_index): Add JTI_CTABLE_DECL, JTI_CATCH_CLASSES. * decl.c (java_init_decl_processing): Add catch_class_type. Add ctable_decl. Add catch_classes field. * class.c (build_indirect_class_ref): Break out from build_class_ref. (make_field_value): Check flag_indirect_dispatch. (make_class_data): Ditto. Tidy uses of PUSH_FIELD_VALUE. Add field catch_classes. (make_catch_class_record): New. * java-tree.h (PUSH_FIELD_VALUE): Tidy. 2003-10-22 Andrew Haley <aph@redhat.com> * java/lang/natClass.cc (initializeClass): Call _Jv_linkExceptionClassTable. (_Jv_LinkSymbolTable): Call )_Jv_ThrowNoSuchMethodError. Call _Jv_Defer_Resolution on a method whose ncode is NULL. (_Jv_linkExceptionClassTable): New function. (_Jv_LayoutVTableMethods): If superclass looks like a constant pool entry, look it up. * java/lang/Class.h (struct _Jv_CatchClass): New. (_Jv_linkExceptionClassTable): New friend. (_Jv_Defer_Resolution): New friend. (class Class.catch_classes): New field. * include/java-interp.h (Jv_Defer_Resolution): New method. (_Jv_PrepareClass): Make a friend of _Jv_MethodBase. (_Jv_MethodBase.deferred): New field. (_Jv_Defer_Resolution): New function. * resolve.cc (_Jv_PrepareClass): Resolve deferred handlers. * exception.cc (get_ttype_entry): Change return type to void**. (PERSONALITY_FUNCTION): Remove all code related to using a Utf8Const* for a match type. Change match type to be a pointer to a pointer, rather than a pointer to a Class. * defineclass.cc (handleCodeAttribute): Initialize method->deferred. (handleMethodsEnd): Likewise. From-SVN: r72886
2003-10-24 11:29:43 +02:00
}
java-tree.h (otable_methods, [...]): New field/global tree definitions. gcc/java: * java-tree.h (otable_methods, otable_decl, otable_syms_decl, otable_type, otable_ptr_type, method_symbol_type, method_symbols_array_type, method_symbols_array_ptr_type): New field/global tree definitions. (flag_indirect_dispatch): New flag. * decl.c (java_init_decl_processing): Initialize new otable and otable_syms type nodes and decls. Add new field "index" to method_type_node. * class.c (build_method_symbols_entry): New function. (make_method_value): Set "index" to to method's vtable index for virtual methods when indirect-dispatch is not used. (make_class_data): For indirect-dispatch, dont emit the dtable_decl, and set vtable_method_count to -1. Set otable and otable_syms field if indirect-dispatch is used and there was something to put in them. (build_method_symbols_entry): New function. (emit_offset_symbol_table): New function. * expr.c (get_offset_table_index): New function. (build_invokevirtual): Build array reference to otable at the index returned by get_offset_table_index, and use the result as the vtable offset. (build_invokeinterface): Similar. * jcf-parse.c (yyparse): If indirect-dispatch, call emit_offset_symbol_table at the end of compilation, after all classes have been generated. * jvspec.c: Don't pass findirect-dispatch to jvgenmain. * lang.c (flag_indirect_dispatch): Define. (lang_f_options): Add indirect-dispatch flag. libjava: * include/jvm.h (_Jv_VTable::idx_to_offset): New method. * java/lang/natClassLoader.cc (_Jv_PrepareCompiledClass): Call _Jv_MakeVTable and _Jv_LinkOffsetTable if needed. * java/lang/Class.h (_Jv_Method): Add "index" field. (_Jv_MethodSymbol): New struct type. (_Jv_LinkOffsetTable, _Jv_LayoutVTableMethods, _Jv_SetVTableEntries, _Jv_MakeVTable): Friends. (otable, otable_syms): New Class fields. * java/lang/natClass.cc (_Jv_LinkOffsetTable): New function. (isVirtualMethod): New static function. (_Jv_LayoutVTableMethods): New function. (_Jv_SetVTableEntries): New function. (_Jv_MakeVTable): New function. From-SVN: r48038
2001-12-15 09:31:49 +01:00
}
// If we haven't found a match, and this class is an interface, then
// check all the superinterfaces.
if (search_class->isInterface())
java-tree.h (otable_methods, [...]): New field/global tree definitions. gcc/java: * java-tree.h (otable_methods, otable_decl, otable_syms_decl, otable_type, otable_ptr_type, method_symbol_type, method_symbols_array_type, method_symbols_array_ptr_type): New field/global tree definitions. (flag_indirect_dispatch): New flag. * decl.c (java_init_decl_processing): Initialize new otable and otable_syms type nodes and decls. Add new field "index" to method_type_node. * class.c (build_method_symbols_entry): New function. (make_method_value): Set "index" to to method's vtable index for virtual methods when indirect-dispatch is not used. (make_class_data): For indirect-dispatch, dont emit the dtable_decl, and set vtable_method_count to -1. Set otable and otable_syms field if indirect-dispatch is used and there was something to put in them. (build_method_symbols_entry): New function. (emit_offset_symbol_table): New function. * expr.c (get_offset_table_index): New function. (build_invokevirtual): Build array reference to otable at the index returned by get_offset_table_index, and use the result as the vtable offset. (build_invokeinterface): Similar. * jcf-parse.c (yyparse): If indirect-dispatch, call emit_offset_symbol_table at the end of compilation, after all classes have been generated. * jvspec.c: Don't pass findirect-dispatch to jvgenmain. * lang.c (flag_indirect_dispatch): Define. (lang_f_options): Add indirect-dispatch flag. libjava: * include/jvm.h (_Jv_VTable::idx_to_offset): New method. * java/lang/natClassLoader.cc (_Jv_PrepareCompiledClass): Call _Jv_MakeVTable and _Jv_LinkOffsetTable if needed. * java/lang/Class.h (_Jv_Method): Add "index" field. (_Jv_MethodSymbol): New struct type. (_Jv_LinkOffsetTable, _Jv_LayoutVTableMethods, _Jv_SetVTableEntries, _Jv_MakeVTable): Friends. (otable, otable_syms): New Class fields. * java/lang/natClass.cc (_Jv_LinkOffsetTable): New function. (isVirtualMethod): New static function. (_Jv_LayoutVTableMethods): New function. (_Jv_SetVTableEntries): New function. (_Jv_MakeVTable): New function. From-SVN: r48038
2001-12-15 09:31:49 +01:00
{
for (int i = 0; i < search_class->interface_count; ++i)
{
using namespace java::lang::reflect;
bool found = _Jv_getInterfaceMethod (search_class->interfaces[i],
found_class, index,
utf_name, utf_sig);
if (found)
return true;
}
java-tree.h (otable_methods, [...]): New field/global tree definitions. gcc/java: * java-tree.h (otable_methods, otable_decl, otable_syms_decl, otable_type, otable_ptr_type, method_symbol_type, method_symbols_array_type, method_symbols_array_ptr_type): New field/global tree definitions. (flag_indirect_dispatch): New flag. * decl.c (java_init_decl_processing): Initialize new otable and otable_syms type nodes and decls. Add new field "index" to method_type_node. * class.c (build_method_symbols_entry): New function. (make_method_value): Set "index" to to method's vtable index for virtual methods when indirect-dispatch is not used. (make_class_data): For indirect-dispatch, dont emit the dtable_decl, and set vtable_method_count to -1. Set otable and otable_syms field if indirect-dispatch is used and there was something to put in them. (build_method_symbols_entry): New function. (emit_offset_symbol_table): New function. * expr.c (get_offset_table_index): New function. (build_invokevirtual): Build array reference to otable at the index returned by get_offset_table_index, and use the result as the vtable offset. (build_invokeinterface): Similar. * jcf-parse.c (yyparse): If indirect-dispatch, call emit_offset_symbol_table at the end of compilation, after all classes have been generated. * jvspec.c: Don't pass findirect-dispatch to jvgenmain. * lang.c (flag_indirect_dispatch): Define. (lang_f_options): Add indirect-dispatch flag. libjava: * include/jvm.h (_Jv_VTable::idx_to_offset): New method. * java/lang/natClassLoader.cc (_Jv_PrepareCompiledClass): Call _Jv_MakeVTable and _Jv_LinkOffsetTable if needed. * java/lang/Class.h (_Jv_Method): Add "index" field. (_Jv_MethodSymbol): New struct type. (_Jv_LinkOffsetTable, _Jv_LayoutVTableMethods, _Jv_SetVTableEntries, _Jv_MakeVTable): Friends. (otable, otable_syms): New Class fields. * java/lang/natClass.cc (_Jv_LinkOffsetTable): New function. (isVirtualMethod): New static function. (_Jv_LayoutVTableMethods): New function. (_Jv_SetVTableEntries): New function. (_Jv_MakeVTable): New function. From-SVN: r48038
2001-12-15 09:31:49 +01:00
}
return false;
java-tree.h (otable_methods, [...]): New field/global tree definitions. gcc/java: * java-tree.h (otable_methods, otable_decl, otable_syms_decl, otable_type, otable_ptr_type, method_symbol_type, method_symbols_array_type, method_symbols_array_ptr_type): New field/global tree definitions. (flag_indirect_dispatch): New flag. * decl.c (java_init_decl_processing): Initialize new otable and otable_syms type nodes and decls. Add new field "index" to method_type_node. * class.c (build_method_symbols_entry): New function. (make_method_value): Set "index" to to method's vtable index for virtual methods when indirect-dispatch is not used. (make_class_data): For indirect-dispatch, dont emit the dtable_decl, and set vtable_method_count to -1. Set otable and otable_syms field if indirect-dispatch is used and there was something to put in them. (build_method_symbols_entry): New function. (emit_offset_symbol_table): New function. * expr.c (get_offset_table_index): New function. (build_invokevirtual): Build array reference to otable at the index returned by get_offset_table_index, and use the result as the vtable offset. (build_invokeinterface): Similar. * jcf-parse.c (yyparse): If indirect-dispatch, call emit_offset_symbol_table at the end of compilation, after all classes have been generated. * jvspec.c: Don't pass findirect-dispatch to jvgenmain. * lang.c (flag_indirect_dispatch): Define. (lang_f_options): Add indirect-dispatch flag. libjava: * include/jvm.h (_Jv_VTable::idx_to_offset): New method. * java/lang/natClassLoader.cc (_Jv_PrepareCompiledClass): Call _Jv_MakeVTable and _Jv_LinkOffsetTable if needed. * java/lang/Class.h (_Jv_Method): Add "index" field. (_Jv_MethodSymbol): New struct type. (_Jv_LinkOffsetTable, _Jv_LayoutVTableMethods, _Jv_SetVTableEntries, _Jv_MakeVTable): Friends. (otable, otable_syms): New Class fields. * java/lang/natClass.cc (_Jv_LinkOffsetTable): New function. (isVirtualMethod): New static function. (_Jv_LayoutVTableMethods): New function. (_Jv_SetVTableEntries): New function. (_Jv_MakeVTable): New function. From-SVN: r48038
2001-12-15 09:31:49 +01:00
}
#ifdef INTERPRETER
_Jv_MethodBase *
_Jv_FindInterpreterMethod (jclass klass, jmethodID desired_method)
{
using namespace java::lang::reflect;
_Jv_InterpClass *iclass
= reinterpret_cast<_Jv_InterpClass *> (klass->aux_info);
_Jv_MethodBase **imethods = _Jv_GetFirstMethod (iclass);
for (int i = 0; i < JvNumMethods (klass); ++i)
{
_Jv_MethodBase *imeth = imethods[i];
if (imeth->get_method () == desired_method)
return imeth;
}
return NULL;
}
#endif
// Return Utf8 name of a class. This function is here for code that
// can't access klass->name directly.
_Jv_Utf8Const*
_Jv_GetClassNameUtf8 (jclass klass)
{
return klass->name;
}
jclass
_Jv_GetMethodDeclaringClass (jmethodID method)
{
_Jv_StackTrace::UpdateNCodeMap ();
jobject obj = reinterpret_cast<jobject> (method->ncode);
return reinterpret_cast<jclass> (_Jv_StackTrace::ncodeMap->get (obj));
}
jbyte
_Jv_GetClassState (jclass klass)
{
return klass->state;
}
configure.ac (INTERPRETER): New AM_CONDITIONAL. * configure.ac (INTERPRETER): New AM_CONDITIONAL. * scripts/makemake.tcl (package_map): Mark jdwp and jvmti packages as being for interpreter only. Place interpreter related files in 'if INTERPRETER' block. (interpreter_package_files): New list. (interpreter_header_vars): Ditto. (emit_package_rule_to_list): Renamed from emit_package_rule with new target list parameter. (emit_package_rule): Rewritten to call emit_package_rule_to_list. (emit_interpreter_rule): New function. (emit_source_var): Place interpreter related files in interpreter_header_vars. * Makefile.am (ACLOCAL_AMFLAGS): Add -I libltdl. (libgcj_interpret_source_files): New variable. (libgcj_la_SOURCES): Move jvmti.cc and interpret.cc to libgcj_interpret_source_files and include libgcj_interpret_source_files. (nat_jdwp_source_files): New variable. (nat_jvmti_source_files): Ditto. (nat_source_files): Move jdwp and jvmti related files to nat_jdwp_source_files and nat_jvmti_source_files and include nat_jdwp_source_files and nat_jvmti_source_files. * Makefile.in: Regenerate. * include/Makefile.in: Ditto. * testsuite/Makefile.in: Ditto. * gcj/Makefile.in: Ditto. * sources.am: Ditto. * configure: Ditto. * include/config.h.in: Ditto. * interpret.cc: Remove #ifdef INTERPRETER block. * stacktrace.cc (UnwindTraceFn): Do not handle proxy frames if interpreter disabled. * include/java-interp.h (_Jv_FrameType): Move outside of #ifdef INTERPRETER block. * include/execution.h (_Jv_IndirectCompiledEngine::do_get_closure_list, _Jv_InterpreterEngine, _Jv_soleInterpreterEngine): Place in #ifdef INTERPRETER block. * jni.cc (jvmti.h, jvmti-int.h): Only include if INTERPRETER is defined. (_Jv_JNI_PopSystemFrame, _Jv_JNI_GetEnv): Only do jvmti processing if INTERPRETER is defined. * prims.cc (jvmti.h, jvmti-int.h, Jdwp.h, VMVirtualMachine.h): Only include if INTERPRETER is defined. (defaultJdwpOptions, jdwpOptions, jvmti_agent_onload_func, jvmti_agent_onunload_func, jvmti_agentonload, jvmti_agentonunload, jvmti_agent_opts, load_jvmti_agent): Only define if INTERPRETER is defined. (parse_x_arg): Only process 'runjdwp:' if INTERPRETER is defined. (parse_init_args): Only process jvmti related options if INTERPRETER is defined. (_Jv_CreateJavaVM): Only call _Jv_JVMTI_Init if INTERPRETER is defined. (_Jv_RunMain): Only do jvmti and jdwp processing if INTERPRETER is defined. * link.cc (jvmti.h, jvmti-int.h): Only include if INTERPRETER is defined. (_Jv_ThrowNoClassDefFoundError, _Jv_Linker::create_error_method): Define if if INTERPRETER is not defined. (_Jv_Linker::wait_for_state): Only do jvmti proccessing if INTERPRETER is defined. * boehm.cc (closure_list_pointer, finalize_closure_list, _Jv_ClosureListFinalizer): Only define if INTERPRETER is defined. * java/lang/natThread.cc (jvmti.h, jvmti-int.h): Only include if INTERPRETER is defined. (finish_, _Jv_NotifyThreadStart): Only do jvmti proccessing if INTERPRETER is defined. * java/lang/Class.h (_Jv_InterpreterEngine): Move declaration and friend declaration inside #ifdef INTERPRETER block. * java/lang/natClass.cc (_Jv_ClosureList::releaseClosures, _Jv_ClosureList::registerClosure, _Jv_GetInterpClassSourceFile): Only define if INTERPRETER is defined. * java/lang/reflect/natVMProxy.cc (UnsupportedOperationException.h): Include. (generateProxyClass): Throw UnsupportedOperationException unless INTERPRETER is defined. From-SVN: r127097
2007-07-31 18:17:21 +02:00
#ifdef INTERPRETER
jstring
_Jv_GetInterpClassSourceFile (jclass klass)
{
if (_Jv_IsInterpretedClass (klass))
{
_Jv_InterpClass *iclass =
reinterpret_cast<_Jv_InterpClass *> (klass->aux_info);
return iclass->source_file_name;
}
return NULL;
}
configure.ac (INTERPRETER): New AM_CONDITIONAL. * configure.ac (INTERPRETER): New AM_CONDITIONAL. * scripts/makemake.tcl (package_map): Mark jdwp and jvmti packages as being for interpreter only. Place interpreter related files in 'if INTERPRETER' block. (interpreter_package_files): New list. (interpreter_header_vars): Ditto. (emit_package_rule_to_list): Renamed from emit_package_rule with new target list parameter. (emit_package_rule): Rewritten to call emit_package_rule_to_list. (emit_interpreter_rule): New function. (emit_source_var): Place interpreter related files in interpreter_header_vars. * Makefile.am (ACLOCAL_AMFLAGS): Add -I libltdl. (libgcj_interpret_source_files): New variable. (libgcj_la_SOURCES): Move jvmti.cc and interpret.cc to libgcj_interpret_source_files and include libgcj_interpret_source_files. (nat_jdwp_source_files): New variable. (nat_jvmti_source_files): Ditto. (nat_source_files): Move jdwp and jvmti related files to nat_jdwp_source_files and nat_jvmti_source_files and include nat_jdwp_source_files and nat_jvmti_source_files. * Makefile.in: Regenerate. * include/Makefile.in: Ditto. * testsuite/Makefile.in: Ditto. * gcj/Makefile.in: Ditto. * sources.am: Ditto. * configure: Ditto. * include/config.h.in: Ditto. * interpret.cc: Remove #ifdef INTERPRETER block. * stacktrace.cc (UnwindTraceFn): Do not handle proxy frames if interpreter disabled. * include/java-interp.h (_Jv_FrameType): Move outside of #ifdef INTERPRETER block. * include/execution.h (_Jv_IndirectCompiledEngine::do_get_closure_list, _Jv_InterpreterEngine, _Jv_soleInterpreterEngine): Place in #ifdef INTERPRETER block. * jni.cc (jvmti.h, jvmti-int.h): Only include if INTERPRETER is defined. (_Jv_JNI_PopSystemFrame, _Jv_JNI_GetEnv): Only do jvmti processing if INTERPRETER is defined. * prims.cc (jvmti.h, jvmti-int.h, Jdwp.h, VMVirtualMachine.h): Only include if INTERPRETER is defined. (defaultJdwpOptions, jdwpOptions, jvmti_agent_onload_func, jvmti_agent_onunload_func, jvmti_agentonload, jvmti_agentonunload, jvmti_agent_opts, load_jvmti_agent): Only define if INTERPRETER is defined. (parse_x_arg): Only process 'runjdwp:' if INTERPRETER is defined. (parse_init_args): Only process jvmti related options if INTERPRETER is defined. (_Jv_CreateJavaVM): Only call _Jv_JVMTI_Init if INTERPRETER is defined. (_Jv_RunMain): Only do jvmti and jdwp processing if INTERPRETER is defined. * link.cc (jvmti.h, jvmti-int.h): Only include if INTERPRETER is defined. (_Jv_ThrowNoClassDefFoundError, _Jv_Linker::create_error_method): Define if if INTERPRETER is not defined. (_Jv_Linker::wait_for_state): Only do jvmti proccessing if INTERPRETER is defined. * boehm.cc (closure_list_pointer, finalize_closure_list, _Jv_ClosureListFinalizer): Only define if INTERPRETER is defined. * java/lang/natThread.cc (jvmti.h, jvmti-int.h): Only include if INTERPRETER is defined. (finish_, _Jv_NotifyThreadStart): Only do jvmti proccessing if INTERPRETER is defined. * java/lang/Class.h (_Jv_InterpreterEngine): Move declaration and friend declaration inside #ifdef INTERPRETER block. * java/lang/natClass.cc (_Jv_ClosureList::releaseClosures, _Jv_ClosureList::registerClosure, _Jv_GetInterpClassSourceFile): Only define if INTERPRETER is defined. * java/lang/reflect/natVMProxy.cc (UnsupportedOperationException.h): Include. (generateProxyClass): Throw UnsupportedOperationException unless INTERPRETER is defined. From-SVN: r127097
2007-07-31 18:17:21 +02:00
#endif