harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gshiman...@apache.org
Subject svn commit: r486456 - in /harmony/enhanced/drlvm/trunk/vm: include/open/ vmcore/include/ vmcore/src/class_support/ vmcore/src/gc/ vmcore/src/jni/ vmcore/src/reflection/
Date Wed, 13 Dec 2006 02:18:01 GMT
Author: gshimansky
Date: Tue Dec 12 18:17:58 2006
New Revision: 486456

URL: http://svn.apache.org/viewvc?view=rev&rev=486456
Log:
Applied HARMONY-2083 [drlvm] Synchronization problem in class resolution code

Tests passed on Ubuntu6 x86, Windows XP and SuSE9 x86_64


Modified:
    harmony/enhanced/drlvm/trunk/vm/include/open/vm.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/Class.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/classloader.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Initialize.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Prepare.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Resolve.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/root_set_enum_common.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_utils.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/reflection/annotations.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/reflection/reflection.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/include/open/vm.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/include/open/vm.h?view=diff&rev=486456&r1=486455&r2=486456
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/include/open/vm.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/include/open/vm.h Tue Dec 12 18:17:58 2006
@@ -564,12 +564,6 @@
 // class handle for the array type (not the element type).
 VMEXPORT Class_Handle type_info_get_class(Type_Info_Handle tih);
 
-// Returns loading error (jthrowable) from classloader. This function is only
-// valid after type_info_get_class. If type_info_get_class returned no runtime
-// exception then loading error happened which should be obtained by this
-// function.
-VMEXPORT Managed_Object_Handle* type_info_get_loading_error(Type_Info_Handle tih);
-
 // Get the method signature if type_info_is_method_pointer returned TRUE.
 VMEXPORT Method_Signature_Handle type_info_get_method_sig(Type_Info_Handle tih);
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/Class.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/Class.h?view=diff&rev=486456&r1=486455&r2=486456
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/Class.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/Class.h Tue Dec 12 18:17:58 2006
@@ -601,17 +601,11 @@
             || is_fieldref(index)
             || is_methodref(index)
             || is_interfacemethodref(index));
-        // ppervov: 'if' clause is changed to 'assert' expression as this
-        // should never happen, i.e. class resolution should never try
-        // to resolve failed entry twice
-        // ppervov: if(!cp.is_entry_in_error(cp_index)) {
-        assert(!is_entry_in_error(index));
         set_entry_error_state(index);
         m_entries[index].error.cause = *((ManagedObject**)exn);
         m_entries[index].error.next = m_failedResolution;
         assert(&(m_entries[index]) != m_failedResolution);
         m_failedResolution = &(m_entries[index]);
-        // ppervov: }
     }
 
     /** Parses in a constant pool for a class.
@@ -661,7 +655,8 @@
         // in class resolution
         //assert(!is_entry_resolved(index));
         // we should not resolve failed entries
-        assert(!is_entry_in_error(index));
+        // see comment above
+        //assert(!is_entry_in_error(index));
         m_entries[0].tags[index] |= RESOLVED_MASK;
     }
 
@@ -674,7 +669,8 @@
         // in class resolution
         //assert(!is_entry_resolved(index));
         // we do not want to reset the reason of the failure
-        assert(!is_entry_in_error(index));
+        // see comment above
+        //assert(!is_entry_in_error(index));
         m_entries[0].tags[index] |= ERROR_MASK;
     }
 
@@ -1005,10 +1001,6 @@
     // thread, which currently executes <clinit>
     VM_thread* m_initializing_thread;
 
-    // error, which is the cause of changing class state to ST_Error
-    // enumeratable as static field
-    ManagedObject* m_error;
-
     // Notify JITs whenever tis class is extended by calling their
     // JIT_extended_class_callback callback function,
     Class_Extended_Notification_Record* m_notify_extended_records;
@@ -1346,14 +1338,6 @@
      * @return A collection of annotations.*/
     AnnotationTable* get_annotations() const { return m_annotations; }
 
-    /** Gets a handle of exception making the class change its state
-     * to <code>ST_Error</code>.
-     * @return A handle of exception.*/
-    jthrowable get_error_cause() const {
-        assert(in_error());
-        return (jthrowable)(&m_error);
-    }
-
     /** Gets a class instance size.
      * @return A size of the allocated instance in bytes.*/
     unsigned int get_allocated_size() const { return m_allocated_size; }
@@ -1531,11 +1515,6 @@
      * @param[in] oh - a class handle of <code>java.lang.Class</code>*/
     void set_class_handle(ManagedObject** oh) { m_class_handle = oh; }
 
