OSDN Git Service

Print -verbose:message on "loading", not initialization.
[pf3gnuchains/gcc-fork.git] / libjava / java / lang / natClass.cc
index ffac2c1..1b1a32d 100644 (file)
@@ -1,6 +1,7 @@
 // natClass.cc - Implementation of java.lang.Class native methods.
 
-/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003  Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004  
+   Free Software Foundation
 
    This file is part of libgcj.
 
@@ -58,10 +59,13 @@ details.  */
 
 #include <java-cpool.h>
 #include <java-interp.h>
+
 \f
 
 using namespace gcj;
 
+bool gcj::verbose_class_flag;
+
 jclass
 java::lang::Class::forName (jstring className, jboolean initialize,
                             java::lang::ClassLoader *loader)
@@ -71,7 +75,7 @@ java::lang::Class::forName (jstring className, jboolean initialize,
 
   jsize length = _Jv_GetStringUTFLength (className);
   char buffer[length];
-  _Jv_GetStringUTFRegion (className, 0, length, buffer);
+  _Jv_GetStringUTFRegion (className, 0, className->length(), buffer);
 
   _Jv_Utf8Const *name = _Jv_makeUtf8Const (buffer, length);
 
@@ -151,7 +155,7 @@ java::lang::Class::getClassLoader (void)
   // `null' instead.
   if (isPrimitive ())
     return NULL;
-  return loader ? loader : ClassLoader::getSystemClassLoader ();
+  return loader ? loader : ClassLoader::systemClassLoader;
 }
 
 java::lang::reflect::Constructor *
@@ -688,9 +692,9 @@ java::lang::Class::newInstance (void)
 
   _Jv_Method *meth = _Jv_GetMethodLocal (this, init_name, void_signature);
   if (! meth)
-    throw new java::lang::NoSuchMethodException (_Jv_NewStringUtf8Const (init_name));
+    throw new java::lang::InstantiationException (getName());
 
-  jobject r = JvAllocObject (this);
+  jobject r = _Jv_AllocObject (this);
   ((void (*) (jobject)) meth->ncode) (r);
   return r;
 }
@@ -1502,13 +1506,13 @@ java::lang::Class::getProtectionDomain0 ()
 JArray<jobject> *
 java::lang::Class::getSigners()
 {
-  return signers;
+  return hack_signers;
 }
 
 void
 java::lang::Class::setSigners(JArray<jobject> *s)
 {
-  signers = s;
+  hack_signers = s;
 }
 
 // Functions for indirect dispatch (symbolic virtual binding) support.
@@ -1786,6 +1790,20 @@ _Jv_abstractMethodError (void)
   throw new java::lang::AbstractMethodError();
 }
 
+// Set itable method indexes for members of interface IFACE.
+void
+_Jv_LayoutInterfaceMethods (jclass iface)
+{
+  if (! iface->isInterface())
+    return;
+  
+  // itable indexes start at 1. 
+  // FIXME: Static initalizers currently get a NULL placeholder entry in the
+  // itable so they are also assigned an index here.
+  for (int i = 0; i < iface->method_count; i++)
+    iface->methods[i].index = i + 1;
+}
+
 // Prepare virtual method declarations in KLASS, and any superclasses as 
 // required, by determining their vtable index, setting method->index, and
 // finally setting the class's vtable_method_count. Must be called with the
@@ -1835,6 +1853,12 @@ _Jv_LayoutVTableMethods (jclass klass)
       if (! _Jv_isVirtualMethod (meth))
        continue;
 
+      // FIXME: Must check that we don't override:
+      // - Package-private method where superclass is in different package.
+      // - Final or less-accessible declaration in superclass (check binary 
+      //   spec, do we allocate new vtable entry or put throw node in vtable?)
+      // - Static or private method in superclass.
+
       if (superclass != NULL)
        {
          super_meth = _Jv_LookupDeclaredMethod (superclass, meth->name, 
@@ -1843,8 +1867,7 @@ _Jv_LayoutVTableMethods (jclass klass)
 
       if (super_meth)
         meth->index = super_meth->index;
-      else if (! (meth->accflags & java::lang::reflect::Modifier::FINAL)
-              && ! (klass->accflags & java::lang::reflect::Modifier::FINAL))
+      else
        meth->index = index++;
     }
 
@@ -1895,7 +1918,7 @@ _Jv_MakeVTable (jclass klass)
       || (klass->accflags & Modifier::ABSTRACT))
     return;
 
-  //  out before we can create a vtable. 
+  // Class must be laid out before we can create a vtable. 
   if (klass->vtable_method_count == -1)
     _Jv_LayoutVTableMethods (klass);