Added Java_java_lang_VMClassLoader_nativeGetResources again, since the GNU
authortwisti <none@none>
Wed, 4 May 2005 15:07:45 +0000 (15:07 +0000)
committertwisti <none@none>
Wed, 4 May 2005 15:07:45 +0000 (15:07 +0000)
classpath java-only implementation has some bootstrap problems (strange
problems with flat bootclasspathes).

src/native/vm/VMClassLoader.c

index bd373b5a4d943ca68dd33a52184cd4cbde483a4c..269d0f52676a1bb20e28a6fa41538f634cae63e8 100644 (file)
@@ -28,9 +28,9 @@
 
    Changes: Joseph Wenninger
             Christian Thalinger
-                       Edwin Steiner
+            Edwin Steiner
 
-   $Id: VMClassLoader.c 2433 2005-05-04 10:25:21Z twisti $
+   $Id: VMClassLoader.c 2438 2005-05-04 15:07:45Z twisti $
 
 */
 
@@ -287,6 +287,113 @@ JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClassLoader_loadClass(JNIEnv
 }
 
 
+/*
+ * Class:     java/lang/VMClassLoader
+ * Method:    nativeGetResources
+ * Signature: (Ljava/lang/String;)Ljava/util/Vector;
+ */
+JNIEXPORT java_util_Vector* JNICALL Java_java_lang_VMClassLoader_nativeGetResources(JNIEnv *env, jclass clazz, java_lang_String *name)
+{
+       jobject           o;
+       methodinfo       *m;
+       java_lang_String *path;
+       classpath_info   *cpi;
+       utf              *utfname;
+       char             *charname;
+       char             *tmppath;
+       s4                namelen;
+       s4                pathlen;
+       struct stat       buf;
+       jboolean          ret;
+
+       /* get the resource name as utf string */
+
+       utfname = javastring_toutf(name, false);
+
+       namelen = utf_strlen(utfname) + strlen("0");
+       charname = MNEW(char, namelen);
+
+       utf_sprint(charname, utfname);
+
+       /* new Vector() */
+
+       o = native_new_and_init(class_java_util_Vector);
+
+       if (!o)
+               return NULL;
+
+       /* get v.add() method */
+
+       m = class_resolveclassmethod(class_java_util_Vector,
+                                                                utf_new_char("add"),
+                                                                utf_new_char("(Ljava/lang/Object;)Z"),
+                                                                NULL,
+                                                                true);
+
+       if (!m)
+               return NULL;
+
+       for (cpi = classpath_entries; cpi != NULL; cpi = cpi->next) {
+               /* clear path pointer */
+               path = NULL;
+
+#if defined(USE_ZLIB)
+               if (cpi->type == CLASSPATH_ARCHIVE) {
+
+#if defined(USE_THREADS)
+                       /* enter a monitor on zip/jar archives */
+
+                       builtin_monitorenter((java_objectheader *) cpi);
+#endif
+
+                       if (cacao_locate(cpi->uf, utfname) == UNZ_OK) {
+                               pathlen = strlen("jar:file://") + cpi->pathlen + strlen("!/") +
+                                       namelen + strlen("0");
+
+                               tmppath = MNEW(char, pathlen);
+
+                               sprintf(tmppath, "jar:file://%s!/%s", cpi->path, charname);
+                               path = javastring_new_char(tmppath),
+
+                               MFREE(tmppath, char, pathlen);
+                       }
+
+#if defined(USE_THREADS)
+                       /* leave the monitor */
+
+                       builtin_monitorexit((java_objectheader *) cpi);
+#endif
+
+               } else {
+#endif /* defined(USE_ZLIB) */
+                       pathlen = strlen("file://") + cpi->pathlen + namelen + strlen("0");
+
+                       tmppath = MNEW(char, pathlen);
+
+                       sprintf(tmppath, "file://%s%s", cpi->path, charname);
+
+                       if (stat(tmppath + strlen("file://") - 1, &buf) == 0)
+                               path = javastring_new_char(tmppath),
+
+                       MFREE(tmppath, char, pathlen);
+#if defined(USE_ZLIB)
+               }
+#endif
+
+               /* if a resource was found, add it to the vector */
+
+               if (path) {
+                       ret = (jboolean) asm_calljavafunction_int(m, o, path, NULL, NULL);
+
+                       if (!ret)
+                               return NULL;
+               }
+       }
+
+       return (java_util_Vector *) o;
+}
+
+
 /*
  * These are local overrides for various environment variables in Emacs.
  * Please do not remove this and leave it at the end of the file, where