-    /** Records a cause of changing state to <code>ST_Error</code> for the given
-     * class.
-     * @param[in] exn - an exception object with error*/
-    void set_error_cause(jthrowable exn);
-
     /** Constructs internal representation of a class from the byte array
      * (defines class).
      * @param[in] env - VM environment
@@ -1931,11 +1910,6 @@
  * @param[in] jlc - instance of java/lang/Class to retrieve class from.
  * @return Native class from instance of java/lang/Class.*/
 Class* java_lang_Class_to_struct_Class(ManagedObject* jlc);
-/** Gets loading error for a class with the given name.
- * @param[in] cl - class loader which attempted to load the class.
- * @param[in] name - name of a class which loading had failed.
- * @return Exception describing class loading failure.*/
-jthrowable class_get_error(ClassLoaderHandle cl, const char* name);
 
 /** Looks up field in class and its superclasses.
  * @param[in] clss - class to lookup field in.

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/classloader.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/classloader.h?view=diff&rev=486456&r1=486455&r2=486456
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/classloader.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/classloader.h Tue Dec 12 18:17:58 2006
@@ -57,18 +57,6 @@
 
 struct ClassLoader
 {
-    struct FailedClass
-    {
-        // class name
-        const String* m_name;
-        // exception object
-        ManagedObject* m_exception;
-
-        FailedClass() : m_name(NULL), m_exception(NULL) {}
-        FailedClass(const FailedClass& fc) : m_name(fc.m_name), m_exception(fc.m_exception)
{}
-        bool operator == (FailedClass& fc) { return m_name == fc.m_name; }
-    };
-
     struct LoadingClass
     {
         struct WaitingThread {
@@ -155,11 +143,9 @@
     };
 
 public:
-    friend LoggerString& operator << (LoggerString& log, FailedClass& lc);
     friend LoggerString& operator << (LoggerString& log, LoadingClass&
lc);
 
 private:
-    class FailedClasses : public MapEx<const String*, FailedClass> {};
     class LoadingClasses : public MapEx<const String*, LoadingClass > {};
     class ReportedClasses : public MapEx<const String*, ManagedObject* > {};
 
@@ -168,9 +154,9 @@
     friend class GlobalClassLoaderIterator;
 public:
     ClassLoader() : m_loader(NULL), m_parent(NULL), m_package_table(NULL), 
-        m_loadedClasses(NULL), m_failedClasses(NULL), 
-        m_loadingClasses(NULL), m_reportedClasses(NULL), m_javaTypes(NULL), m_nativeLibraries(NULL),
-        m_markBit(0), m_unloading(false), m_fullSize(0), m_verifyData(NULL)
+        m_loadedClasses(NULL), m_loadingClasses(NULL), m_reportedClasses(NULL),
+        m_javaTypes(NULL), m_nativeLibraries(NULL), m_markBit(0),
+        m_unloading(false), m_fullSize(0), m_verifyData(NULL)
     {
         apr_pool_create(&pool, 0);
     }
@@ -202,13 +188,6 @@
     virtual void ReportFailedClass(Class* klass, const char* exnclass, std::stringstream&
exnmsg);
     void ReportFailedClass(Class* klass, const jthrowable exn);
     virtual void ReportFailedClass(const char* name, const char* exnclass, std::stringstream&
exnmsg);
-    jthrowable GetClassError(const char* name) {
-        LMAutoUnlock aulock(&m_lock);
-        String* nameString = VM_Global_State::loader_env->string_pool.lookup(name);
-        FailedClass* fc = m_failedClasses->Lookup(nameString);
-        if(!fc) return NULL;
-        return (jthrowable)(&(fc->m_exception));
-    }
     void LoadNativeLibrary( const char *name );
     GenericFunctionPointer LookupNative(Method*);
     void SetVerifyData( void *data ) { m_verifyData = data; }
@@ -224,7 +203,6 @@
     Class* StartLoadingClass(Global_Env* env, const String* className);
     void RemoveLoadingClass(const String* className, LoadingClass* loading);
     void SuccessLoadingClass(const String* className);
-    void AddFailedClass(const String* className, const jthrowable exn);
     void FailedLoadingClass(const String* className);
 
 public:
@@ -237,7 +215,6 @@
     Package_Table* getPackageTable() { return m_package_table; }
     ClassTable* GetLoadedClasses() { return m_loadedClasses; }
     ClassTable* GetInitiatedClasses() { return m_initiatedClasses; }
-    FailedClasses* GetFailedClasses() { return m_failedClasses; }
     LoadingClasses* GetLoadingClasses() { return m_loadingClasses; }
     ReportedClasses* GetReportedClasses() { return m_reportedClasses; }
     JavaTypes* GetJavaTypes() { return m_javaTypes; }
@@ -293,7 +270,6 @@
     Package_Table* m_package_table;
     ClassTable* m_loadedClasses;
     ClassTable* m_initiatedClasses;
-    FailedClasses* m_failedClasses;
     LoadingClasses* m_loadingClasses;
     ReportedClasses* m_reportedClasses;
     JavaTypes* m_javaTypes;
@@ -314,12 +290,6 @@
 private:
     void FieldClearInternals(Class*); // clean Field internals in Class
 }; // class ClassLoader
-
-inline LoggerString& operator << (LoggerString& log, ClassLoader::FailedClass&
fc)
-{
-    log << fc.m_name->bytes << " status: " << fc.m_exception;
-    return log;
-}
 
 inline LoggerString& operator << (LoggerString& log, ClassLoader::LoadingClass&
lc)
 {

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp?view=diff&rev=486456&r1=486455&r2=486456
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp Tue Dec 12 18:17:58
2006
@@ -983,15 +983,16 @@
         if (*p=='.') *p='/';
         p++;
     }
-    String* name2 = VM_Global_State::loader_env->string_pool.lookup(name3);
+    Global_Env* env = VM_Global_State::loader_env;
+    String* name2 = env->string_pool.lookup(name3);
     Class* ch;
     if (loader) {
         ch = loader->LookupClass(name2);
     } else {
-        ch = VM_Global_State::loader_env->bootstrap_class_loader->LookupClass(name2);
+        ch = env->bootstrap_class_loader->LookupClass(name2);
     }
     STD_FREE(name3);
-    //if(ch && ch->state == ST_Error) return NULL;
+    if(ch && (!ch->verify(env) || !ch->prepare(env))) return NULL;
     return ch;
 }
 
@@ -1198,10 +1199,9 @@
     ClassLoader* class_loader = m->get_class()->get_class_loader();
     Class *c =
         class_loader->LoadVerifyAndPrepareClass(VM_Global_State::loader_env, exn_name);
-    if (!c && !exn_raised()) {
-        exn_raise_object(class_loader->GetClassError(exn_name->bytes));
-    }
-    return (Class_Handle)c;
+    // if loading failed - exception should be raised
+    assert((!c && exn_raised()) || (c && !exn_raised()));
+    return c;
 }
 
 unsigned method_get_num_handlers(Method_Handle m)
@@ -2017,20 +2017,6 @@
     if(!c->prepare(VM_Global_State::loader_env)) return NULL;
     return c;
 } //type_info_get_class
-
-Managed_Object_Handle* type_info_get_loading_error(Type_Info_Handle tih) {
-    TypeDesc* td = (TypeDesc*) tih;
-    if (td->is_vector()) {
-        Managed_Object_Handle* err = type_info_get_loading_error((Type_Info_Handle)td->get_element_type());
-        if (err) return err;
-    }
-    const String* name = td->get_type_name();
-    ClassLoader* cl = td->get_classloader();
-    jthrowable ex = class_get_error(cl, name->bytes);
-    assert(ex);
-    return (Managed_Object_Handle*) ex;
-}
-
 
 
 Method_Signature_Handle type_info_get_method_sig(Type_Info_Handle UNREF tih)

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp?view=diff&rev=486456&r1=486455&r2=486456
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp Tue Dec 12 18:17:58
2006
@@ -126,7 +126,6 @@
     m_intfc_table_descriptors = NULL;
 
     m_initializing_thread = NULL;
-    m_error = NULL;
 
     m_num_class_init_checks = m_num_throws = m_num_instanceof_slow
         = m_num_allocations = m_num_bytes_allocated = 0;
@@ -273,11 +272,7 @@
         m_super_class.name = NULL;
         superClass = m_class_loader->LoadVerifyAndPrepareClass(env, superName);
         if(superClass == NULL) {
-            if(!m_class_loader->GetClassError(get_name()->bytes)) {
-                // Don't report failed classes more than one time
-                REPORT_FAILED_CLASS_CLASS_EXN(m_class_loader, this,
-                    m_class_loader->GetClassError(superName->bytes));
-            }
+            assert(exn_raised());
             return false;
         }
 
@@ -331,10 +326,7 @@
         const String* intfc_name = m_superinterfaces[i].name;
         Class* intfc = m_class_loader->LoadVerifyAndPrepareClass(env, intfc_name);
         if(intfc == NULL) {
-            if(!m_class_loader->GetClassError(get_name()->bytes)) {
-                REPORT_FAILED_CLASS_CLASS_EXN(m_class_loader, this,
-                    m_class_loader->GetClassError(intfc_name->bytes));
-            }
+            assert(exn_raised());
             return false;
         }
         if(!intfc->is_interface()) {
@@ -526,17 +518,6 @@
         }
     }
     return NULL;
-}
-
-
-void Class::set_error_cause(jthrowable exn)
-{
-    tmn_suspend_disable();
-    lock();
-    m_state = ST_Error;
-    m_error = exn->object;
-    unlock();
-    tmn_suspend_enable();
 }
 
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Initialize.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Initialize.cpp?view=diff&rev=486456&r1=486455&r2=486456
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Initialize.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Initialize.cpp Tue Dec 12 18:17:58
2006
@@ -102,10 +102,6 @@
 
         if(get_super_class()->in_error()) { 
             jthread_monitor_enter(jlc);
-            tmn_suspend_enable();
-            REPORT_FAILED_CLASS_CLASS_EXN(m_class_loader, this,
-                get_super_class()->get_error_cause());
-            tmn_suspend_disable();
             m_initializing_thread = NULL;
             lock();
             m_state = ST_Error;
@@ -155,7 +151,6 @@
         unlock();
         TRACE2("classloader", "class " << m_name->bytes << " initialized");
         m_initializing_thread = NULL;
-        assert(m_error == NULL);
         assert(!hythread_is_suspend_enabled());
         jthread_monitor_notify_all(jlc);
         jthread_monitor_exit(jlc);
@@ -163,43 +158,39 @@
     }
 
     // ---  step 10  ----------------------------------------------------------
-
-    if(p_error_object) {
-        assert(!hythread_is_suspend_enabled());
-        exn_clear();
-        Class* p_error_class = p_error_object->object->vt()->clss;
-        Class* jle = VM_Global_State::loader_env->java_lang_Error_Class;
-        while(p_error_class && p_error_class != jle) {
-            p_error_class = p_error_class->get_super_class();
-        }
-        assert(!hythread_is_suspend_enabled());
-        if((!p_error_class) || (p_error_class != jle) ) {
+    assert(p_error_object != NULL);
+    assert(!hythread_is_suspend_enabled());
+    exn_clear();
+    Class* p_error_class = p_error_object->object->vt()->clss;
+    Class* jle = VM_Global_State::loader_env->java_lang_Error_Class;
+    while(p_error_class && p_error_class != jle) {
+        p_error_class = p_error_class->get_super_class();
+    }
+    assert(!hythread_is_suspend_enabled());
+    if(p_error_class == NULL) {
+        // class of p_error_object is not a descendant of java/lang/Error
 #ifdef _DEBUG_REMOVED
-            Class* eiie = VM_Global_State::loader_env->java_lang_ExceptionInInitializerError_Class;
-            assert(eiie);
+        Class* eiie = VM_Global_State::loader_env->
+            java_lang_ExceptionInInitializerError_Class;
+        assert(eiie);
 #endif
-            tmn_suspend_enable();
-
-            p_error_object = exn_create("java/lang/ExceptionInInitializerError",
-                p_error_object);
-            tmn_suspend_disable();
-        }
         tmn_suspend_enable();
-        set_error_cause(p_error_object);
+        p_error_object = exn_create("java/lang/ExceptionInInitializerError",
+            p_error_object);
         tmn_suspend_disable();
-
-        // ---  step 11  ----------------------------------------------------------
-        assert(!hythread_is_suspend_enabled());
-        jthread_monitor_enter(jlc);
-        lock();
-        m_state = ST_Error;
-        unlock();
-        m_initializing_thread = NULL;
-        assert(!hythread_is_suspend_enabled());
-        jthread_monitor_notify_all(jlc);
-        jthread_monitor_exit(jlc);
-        exn_raise_object(p_error_object);
     }
+
+    // ---  step 11  ----------------------------------------------------------
+    assert(!hythread_is_suspend_enabled());
+    jthread_monitor_enter(jlc);
+    lock();
+    m_state = ST_Error;
+    unlock();
+    m_initializing_thread = NULL;
+    assert(!hythread_is_suspend_enabled());
+    jthread_monitor_notify_all(jlc);
+    jthread_monitor_exit(jlc);
+    exn_raise_object(p_error_object);
     // end of 11 step class initialization program
 } //class_initialize1
 
@@ -211,11 +202,7 @@
 
     // check verifier constraints
     if(!clss->verify_constraints(VM_Global_State::loader_env)) {
-        if (!exn_raised()) {
-            tmn_suspend_disable();
-            exn_raise_object(class_get_error(clss->get_class_loader(), clss->get_name()->bytes));
-            tmn_suspend_enable();
-        }
+        assert(exn_raised());
         return;
     }
 
@@ -241,10 +228,8 @@
     // check verifier constraints
     tmn_suspend_enable();
     if(!clss->verify_constraints(VM_Global_State::loader_env)) {
-        if (!exn_raised()) {
-            tmn_suspend_disable();
-            exn_raise_object(class_get_error(clss->get_class_loader(), clss->get_name()->bytes));
-        }
+        assert(exn_raised());
+        tmn_suspend_disable();
         return;
     }
     tmn_suspend_disable();

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Prepare.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Prepare.cpp?view=diff&rev=486456&r1=486455&r2=486456
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Prepare.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Prepare.cpp Tue Dec 12 18:17:58
2006
@@ -1263,7 +1263,7 @@
     // STEP 7 ::: ASSIGN OFFSETS to the class and virtual METHODS
     //
     assign_offsets_to_methods(env);
-    if(m_state == ST_Error)
+    if(in_error())
         return false;
 
     //

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Resolve.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Resolve.cpp?view=diff&rev=486456&r1=486455&r2=486456
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Resolve.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Resolve.cpp Tue Dec 12 18:17:58
2006
@@ -110,10 +110,6 @@
     ConstantPool& cp = target->get_constant_pool();
     assert(cp.is_valid_index(cp_index));
     assert(hythread_is_suspend_enabled());
-    if (exn_raised()) {
-        TRACE2("classloader.error", "runtime exception in classloading");
-        return;
-    }
     assert(exn);
 
     tmn_suspend_disable();
@@ -169,12 +165,10 @@
     Class* other_clss = m_class_loader->LoadVerifyAndPrepareClass(env, classname);
     if(other_clss == NULL)
     {
-        jthrowable exn = class_get_error(m_class_loader, classname->bytes);
-        if (exn) {
-            class_report_failure(this, cp_index, exn);
-        } else {
-            assert(exn_raised());
-        }
+        // FIXMECL should find out if this is VirtualMachineError
+        assert(exn_raised());
+        class_report_failure(this, cp_index, exn_get());
+        exn_clear();
         return NULL;
     }
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp?view=diff&rev=486456&r1=486455&r2=486456
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp Tue Dec 12 18:17:58
2006
@@ -63,13 +63,6 @@
                                  uint8* buffer,
                                  unsigned offset, unsigned length);
 
-/*VMEXPORT*/ jthrowable class_get_error(ClassLoaderHandle clh, const char* name)
-{
-    assert(clh);
-    assert(name);
-    return clh->GetClassError(name);
-}
-
 
 bool ClassLoader::Initialize( ManagedObject* loader )
 {
@@ -85,8 +78,6 @@
     if(!m_loadingClasses) return false;
     m_reportedClasses = new ReportedClasses();
     if(!m_reportedClasses) return false;
-    m_failedClasses = new FailedClasses();
-    if(!m_failedClasses) return false;
     m_javaTypes = new JavaTypes();
     if(!m_javaTypes) return false;
 
@@ -113,8 +104,6 @@
 
     if (GetLoadedClasses())
         delete GetLoadedClasses();
-    if (GetFailedClasses())
-        delete GetFailedClasses();
     if (GetLoadingClasses())
         delete GetLoadingClasses();
     if (GetReportedClasses())
@@ -250,14 +239,6 @@
     if((clss = WaitDefinition(env, className)) != NULL || exn_raised())
         return clss;
 
-    m_lock._lock();
-    if(m_failedClasses->Lookup(className)) {
-        FailedLoadingClass(className);
-        m_lock._unlock();
-        return NULL;
-    }
-    m_lock._unlock();
-
     uint8 *redef_buf = NULL;
     int redef_buflen = 0;
     jvmti_send_class_file_load_hook_event(env, this, class_name,
@@ -366,48 +347,45 @@
 }
 
 
-void ClassLoader::AddFailedClass(const String *className, const jthrowable exn) {
-    assert(exn != NULL);
-    tmn_suspend_disable();
-    m_lock._lock();
-
-    FailedClass fc;
-    fc.m_name = className;
-    fc.m_exception = ((ObjectHandle)exn)->object;
-    m_failedClasses->Insert(className, fc);
-
-    m_lock._unlock();
-    tmn_suspend_enable();
-}
-
 void ClassLoader::ReportFailedClass(Class* klass, const jthrowable exn)
 {
-    if (exn == NULL) {
-        assert(exn_raised());
-        return; // OOME
+    if(exn_raised()) {
+        assert(exn == NULL);
+        return;
     }
-    AddFailedClass(klass->get_name(), exn);
-    klass->set_error_cause(exn);
+    exn_raise_object(exn);
 }
 
+
 void ClassLoader::ReportFailedClass(Class* klass, const char* exnclass, std::stringstream&
exnmsg)
 {
+    assert(!exn_raised());
     jthrowable exn = exn_create(exnclass, exnmsg.str().c_str());
 
-    // ppervov: FIXME: should throw OOME
-    AddFailedClass(klass->get_name(), exn);
-    klass->set_error_cause(exn);
+    if(exn_raised()) {
+        assert(exn == NULL);
+        return;
+    }
+    exn_raise_object(exn);
 }
 
 
-
-void ClassLoader::ReportFailedClass(const char* klass, const char* exnclass, std::stringstream&
exnmsg)
+void ClassLoader::ReportFailedClass(const char* klass, const char* exnclass,
+                                    std::stringstream& exnmsg)
 {
     const String* klassName = VM_Global_State::loader_env->string_pool.lookup(klass);
 
+    assert(!exn_raised());
+
     jthrowable exn = exn_create(exnclass, exnmsg.str().c_str());
     // ppervov: FIXME: should throw OOME
-    AddFailedClass(klassName, exn);
+
+    if(!exn_raised()) {
+        assert(exn != NULL);
+        exn_raise_object(exn);
+    } else {
+        assert(exn == NULL);
+    }
 }
 
 
@@ -422,6 +400,7 @@
     }
 }
 
+
 void ClassLoader::SuccessLoadingClass(const String* className) 
 {
     LMAutoUnlock aulock( &m_lock );
@@ -477,23 +456,10 @@
 {
     TRACE2("enumeration", "enumerating classes");
     LMAutoUnlock aulock( &(ClassLoader::m_tableLock) );
-    FailedClasses::iterator fci;
-    // should enumerate errors in bootstrap
-    for(fci = VM_Global_State::loader_env->bootstrap_class_loader->m_failedClasses->begin();
-        fci != VM_Global_State::loader_env->bootstrap_class_loader->m_failedClasses->end();
fci++)
-    {
-        vm_enumerate_root_reference((void**)(&(fci->second.m_exception)), FALSE);
-    }
 
     for(unsigned int i = 0; i < m_nextEntry; i++) {
         if(m_table[i]->m_loader != NULL) {
             vm_enumerate_root_reference((void**)(&(m_table[i]->m_loader)), FALSE);
-            // should enumerate errors for classes
-            for(fci = m_table[i]->m_failedClasses->begin();
-                fci != m_table[i]->m_failedClasses->end(); fci++)
-            {
-                vm_enumerate_root_reference((void**)(&(fci->second.m_exception)),
FALSE);
-            }
         }
     }
 }
@@ -640,9 +606,6 @@
     while(true)
     {
         LMAutoUnlock aulock(&m_lock);
-        FailedClass* failed = m_failedClasses->Lookup(className);
-        if(failed) return NULL;
-
         // check if the class has been already recorded as initiated by this loader
         pklass = m_initiatedClasses->Lookup(className);
         if (pklass) return *pklass;
@@ -746,10 +709,6 @@
     m_lock._lock();
     do
     {
-        if(m_failedClasses->Lookup(className)) {
-            m_lock._unlock();
-            return NULL;
-        }
         loading = m_loadingClasses->Lookup(className);
         if(loading && m_loadedClasses->Lookup(className) == NULL) {
             TRACE2("classloader.collisions", this << " " << cur_thread <<
" DC " << className->bytes);
@@ -902,14 +861,6 @@
         if((klass = WaitDefinition(env, classNameString)) != NULL)
             return klass;
 
-        m_lock._lock();
-        if(m_failedClasses->Lookup(classNameString)) {
-            FailedLoadingClass(classNameString);
-            m_lock._unlock();
-            return NULL;
-        }
-        m_lock._unlock();
-
         // create class
         klass = NewClass(env, classNameString);
         if (!klass) {
@@ -1529,13 +1480,6 @@
 {
     assert(env == m_env);
     Class* klass = StartLoadingClass(m_env, className);
-    
-    LMAutoUnlock aulock(&m_lock);
-    if(klass == NULL && m_failedClasses->Lookup(className) != NULL) {
-        // there was an error in loading class
-        return NULL;
-    }
-    aulock.ForceUnlock();
 
     if(klass != NULL) {
         // class is already loaded so return it
@@ -1560,11 +1504,7 @@
     assert(m_loader != NULL);
 
     Class* klass = StartLoadingClass(env, className);
-    LMAutoUnlock aulock(&m_lock);
-    if(klass == NULL && m_failedClasses->Lookup(className) != NULL) {
-        return NULL;
-    }
-    aulock.ForceUnlock();
+
     if(klass != NULL) {
         return klass;
     }
@@ -1642,39 +1582,35 @@
     if(exn_raised()) {
         tmn_suspend_enable();
 
-        jthrowable exn = GetClassError(className->bytes);
-        if(!exn) {
-            exn = exn_get();
-            // translate ClassNotFoundException to NoClassDefFoundError (if any)
-            Class* NotFoundExn_class = env->java_lang_ClassNotFoundException_Class;
-            Class *exn_class = jobject_to_struct_Class(exn);
-
-            INFO("Loading of " << className->bytes << " class failed due to
"
-                << exn_class->get_name()->bytes);
-
-            while(exn_class && exn_class != NotFoundExn_class) {
-                exn_class = exn_class->get_super_class();
-            }
-
-            if (exn_class == NotFoundExn_class) {
-                TRACE("translating ClassNotFoundException to "
-                     "NoClassDefFoundError for " << className->bytes);
-                exn_clear();
-                jthrowable new_exn = CreateNewThrowable(
-                    p_TLS_vmthread->jni_env,
-                    env->java_lang_NoClassDefFoundError_Class, 
-                    className->bytes, exn);
-                if (new_exn) {
-                    exn = new_exn;
-                } else {
-                    LOG("Failed to translate ClassNotFoundException "
-                        "to NoClassDefFoundError for " << className->bytes);
-                }
+        jthrowable exn = exn_get();
+        // translate ClassNotFoundException to NoClassDefFoundError (if any)
+        Class* NotFoundExn_class = env->java_lang_ClassNotFoundException_Class;
+        Class* exn_class = jobject_to_struct_Class(exn);
+
+        INFO("Loading of " << className->bytes << " class failed due to "
+            << exn_class->get_name()->bytes);
+
+        while(exn_class && exn_class != NotFoundExn_class) {
+            exn_class = exn_class->get_super_class();
+        }
+
+        if (exn_class == NotFoundExn_class) {
+            TRACE("translating ClassNotFoundException to "
+                    "NoClassDefFoundError for " << className->bytes);
+            exn_clear();
+            jthrowable new_exn = CreateNewThrowable(
+                p_TLS_vmthread->jni_env,
+                env->java_lang_NoClassDefFoundError_Class,
+                className->bytes, exn);
+            if(new_exn) {
+                exn_raise_object(new_exn);
+            } else {
+                assert(exn_raised());
+                LOG("Failed to translate ClassNotFoundException "
+                    "to NoClassDefFoundError for " << className->bytes);
             }
-
-            AddFailedClass(className, exn);
         }
-        exn_clear();
+
         FailedLoadingClass(className);
         return NULL;
     }

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/root_set_enum_common.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/root_set_enum_common.cpp?view=diff&rev=486456&r1=486455&r2=486456
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/root_set_enum_common.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/root_set_enum_common.cpp Tue Dec 12 18:17:58
2006
@@ -82,10 +82,6 @@
             assert(*ppc);
             Class* c = jclass_to_struct_Class((jclass)ppc);
 
-            if(c->in_error()) {
-                vm_enumerate_root_reference(
-                        (void**)c->get_error_cause() ,FALSE);
-            }
             vm_enumerate_root_reference((void**)ppc, FALSE);
             ConstPoolEntry* cp = c->get_constant_pool().get_error_chain();
             while(cp) {

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp?view=diff&rev=486456&r1=486455&r2=486456
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp Tue Dec 12 18:17:58 2006
@@ -646,16 +646,8 @@
     }
     else
     {
-        if (exn_raised()) {
-            return 0;
-        } else if(res_name) {
-            jthrowable exn = (jthrowable)class_get_error(cl, res_name->bytes);
-            exn_raise_object(exn);
-        } else {
-            exn_raise_by_name("java/lang/LinkageError",
-                "defineClass failed for unnamed class", NULL);
-        }
-        return 0;
+        assert(exn_raised());
+        return NULL;
     }
 } //DefineClass
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_utils.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_utils.cpp?view=diff&rev=486456&r1=486455&r2=486456
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_utils.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_utils.cpp Tue Dec 12 18:17:58 2006
@@ -610,16 +610,12 @@
     assert(hythread_is_suspend_enabled());
 
     Class* c = loader->LoadVerifyAndPrepareClass( VM_Global_State::loader_env, name);
-    assert(!exn_raised());
-
-    if (!c) { 
-        // actually class loading failed
-        jthrowable exn = loader->GetClassError(name->bytes);
-        assert(exn);
-        Throw(jenv, exn);
+    // if loading failed - exception should be raised
+    if(!c) {
+        assert(exn_raised());
         return NULL;
     }
-    
+
     jclass clazz = struct_Class_to_jclass(c);
 
     return (jclass)clazz;
@@ -704,15 +700,8 @@
         assert(hythread_is_suspend_enabled());
         return struct_Class_to_jclass(clss);
     } else {
-        // The JNI spec says that we should throw one of: ClassFormatError,
-        // ClassCircularityError, NoClassDefFoundError or OutOfMemoryError.
-        // We don't throw OutOfMemoryError (we assume that we can always
-        // allocate more memory for a class).
-        jthrowable exn = class_get_error(loader, name->bytes);
-        assert(exn);
-        exn_clear();
-        Throw(env, exn);
-        return 0;
+        assert(exn_raised());
+        return NULL;
     }
 }
 
@@ -794,12 +783,7 @@
     if(!clss->is_initialized()) {
         class_initialize_from_jni(clss);
         if(clss->in_error()) {
-            // If exception is already raised, no need to
-            // throw new one, just return instead
-            if(!exn_raised()) 
-            {
-                env->Throw(clss->get_error_cause());
-            }
+            assert(exn_raised());
             return false;
         }
     }

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/reflection/annotations.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/reflection/annotations.cpp?view=diff&rev=486456&r1=486455&r2=486456
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/reflection/annotations.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/reflection/annotations.cpp Tue Dec 12 18:17:58
2006
@@ -77,17 +77,13 @@
             return type;
         }
 
-        jthrowable jfailure;
-        if (exn_raised()) {
-            jfailure = exn_get(); 
-            ASSERT(jfailure, "FIXME lazy exceptions handling");
-            exn_clear();
-        } else {
-            jfailure = (jthrowable)type_info_get_loading_error(tih);
-        }
-   	    jthrowable jnewfailure = exn_create("java/lang/TypeNotPresentException",
-	        tih->get_type_name()->bytes, jfailure);
-	    if (jnewfailure) {
+        assert(exn_raised());
+        jthrowable jfailure = exn_get();
+        ASSERT(jfailure, "FIXME lazy exceptions handling");
+        exn_clear();
+        jthrowable jnewfailure = exn_create("java/lang/TypeNotPresentException",
+            tih->get_type_name()->bytes, jfailure);
+        if (jnewfailure) {
             if (cause) {
                 *cause = jnewfailure;
             } else {
@@ -360,7 +356,8 @@
                     if (type_info_is_vector(tih)) {
                         arr_type = type_info_get_class(tih);
                         if (!arr_type) {
-                            *cause= (jthrowable)type_info_get_loading_error(tih);
+                            // if loading failed - exception should be raised
+                            assert(exn_raised());
                             return NULL;
                         }
                     } 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/reflection/reflection.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/reflection/reflection.cpp?view=diff&rev=486456&r1=486455&r2=486456
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/reflection/reflection.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/reflection/reflection.cpp Tue Dec 12 18:17:58
2006
@@ -37,13 +37,11 @@
 
 jclass descriptor_to_jclass(Type_Info_Handle desc){
     Class_Handle clss = type_info_get_class(desc);
-
-    if (!clss) {
-        if (!exn_raised()) {
-            exn_raise_object((jthrowable) type_info_get_loading_error(desc));
-        }
+    if(!clss) {
+        assert(exn_raised());
         return NULL;
     }
+
     return struct_Class_to_java_lang_Class_Handle(clss);
 }
 



Mime
View raw message