• R/O
  • SSH
  • HTTPS

exewrap: Commit


Commit MetaInfo

Revision40 (tree)
Time2017-10-17 11:40:31
Authorhirukawa_ryo

Log Message

* exewrap 1.2.0
exewrap.core.ExewrapClassLoaderを(パッケージ名なしの)Loaderに改名し、このLoaderのみをファイル末尾のJARに格納するようにしました。
Loaderが標準のクラスローダーから読み取り可能であれば十分です。

Change Summary

Incremental Difference

--- exewrap/trunk/exewrap/src/image_console.c (revision 39)
+++ exewrap/trunk/exewrap/src/image_console.c (revision 40)
@@ -10,7 +10,6 @@
1010 #include "include/loader.h"
1111 #include "include/notify.h"
1212 #include "include/message.h"
13-#include "include/trace.h"
1413
1514 void OutputConsole(BYTE* buf, DWORD len);
1615 void OutputMessage(const char* text);
@@ -34,10 +33,6 @@
3433 LOAD_RESULT result;
3534
3635 utilities[0] = '\0';
37- #ifdef TRACE
38- StartTrace(TRUE);
39- strcat(utilities, UTIL_CONSOLE_OUTPUT_STREAM);
40- #endif
4136
4237 result.msg = malloc(2048);
4338
@@ -67,7 +62,7 @@
6762 }
6863
6964 vm_args_opt = (char*)GetResource("VMARGS", NULL);
70- CreateJavaVM(vm_args_opt, "exewrap.core.ExewrapClassLoader", use_server_vm, use_side_by_side_jre, &err);
65+ CreateJavaVM(vm_args_opt, "Loader", use_server_vm, use_side_by_side_jre, &err);
7166 if (err != JNI_OK)
7267 {
7368 OutputMessage(GetJniErrorMessage(err, &result.msg_id, result.msg));
@@ -129,10 +124,6 @@
129124
130125 NotifyClose();
131126
132- #ifdef TRACE
133- StopTrace();
134- #endif
135-
136127 return result.msg_id;
137128 }
138129
--- exewrap/trunk/exewrap/src/loader.c (revision 39)
+++ exewrap/trunk/exewrap/src/loader.c (revision 40)
@@ -32,7 +32,8 @@
3232 extern void OutputMessage(const char* text);
3333 extern UINT UncaughtException(const char* thread, const char* message, const char* trace);
3434
35-static jclass ExewrapClassLoader = NULL;
35+static jclass Loader = NULL;
36+static jobject resources = NULL;
3637 static jclass MainClass = NULL;
3738 static jmethodID MainClass_main = NULL;
3839
@@ -39,15 +40,89 @@
3940 BOOL LoadMainClass(int argc, char* argv[], char* utilities, LOAD_RESULT* result)
4041 {
4142 RESOURCE res;
43+ jclass ClassLoader;
44+ jmethodID ClassLoader_getSystemClassLoader;
45+ jmethodID ClassLoader_definePackage;
46+ jstring packageName;
47+ jobject systemClassLoader;
48+ jfieldID Loader_resources;
49+ jmethodID Loader_initialize;
4250 jclass JarInputStream;
4351 jmethodID JarInputStream_init;
4452 jclass ByteBufferInputStream;
4553 jmethodID ByteBufferInputStream_init;
54+ jclass NativeMethods;
55+ jclass URLConnection;
56+ jclass URLStreamHandler;
57+ jclass URLStreamHandlerFactory;
58+ jmethodID URLStreamHandlerFactory_init;
59+ jobject urlStreamHandlerFactory;
4660 jobjectArray jars;
47- jmethodID ExewrapClassLoader_setInputs;
48- jmethodID ExewrapClassLoader_loadUtilities;
49- jmethodID ExewrapClassLoader_getMainClass;
5061
62+ // ClassLoader
63+ ClassLoader = (*env)->FindClass(env, "java/lang/ClassLoader");
64+ if (ClassLoader == NULL)
65+ {
66+ result->msg_id = MSG_ID_ERR_DEFINE_CLASS;
67+ sprintf(result->msg, _(MSG_ID_ERR_DEFINE_CLASS), "java.lang.ClassLoader");
68+ goto EXIT;
69+ }
70+ ClassLoader_getSystemClassLoader = (*env)->GetStaticMethodID(env, ClassLoader, "getSystemClassLoader", "()Ljava/lang/ClassLoader;");
71+ if (ClassLoader_getSystemClassLoader == NULL)
72+ {
73+ result->msg_id = MSG_ID_ERR_GET_METHOD;
74+ sprintf(result->msg, _(MSG_ID_ERR_GET_METHOD), "java.lang.ClassLoader.getSystemClassLoader()");
75+ goto EXIT;
76+ }
77+ systemClassLoader = (*env)->CallStaticObjectMethod(env, ClassLoader, ClassLoader_getSystemClassLoader);
78+ if (systemClassLoader == NULL)
79+ {
80+ result->msg_id = MSG_ID_ERR_NULL_OBJECT;
81+ sprintf(result->msg, _(MSG_ID_ERR_NULL_OBJECT), "java.lang.ClassLoader.getSystemClassLoader()");
82+ goto EXIT;
83+ }
84+ ClassLoader_definePackage = (*env)->GetMethodID(env, ClassLoader, "definePackage", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/net/URL;)Ljava/lang/Package;");
85+ if (ClassLoader_definePackage == NULL)
86+ {
87+ result->msg_id = MSG_ID_ERR_GET_METHOD;
88+ sprintf(result->msg, _(MSG_ID_ERR_GET_METHOD), "java.lang.ClassLoader.definePackage(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.net.URL)");
89+ goto EXIT;
90+ }
91+
92+ // Define package "exewrap.core"
93+ packageName = GetJString(env, "exewrap.core");
94+ (*env)->CallObjectMethod(env, systemClassLoader, ClassLoader_definePackage, packageName, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
95+
96+ // Loader
97+ Loader = (*env)->FindClass(env, "Loader");
98+ if(Loader == NULL)
99+ {
100+ result->msg_id = MSG_ID_ERR_FIND_CLASS;
101+ sprintf(result->msg, _(MSG_ID_ERR_FIND_CLASS), "Loader");
102+ goto EXIT;
103+ }
104+ Loader_resources = (*env)->GetStaticFieldID(env, Loader, "resources", "Ljava/util/Map;");
105+ if(Loader_resources == NULL)
106+ {
107+ result->msg_id = MSG_ID_ERR_GET_FIELD;
108+ sprintf(result->msg, _(MSG_ID_ERR_GET_FIELD), "Loader.resources");
109+ goto EXIT;
110+ }
111+ resources = (*env)->GetStaticObjectField(env, Loader, Loader_resources);
112+ if(resources == NULL)
113+ {
114+ result->msg_id = MSG_ID_ERR_GET_FIELD;
115+ sprintf(result->msg, _(MSG_ID_ERR_GET_FIELD), "Loader.resources");
116+ goto EXIT;
117+ }
118+ Loader_initialize = (*env)->GetStaticMethodID(env, Loader, "initialize", "([Ljava/util/jar/JarInputStream;Ljava/net/URLStreamHandlerFactory;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Class;");
119+ if(Loader_initialize == NULL)
120+ {
121+ result->msg_id = MSG_ID_ERR_GET_METHOD;
122+ sprintf(result->msg, _(MSG_ID_ERR_GET_METHOD), "Loader.initialize(java.util.jar.JarInputStream[], java.net.URLStreamHandlerFactory, java.lang.String, java.lang.String)");
123+ goto EXIT;
124+ }
125+
51126 // JarInputStream
52127 JarInputStream = (*env)->FindClass(env, "java/util/jar/JarInputStream");
53128 if (JarInputStream == NULL)
@@ -65,7 +140,13 @@
65140 }
66141
67142 // ByteBufferInputStream
68- ByteBufferInputStream = (*env)->FindClass(env, "exewrap/core/ByteBufferInputStream");
143+ if (GetResource("BYTE_BUFFER_INPUT_STREAM", &res) == NULL)
144+ {
145+ result->msg_id = MSG_ID_ERR_RESOURCE_NOT_FOUND;
146+ sprintf(result->msg, _(MSG_ID_ERR_RESOURCE_NOT_FOUND), "RT_RCDATA: BYTE_BUFFER_INPUT_STREAM");
147+ goto EXIT;
148+ }
149+ ByteBufferInputStream = (*env)->DefineClass(env, "exewrap/core/ByteBufferInputStream", systemClassLoader, res.buf, res.len);
69150 if (ByteBufferInputStream == NULL)
70151 {
71152 result->msg_id = MSG_ID_ERR_FIND_CLASS;
@@ -80,8 +161,104 @@
80161 goto EXIT;
81162 }
82163
83- // JarInputStream[] jars = new JarInputStream[1];
84- jars = (*env)->NewObjectArray(env, 1, JarInputStream, NULL);
164+ // NativeMethods
165+ if (GetResource("NATIVE_METHODS", &res) == NULL)
166+ {
167+ result->msg_id = MSG_ID_ERR_RESOURCE_NOT_FOUND;
168+ sprintf(result->msg, _(MSG_ID_ERR_RESOURCE_NOT_FOUND), "RT_RCDATA: NATIVE_METHODS");
169+ goto EXIT;
170+ }
171+ NativeMethods = (*env)->DefineClass(env, "exewrap/core/NativeMethods", systemClassLoader, res.buf, res.len);
172+ if (NativeMethods == NULL)
173+ {
174+ result->msg_id = MSG_ID_ERR_FIND_CLASS;
175+ sprintf(result->msg, _(MSG_ID_ERR_FIND_CLASS), "exewrap.core.NativeMethods");
176+ goto EXIT;
177+ }
178+ if (register_native(env, NativeMethods, "WriteConsole", "([BII)V", JNI_WriteConsole) != 0)
179+ {
180+ result->msg_id = MSG_ID_ERR_REGISTER_NATIVE;
181+ sprintf(result->msg, _(MSG_ID_ERR_REGISTER_NATIVE), "WriteConsole");
182+ goto EXIT;
183+ }
184+ if (register_native(env, NativeMethods, "WriteEventLog", "(ILjava/lang/String;)V", JNI_WriteEventLog) != 0)
185+ {
186+ result->msg_id = MSG_ID_ERR_REGISTER_NATIVE;
187+ sprintf(result->msg, _(MSG_ID_ERR_REGISTER_NATIVE), "WriteEventLog");
188+ goto EXIT;
189+ }
190+ if (register_native(env, NativeMethods, "UncaughtException", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", JNI_UncaughtException) != 0)
191+ {
192+ result->msg_id = MSG_ID_ERR_REGISTER_NATIVE;
193+ sprintf(result->msg, _(MSG_ID_ERR_REGISTER_NATIVE), "UncaughtException");
194+ goto EXIT;
195+ }
196+ if (register_native(env, NativeMethods, "SetEnvironment", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", JNI_SetEnvironment) != 0)
197+ {
198+ result->msg_id = MSG_ID_ERR_REGISTER_NATIVE;
199+ sprintf(result->msg, _(MSG_ID_ERR_REGISTER_NATIVE), "SetEnvironment");
200+ goto EXIT;
201+ }
202+
203+ // URLConnection
204+ if (GetResource("URL_CONNECTION", &res) == NULL)
205+ {
206+ result->msg_id = MSG_ID_ERR_RESOURCE_NOT_FOUND;
207+ sprintf(result->msg, _(MSG_ID_ERR_RESOURCE_NOT_FOUND), "RT_RCDATA: URL_CONNECTION");
208+ goto EXIT;
209+ }
210+ URLConnection = (*env)->DefineClass(env, "exewrap/core/URLConnection", systemClassLoader, res.buf, res.len);
211+ if (URLConnection == NULL)
212+ {
213+ result->msg_id = MSG_ID_ERR_DEFINE_CLASS;
214+ sprintf(result->msg, _(MSG_ID_ERR_DEFINE_CLASS), "exewrap.core.URLConnection");
215+ goto EXIT;
216+ }
217+ // URLStreamHandler
218+ if (GetResource("URL_STREAM_HANDLER", &res) == NULL)
219+ {
220+ result->msg_id = MSG_ID_ERR_RESOURCE_NOT_FOUND;
221+ sprintf(result->msg, _(MSG_ID_ERR_RESOURCE_NOT_FOUND), "RT_RCDATA: URL_STREAM_HANDLER");
222+ goto EXIT;
223+ }
224+ URLStreamHandler = (*env)->DefineClass(env, "exewrap/core/URLStreamHandler", systemClassLoader, res.buf, res.len);
225+ if (URLStreamHandler == NULL)
226+ {
227+ result->msg_id = MSG_ID_ERR_DEFINE_CLASS;
228+ sprintf(result->msg, _(MSG_ID_ERR_DEFINE_CLASS), "exewrap.core.URLStreamHandler");
229+ goto EXIT;
230+ }
231+ // URLStreamHandlerFactory
232+ if (GetResource("URL_STREAM_HANDLER_FACTORY", &res) == NULL)
233+ {
234+ result->msg_id = MSG_ID_ERR_RESOURCE_NOT_FOUND;
235+ sprintf(result->msg, _(MSG_ID_ERR_RESOURCE_NOT_FOUND), "RT_RCDATA: URL_STREAM_HANDLER_FACTORY");
236+ goto EXIT;
237+ }
238+ URLStreamHandlerFactory = (*env)->DefineClass(env, "exewrap/core/URLStreamHandlerFactory", systemClassLoader, res.buf, res.len);
239+ if (URLStreamHandlerFactory == NULL)
240+ {
241+ result->msg_id = MSG_ID_ERR_DEFINE_CLASS;
242+ sprintf(result->msg, _(MSG_ID_ERR_DEFINE_CLASS), "exewrap.core.URLStreamHandlerFactory");
243+ goto EXIT;
244+ }
245+ URLStreamHandlerFactory_init = (*env)->GetMethodID(env, URLStreamHandlerFactory, "<init>", "(Ljava/lang/ClassLoader;Ljava/util/Map;)V");
246+ if (URLStreamHandlerFactory_init == NULL)
247+ {
248+ result->msg_id = MSG_ID_ERR_GET_CONSTRUCTOR;
249+ sprintf(result->msg, _(MSG_ID_ERR_GET_CONSTRUCTOR), "exewrap.core.URLStreamHandlerFactory(java.lang.ClassLoader)");
250+ goto EXIT;
251+ }
252+ urlStreamHandlerFactory = (*env)->NewObject(env, URLStreamHandlerFactory, URLStreamHandlerFactory_init, systemClassLoader, resources);
253+ if (urlStreamHandlerFactory == NULL)
254+ {
255+ result->msg_id = MSG_ID_ERR_NEW_OBJECT;
256+ sprintf(result->msg, _(MSG_ID_ERR_NEW_OBJECT), "exewrap.core.URLStreamHandlerFactory(java.lang.ClassLoader)");
257+ goto EXIT;
258+ }
259+
260+ // JarInputStream[] jars = new JarInputStream[2];
261+ jars = (*env)->NewObjectArray(env, 2, JarInputStream, NULL);
85262 if (jars == NULL)
86263 {
87264 result->msg_id = MSG_ID_ERR_NEW_OBJECT;
@@ -88,6 +265,42 @@
88265 sprintf(result->msg, _(MSG_ID_ERR_NEW_OBJECT), "JarInputStream[]");
89266 goto EXIT;
90267 }
268+
269+ //util.jar
270+ {
271+ jobject byteBuffer;
272+ jobject byteBufferInputStream = NULL;
273+ jobject jarInputStream = NULL;
274+
275+ if (GetResource("UTIL_JAR", &res) == NULL)
276+ {
277+ result->msg_id = MSG_ID_ERR_RESOURCE_NOT_FOUND;
278+ sprintf(result->msg, _(MSG_ID_ERR_RESOURCE_NOT_FOUND), "RT_RCDATA: UTIL_JAR");
279+ goto EXIT;
280+ }
281+ byteBuffer = (*env)->NewDirectByteBuffer(env, res.buf, res.len);
282+ if (byteBuffer == NULL)
283+ {
284+ result->msg_id = MSG_ID_ERR_NEW_OBJECT;
285+ sprintf(result->msg, _(MSG_ID_ERR_NEW_OBJECT), "NewDirectByteBuffer(JNIEnv* env, void* address, jlong capacity)");
286+ goto EXIT;
287+ }
288+ byteBufferInputStream = (*env)->NewObject(env, ByteBufferInputStream, ByteBufferInputStream_init, byteBuffer);
289+ if (byteBufferInputStream == NULL)
290+ {
291+ result->msg_id = MSG_ID_ERR_NEW_OBJECT;
292+ sprintf(result->msg, _(MSG_ID_ERR_NEW_OBJECT), "exewrap.core.ByteBufferInputStream(java.nio.ByteBuffer)");
293+ goto EXIT;
294+ }
295+ jarInputStream = (*env)->NewObject(env, JarInputStream, JarInputStream_init, byteBufferInputStream);
296+ if (jarInputStream == NULL)
297+ {
298+ result->msg_id = MSG_ID_ERR_NEW_OBJECT;
299+ sprintf(result->msg, _(MSG_ID_ERR_NEW_OBJECT), "java.util.jar.JarInputStream(exewrap.core.ByteBufferInputStream)");
300+ goto EXIT;
301+ }
302+ (*env)->SetObjectArrayElement(env, jars, 0, jarInputStream);
303+ }
91304
92305 // user.jar or user.pack.gz
93306 {
@@ -153,7 +366,13 @@
153366 }
154367
155368 // PackInputStream
156- PackInputStream = (*env)->FindClass(env, "exewrap/core/PackInputStream");
369+ if (GetResource("PACK_INPUT_STREAM", &res) == NULL)
370+ {
371+ result->msg_id = MSG_ID_ERR_RESOURCE_NOT_FOUND;
372+ sprintf(result->msg, _(MSG_ID_ERR_RESOURCE_NOT_FOUND), "RT_RCDATA: PACK_INPUT_STREAM");
373+ goto EXIT;
374+ }
375+ PackInputStream = (*env)->DefineClass(env, "exewrap/core/PackInputStream", systemClassLoader, res.buf, res.len);
157376 if (PackInputStream == NULL)
158377 {
159378 result->msg_id = MSG_ID_ERR_FIND_CLASS;
@@ -195,76 +414,11 @@
195414 goto EXIT;
196415 }
197416 }
198- (*env)->SetObjectArrayElement(env, jars, 0, jarInputStream);
417+ (*env)->SetObjectArrayElement(env, jars, 1, jarInputStream);
199418 }
200419
201- // ExewrapClassLoader
202- ExewrapClassLoader = (*env)->FindClass(env, "exewrap/core/ExewrapClassLoader");
203- if (ExewrapClassLoader == NULL)
204- {
205- result->msg_id = MSG_ID_ERR_FIND_CLASS;
206- sprintf(result->msg, _(MSG_ID_ERR_FIND_CLASS), "exewrap.core.ExewrapClassLoader");
207- goto EXIT;
208- }
209-
210- // register native methods
211- if (register_native(env, ExewrapClassLoader, "WriteConsole", "([BII)V", JNI_WriteConsole) != 0)
212- {
213- result->msg_id = MSG_ID_ERR_REGISTER_NATIVE;
214- sprintf(result->msg, _(MSG_ID_ERR_REGISTER_NATIVE), "WriteConsole");
215- goto EXIT;
216- }
217- if (register_native(env, ExewrapClassLoader, "WriteEventLog", "(ILjava/lang/String;)V", JNI_WriteEventLog) != 0)
218- {
219- result->msg_id = MSG_ID_ERR_REGISTER_NATIVE;
220- sprintf(result->msg, _(MSG_ID_ERR_REGISTER_NATIVE), "WriteEventLog");
221- goto EXIT;
222- }
223- if (register_native(env, ExewrapClassLoader, "UncaughtException", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", JNI_UncaughtException) != 0)
224- {
225- result->msg_id = MSG_ID_ERR_REGISTER_NATIVE;
226- sprintf(result->msg, _(MSG_ID_ERR_REGISTER_NATIVE), "UncaughtException");
227- goto EXIT;
228- }
229- if (register_native(env, ExewrapClassLoader, "SetEnvironment", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", JNI_SetEnvironment) != 0)
230- {
231- result->msg_id = MSG_ID_ERR_REGISTER_NATIVE;
232- sprintf(result->msg, _(MSG_ID_ERR_REGISTER_NATIVE), "SetEnvironment");
233- goto EXIT;
234- }
235-
236- ExewrapClassLoader_setInputs = (*env)->GetStaticMethodID(env, ExewrapClassLoader, "setInputs", "([Ljava/util/jar/JarInputStream;)V");
237- if (ExewrapClassLoader_setInputs == NULL)
238- {
239- result->msg_id = MSG_ID_ERR_GET_METHOD;
240- sprintf(result->msg, _(MSG_ID_ERR_GET_METHOD), "exewrap.core.ExewrapClassLoader.setInputs(java.util.jar.JarInputStream[])");
241- goto EXIT;
242- }
243- (*env)->CallStaticObjectMethod(env, ExewrapClassLoader, ExewrapClassLoader_setInputs, jars);
244-
245-
246- ExewrapClassLoader_loadUtilities = (*env)->GetStaticMethodID(env, ExewrapClassLoader, "loadUtilities", "(Ljava/lang/String;)V");
247- if (ExewrapClassLoader_loadUtilities == NULL)
248- {
249- result->msg_id = MSG_ID_ERR_GET_METHOD;
250- sprintf(result->msg, _(MSG_ID_ERR_GET_METHOD), "exewrap.core.ExewrapClassLoader.loadUtilities(java.lang.String)");
251- goto EXIT;
252- }
253- // exewrapClassLoader.loadUtilities();
254- {
255- jstring s = GetJString(env, utilities);
256- (*env)->CallStaticObjectMethod(env, ExewrapClassLoader, ExewrapClassLoader_loadUtilities, s);
257- }
258-
259- // MainClass
260- ExewrapClassLoader_getMainClass = (*env)->GetStaticMethodID(env, ExewrapClassLoader, "getMainClass", "(Ljava/lang/String;)Ljava/lang/Class;");
261- if (ExewrapClassLoader_getMainClass == NULL)
262- {
263- result->msg_id = MSG_ID_ERR_GET_METHOD;
264- sprintf(result->msg, _(MSG_ID_ERR_GET_METHOD), "exewrap.core.ExewrapClassLoader.getMainClass(java.lang.String)");
265- goto EXIT;
266- }
267- MainClass = (*env)->CallStaticObjectMethod(env, ExewrapClassLoader, ExewrapClassLoader_getMainClass, GetJString(env, GetResource("MAIN_CLASS", NULL)));
420+ // call Main
421+ MainClass = (*env)->CallStaticObjectMethod(env, Loader, Loader_initialize, jars, urlStreamHandlerFactory, GetJString(env, utilities), GetJString(env, GetResource("MAIN_CLASS", NULL)));
268422 if (MainClass == NULL)
269423 {
270424 result->msg_id = MSG_ID_ERR_LOAD_MAIN_CLASS;
@@ -308,7 +462,8 @@
308462 BOOL ret = FALSE;
309463 jstring name;
310464 jbyteArray image;
311- jmethodID ExewrapClassLoader_setSplashScreenResource;
465+ jclass Map;
466+ jmethodID Map_put;
312467
313468 name = GetJString(env, splash_screen_name);
314469 if (name == NULL)
@@ -323,13 +478,18 @@
323478 }
324479 (*env)->SetByteArrayRegion(env, image, 0, splash_screen_image_len, splash_screen_image_buf);
325480
326- ExewrapClassLoader_setSplashScreenResource = (*env)->GetStaticMethodID(env, ExewrapClassLoader, "setSplashScreenResource", "(Ljava/lang/String;[B)V");
327- if (ExewrapClassLoader_setSplashScreenResource == NULL)
481+ Map = (*env)->FindClass(env, "java/util/Map");
482+ if(Map == NULL)
328483 {
329484 goto EXIT;
330485 }
486+ Map_put = (*env)->GetMethodID(env, Map, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
487+ if (Map_put == NULL)
488+ {
489+ goto EXIT;
490+ }
331491
332- (*env)->CallStaticVoidMethod(env, ExewrapClassLoader, ExewrapClassLoader_setSplashScreenResource, name, image);
492+ (*env)->CallObjectMethod(env, resources, Map_put, name, image);
333493
334494 ret = TRUE;
335495
--- exewrap/trunk/exewrap/src/exewrap.c (revision 39)
+++ exewrap/trunk/exewrap/src/exewrap.c (revision 40)
@@ -223,7 +223,7 @@
223223 set_resource(exe_file, "EXTDIRS", RT_RCDATA, "lib", 4);
224224 }
225225
226- enable_java = CreateJavaVM(NULL, "exewrap.core.ExewrapClassLoader", FALSE, TRUE, NULL) != NULL;
226+ enable_java = CreateJavaVM(NULL, "Loader", FALSE, TRUE, NULL) != NULL;
227227 if (enable_java)
228228 {
229229 LOAD_RESULT result;
@@ -246,7 +246,7 @@
246246
247247 if (LoadMainClass(argc, argv, NULL, &result) == FALSE)
248248 {
249- printf("ERROR: LoadMainClass: tool.jar exewrap.tool.JarProcessor\n");
249+ printf("ERROR: LoadMainClass: tool.jar exewrap.tool.JarProcessor: %s\n", result.msg);
250250 goto EXIT;
251251 }
252252 JarProcessor = result.MainClass;
@@ -509,9 +509,9 @@
509509 original_filename = strrchr(exe_file, '\\') + 1;
510510 new_version = set_version_info(exe_file, version_number, previous_revision, file_description, copyright, company_name, product_name, product_version, original_filename, jar_file);
511511
512- if(GetResource("CORE_JAR", &res) == NULL)
512+ if(GetResource("LOADER", &res) == NULL)
513513 {
514- printf("ERROR: GetResource: CORE_JAR\n");
514+ printf("ERROR: GetResource: LOADER\n");
515515 goto EXIT;
516516 }
517517 else
--- exewrap/trunk/exewrap/src/message.c (revision 39)
+++ exewrap/trunk/exewrap/src/message.c (revision 40)
@@ -82,6 +82,9 @@
8282 msg[MSG_ID_COUNT * MSG_LANG_ID_EN + MSG_ID_ERR_TARGET_VERSION] =
8383 "%s or higher is required to run this program.";
8484
85+ msg[MSG_ID_COUNT * MSG_LANG_ID_EN + MSG_ID_ERR_DEFINE_CLASS] =
86+ "Class not found: %s";
87+
8588 msg[MSG_ID_COUNT * MSG_LANG_ID_EN + MSG_ID_ERR_FIND_CLASS] =
8689 "Class not found: %s";
8790
@@ -88,6 +91,9 @@
8891 msg[MSG_ID_COUNT * MSG_LANG_ID_EN + MSG_ID_ERR_GET_CONSTRUCTOR] =
8992 "Constructor not found: %s";
9093
94+ msg[MSG_ID_COUNT * MSG_LANG_ID_EN + MSG_ID_ERR_GET_FIELD] =
95+ "Field not found: %s";
96+
9197 msg[MSG_ID_COUNT * MSG_LANG_ID_EN + MSG_ID_ERR_GET_METHOD] =
9298 "Method not found: %s";
9399
@@ -94,6 +100,9 @@
94100 msg[MSG_ID_COUNT * MSG_LANG_ID_EN + MSG_ID_ERR_NEW_OBJECT] =
95101 "Failed to create object: %s";
96102
103+ msg[MSG_ID_COUNT * MSG_LANG_ID_EN + MSG_ID_ERR_NULL_OBJECT] =
104+ "Object is null: %s";
105+
97106 msg[MSG_ID_COUNT * MSG_LANG_ID_EN + MSG_ID_ERR_FIND_CLASSLOADER] =
98107 "Class Loader not found.";
99108
@@ -182,6 +191,9 @@
182191 msg[MSG_ID_COUNT * MSG_LANG_ID_JA + MSG_ID_ERR_TARGET_VERSION] =
183192 "このプログラムの実行には%s以上が必要です。";
184193
194+ msg[MSG_ID_COUNT * MSG_LANG_ID_JA + MSG_ID_ERR_DEFINE_CLASS] =
195+ "クラスが見つかりません: %s";
196+
185197 msg[MSG_ID_COUNT * MSG_LANG_ID_JA + MSG_ID_ERR_FIND_CLASS] =
186198 "クラスが見つかりません: %s";
187199
@@ -188,6 +200,9 @@
188200 msg[MSG_ID_COUNT * MSG_LANG_ID_JA + MSG_ID_ERR_GET_CONSTRUCTOR] =
189201 "コンストラクターが見つかりません: %s";
190202
203+ msg[MSG_ID_COUNT * MSG_LANG_ID_JA + MSG_ID_ERR_GET_FIELD] =
204+ "フィールドが見つかりません: %s";
205+
191206 msg[MSG_ID_COUNT * MSG_LANG_ID_JA + MSG_ID_ERR_GET_METHOD] =
192207 "メソッドが見つかりません: %s";
193208
@@ -194,6 +209,9 @@
194209 msg[MSG_ID_COUNT * MSG_LANG_ID_JA + MSG_ID_ERR_NEW_OBJECT] =
195210 "オブジェクトの作成に失敗しました: %s";
196211
212+ msg[MSG_ID_COUNT * MSG_LANG_ID_JA + MSG_ID_ERR_NULL_OBJECT] =
213+ "オブジェクト参照がありません: %s";
214+
197215 msg[MSG_ID_COUNT * MSG_LANG_ID_JA + MSG_ID_ERR_FIND_CLASSLOADER] =
198216 "クラスローダーが見つかりません。";
199217
--- exewrap/trunk/exewrap/src/image_gui.c (revision 39)
+++ exewrap/trunk/exewrap/src/image_gui.c (revision 40)
@@ -20,7 +20,6 @@
2020 #include "include/loader.h"
2121 #include "include/notify.h"
2222 #include "include/message.h"
23-#include "include/trace.h"
2423
2524 void OutputConsole(BYTE* buf, DWORD len);
2625 void OutputMessage(const char* text);
@@ -56,17 +55,6 @@
5655 LOAD_RESULT result;
5756
5857 utilities[0] = '\0';
59- #ifdef TRACE
60- {
61- const char* filename = StartTrace(FALSE);
62- vm_args_opt = (char*)malloc(1024);
63- sprintf(vm_args_opt, "-XX:+UnlockDiagnosticVMOptions -XX:+LogVMOutput -XX:LogFile=\"%s\" ", filename);
64- if (GetResource("VMARGS", &res) != NULL)
65- {
66- strcat(vm_args_opt, res.buf);
67- }
68- }
69- #endif
7058
7159 argv = get_args(&argc);
7260 result.msg = malloc(2048);
@@ -119,7 +107,7 @@
119107 {
120108 vm_args_opt = (char*)GetResource("VMARGS", NULL);
121109 }
122- CreateJavaVM(vm_args_opt, "exewrap.core.ExewrapClassLoader", use_server_vm, use_side_by_side_jre, &err);
110+ CreateJavaVM(vm_args_opt, "Loader", use_server_vm, use_side_by_side_jre, &err);
123111 if (err != JNI_OK)
124112 {
125113 OutputMessage(GetJniErrorMessage(err, &result.msg_id, result.msg));
@@ -204,10 +192,6 @@
204192
205193 NotifyClose();
206194
207- #ifdef TRACE
208- StopTrace();
209- #endif
210-
211195 return result.msg_id;
212196 }
213197
--- exewrap/trunk/exewrap/src/Makefile (revision 39)
+++ exewrap/trunk/exewrap/src/Makefile (revision 40)
@@ -35,7 +35,6 @@
3535 LDFLAGS=\
3636 /nologo\
3737 /MACHINE:$(ARCHITECTURE)\
38- /LTCG\
3938 /OPT:REF
4039
4140 ALL :
@@ -56,27 +55,34 @@
5655
5756 $(OBJ) :
5857 @if not exist $(OBJ)/$(NULL) mkdir $(OBJ)
59-
60-$(OBJ)\exewrap-tool :
61- @if not exist $(OBJ)\exewrap-tool/$(NULL) mkdir $(OBJ)\exewrap-tool
6258
6359 $(BIN)\exewrap.exe : $(BIN) $(OBJ) $(OBJ)\exewrap.res $(OBJ)\exewrap.obj \
6460 $(OBJ)\jvm.obj $(OBJ)\loader.obj $(OBJ)\message.obj $(OBJ)\eventlog.obj \
61+ $(OBJ)\bindres.exe \
6562 $(OBJ)\image_console.exe $(OBJ)\image_gui.exe $(OBJ)\image_service.exe \
66- $(OBJ)\bindres.exe $(OBJ)\core.jar $(OBJ)\tool.jar
63+ $(OBJ)\exewrap\core\ByteBufferInputStream.class $(OBJ)\exewrap\core\NativeMethods.class $(OBJ)\exewrap\core\PackInputStream.class \
64+ $(OBJ)\exewrap\core\URLConnection.class $(OBJ)\exewrap\core\URLStreamHandler.class $(OBJ)\exewrap\core\URLStreamHandlerFactory.class \
65+ $(OBJ)\util.jar $(OBJ)\tool.jar $(OBJ)\loader.jar
6766 $(LINK) $(LDFLAGS) /SUBSYSTEM:CONSOLE$(TARGET_VER) /MANIFEST /MANIFESTFILE:$(OBJ)\exewrap.exe.manifest /OUT:$(OBJ)\exewrap.exe $(OBJ)\exewrap.res $(OBJ)\exewrap.obj \
6867 $(OBJ)\jvm.obj $(OBJ)\loader.obj $(OBJ)\message.obj $(OBJ)\eventlog.obj $(LIBS) $(MSVCRT_PATCH)
6968 $(MT) -manifest $(OBJ)\exewrap.exe.manifest -outputresource:$(BIN)\exewrap.exe;1
70- $(OBJ)\bindres.exe $(OBJ)\exewrap.exe VERSION_INFO resources\versioninfo.bin
71- $(OBJ)\bindres.exe -r $(OBJ)\exewrap.exe IMAGE_CONSOLE_32 $(OBJ)\..\x86\image_console.exe
72- $(OBJ)\bindres.exe -r $(OBJ)\exewrap.exe IMAGE_CONSOLE_64 $(OBJ)\..\x64\image_console.exe
73- $(OBJ)\bindres.exe -r $(OBJ)\exewrap.exe IMAGE_GUI_32 $(OBJ)\..\x86\image_gui.exe
74- $(OBJ)\bindres.exe -r $(OBJ)\exewrap.exe IMAGE_GUI_64 $(OBJ)\..\x64\image_gui.exe
75- $(OBJ)\bindres.exe -r $(OBJ)\exewrap.exe IMAGE_SERVICE_32 $(OBJ)\..\x86\image_service.exe
76- $(OBJ)\bindres.exe -r $(OBJ)\exewrap.exe IMAGE_SERVICE_64 $(OBJ)\..\x64\image_service.exe
77- $(OBJ)\bindres.exe $(OBJ)\exewrap.exe JAR $(OBJ)\tool.jar
78- $(OBJ)\bindres.exe $(OBJ)\exewrap.exe CORE_JAR $(OBJ)\core.jar
79- copy /V /Y /B $(OBJ)\exewrap.exe + $(OBJ)\core.jar $(BIN)\exewrap.exe
69+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe VERSION_INFO resources\versioninfo.bin
70+ $(OBJ)\bindres.exe -r $(OBJ)\exewrap.exe IMAGE_CONSOLE_32 $(OBJ)\..\x86\image_console.exe
71+ $(OBJ)\bindres.exe -r $(OBJ)\exewrap.exe IMAGE_CONSOLE_64 $(OBJ)\..\x64\image_console.exe
72+ $(OBJ)\bindres.exe -r $(OBJ)\exewrap.exe IMAGE_GUI_32 $(OBJ)\..\x86\image_gui.exe
73+ $(OBJ)\bindres.exe -r $(OBJ)\exewrap.exe IMAGE_GUI_64 $(OBJ)\..\x64\image_gui.exe
74+ $(OBJ)\bindres.exe -r $(OBJ)\exewrap.exe IMAGE_SERVICE_32 $(OBJ)\..\x86\image_service.exe
75+ $(OBJ)\bindres.exe -r $(OBJ)\exewrap.exe IMAGE_SERVICE_64 $(OBJ)\..\x64\image_service.exe
76+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe BYTE_BUFFER_INPUT_STREAM $(OBJ)\exewrap\core\ByteBufferInputStream.class
77+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe NATIVE_METHODS $(OBJ)\exewrap\core\NativeMethods.class
78+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe PACK_INPUT_STREAM $(OBJ)\exewrap\core\PackInputStream.class
79+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe URL_CONNECTION $(OBJ)\exewrap\core\URLConnection.class
80+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe URL_STREAM_HANDLER $(OBJ)\exewrap\core\URLStreamHandler.class
81+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe URL_STREAM_HANDLER_FACTORY $(OBJ)\exewrap\core\URLStreamHandlerFactory.class
82+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe UTIL_JAR $(OBJ)\util.jar
83+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe JAR $(OBJ)\tool.jar
84+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe LOADER $(OBJ)\loader.jar
85+ copy /V /Y /B $(OBJ)\exewrap.exe + $(OBJ)\loader.jar $(BIN)\exewrap.exe
8086
8187 $(OBJ)\exewrap.obj : $(OBJ) exewrap.c
8288 $(CC) $(CFLAGS) $(INC) /Fo$(OBJ)\exewrap.obj exewrap.c
@@ -86,10 +92,20 @@
8692
8793 $(OBJ)\image_console.exe : $(OBJ) $(OBJ)\image_console.res $(OBJ)\image_console.obj \
8894 $(OBJ)\jvm.obj $(OBJ)\loader.obj $(OBJ)\message.obj $(OBJ)\notify.obj $(OBJ)\eventlog.obj \
89- $(OBJ)\bindres.exe $(OBJ)\core.jar
95+ $(OBJ)\bindres.exe \
96+ $(OBJ)\exewrap\core\ByteBufferInputStream.class $(OBJ)\exewrap\core\NativeMethods.class $(OBJ)\exewrap\core\PackInputStream.class \
97+ $(OBJ)\exewrap\core\URLConnection.class $(OBJ)\exewrap\core\URLStreamHandler.class $(OBJ)\exewrap\core\URLStreamHandlerFactory.class \
98+ $(OBJ)\util.jar
9099 $(LINK) $(LDFLAGS) /SUBSYSTEM:CONSOLE$(TARGET_VER) /MANIFEST /OUT:$(OBJ)\image_console.exe $(OBJ)\image_console.obj \
91100 $(OBJ)\jvm.obj $(OBJ)\loader.obj $(OBJ)\message.obj $(OBJ)\notify.obj $(OBJ)\eventlog.obj $(LIBS) $(MSVCRT_PATCH)
92101 $(MT) -manifest $(OBJ)\image_console.exe.manifest -outputresource:$(OBJ)\image_console.exe;1
102+ $(OBJ)\bindres.exe $(OBJ)\image_console.exe BYTE_BUFFER_INPUT_STREAM $(OBJ)\exewrap\core\ByteBufferInputStream.class
103+ $(OBJ)\bindres.exe $(OBJ)\image_console.exe NATIVE_METHODS $(OBJ)\exewrap\core\NativeMethods.class
104+ $(OBJ)\bindres.exe $(OBJ)\image_console.exe PACK_INPUT_STREAM $(OBJ)\exewrap\core\PackInputStream.class
105+ $(OBJ)\bindres.exe $(OBJ)\image_console.exe URL_CONNECTION $(OBJ)\exewrap\core\URLConnection.class
106+ $(OBJ)\bindres.exe $(OBJ)\image_console.exe URL_STREAM_HANDLER $(OBJ)\exewrap\core\URLStreamHandler.class
107+ $(OBJ)\bindres.exe $(OBJ)\image_console.exe URL_STREAM_HANDLER_FACTORY $(OBJ)\exewrap\core\URLStreamHandlerFactory.class
108+ $(OBJ)\bindres.exe $(OBJ)\image_console.exe UTIL_JAR $(OBJ)\util.jar
93109
94110 $(OBJ)\image_console.res : $(OBJ) resources\image_console.rc resources\eventlog.bin
95111 $(RC) /fo$(OBJ)\image_console.res resources\image_console.rc
@@ -99,10 +115,20 @@
99115
100116 $(OBJ)\image_gui.exe : $(OBJ) $(OBJ)\image_gui.res $(OBJ)\image_gui.obj \
101117 $(OBJ)\jvm.obj $(OBJ)\loader.obj $(OBJ)\message.obj $(OBJ)\notify.obj $(OBJ)\eventlog.obj \
102- $(OBJ)\bindres.exe $(OBJ)\core.jar
118+ $(OBJ)\bindres.exe \
119+ $(OBJ)\exewrap\core\ByteBufferInputStream.class $(OBJ)\exewrap\core\NativeMethods.class $(OBJ)\exewrap\core\PackInputStream.class \
120+ $(OBJ)\exewrap\core\URLConnection.class $(OBJ)\exewrap\core\URLStreamHandler.class $(OBJ)\exewrap\core\URLStreamHandlerFactory.class \
121+ $(OBJ)\util.jar
103122 $(LINK) $(LDFLAGS) /SUBSYSTEM:WINDOWS$(TARGET_VER) /MANIFEST /OUT:$(OBJ)\image_gui.exe $(OBJ)\image_gui.res $(OBJ)\image_gui.obj \
104123 $(OBJ)\jvm.obj $(OBJ)\loader.obj $(OBJ)\message.obj $(OBJ)\notify.obj $(OBJ)\eventlog.obj $(LIBS) $(MSVCRT_PATCH)
105124 $(MT) -manifest $(OBJ)\image_gui.exe.manifest -outputresource:$(OBJ)\image_gui.exe;1
125+ $(OBJ)\bindres.exe $(OBJ)\image_gui.exe BYTE_BUFFER_INPUT_STREAM $(OBJ)\exewrap\core\ByteBufferInputStream.class
126+ $(OBJ)\bindres.exe $(OBJ)\image_gui.exe NATIVE_METHODS $(OBJ)\exewrap\core\NativeMethods.class
127+ $(OBJ)\bindres.exe $(OBJ)\image_gui.exe PACK_INPUT_STREAM $(OBJ)\exewrap\core\PackInputStream.class
128+ $(OBJ)\bindres.exe $(OBJ)\image_gui.exe URL_CONNECTION $(OBJ)\exewrap\core\URLConnection.class
129+ $(OBJ)\bindres.exe $(OBJ)\image_gui.exe URL_STREAM_HANDLER $(OBJ)\exewrap\core\URLStreamHandler.class
130+ $(OBJ)\bindres.exe $(OBJ)\image_gui.exe URL_STREAM_HANDLER_FACTORY $(OBJ)\exewrap\core\URLStreamHandlerFactory.class
131+ $(OBJ)\bindres.exe $(OBJ)\image_gui.exe UTIL_JAR $(OBJ)\util.jar
106132
107133 $(OBJ)\image_gui.res : $(OBJ) resources\image_gui.rc resources\eventlog.bin
108134 $(RC) /fo$(OBJ)\image_gui.res resources\image_gui.rc
@@ -112,10 +138,20 @@
112138
113139 $(OBJ)\image_service.exe : $(OBJ) $(OBJ)\image_service.res $(OBJ)\image_service.obj \
114140 $(OBJ)\jvm.obj $(OBJ)\loader.obj $(OBJ)\message.obj $(OBJ)\eventlog.obj \
115- $(OBJ)\bindres.exe $(OBJ)\core.jar
141+ $(OBJ)\bindres.exe \
142+ $(OBJ)\exewrap\core\ByteBufferInputStream.class $(OBJ)\exewrap\core\NativeMethods.class $(OBJ)\exewrap\core\PackInputStream.class \
143+ $(OBJ)\exewrap\core\URLConnection.class $(OBJ)\exewrap\core\URLStreamHandler.class $(OBJ)\exewrap\core\URLStreamHandlerFactory.class \
144+ $(OBJ)\util.jar
116145 $(LINK) $(LDFLAGS) /SUBSYSTEM:CONSOLE$(TARGET_VER) /MANIFEST /OUT:$(OBJ)\image_service.exe $(OBJ)\image_service.res $(OBJ)\image_service.obj \
117146 $(OBJ)\jvm.obj $(OBJ)\loader.obj $(OBJ)\message.obj $(OBJ)\eventlog.obj $(LIBS) $(MSVCRT_PATCH)
118147 $(MT) -manifest $(OBJ)\image_service.exe.manifest -outputresource:$(OBJ)\image_service.exe;1
148+ $(OBJ)\bindres.exe $(OBJ)\image_service.exe BYTE_BUFFER_INPUT_STREAM $(OBJ)\exewrap\core\ByteBufferInputStream.class
149+ $(OBJ)\bindres.exe $(OBJ)\image_service.exe NATIVE_METHODS $(OBJ)\exewrap\core\NativeMethods.class
150+ $(OBJ)\bindres.exe $(OBJ)\image_service.exe PACK_INPUT_STREAM $(OBJ)\exewrap\core\PackInputStream.class
151+ $(OBJ)\bindres.exe $(OBJ)\image_service.exe URL_CONNECTION $(OBJ)\exewrap\core\URLConnection.class
152+ $(OBJ)\bindres.exe $(OBJ)\image_service.exe URL_STREAM_HANDLER $(OBJ)\exewrap\core\URLStreamHandler.class
153+ $(OBJ)\bindres.exe $(OBJ)\image_service.exe URL_STREAM_HANDLER_FACTORY $(OBJ)\exewrap\core\URLStreamHandlerFactory.class
154+ $(OBJ)\bindres.exe $(OBJ)\image_service.exe UTIL_JAR $(OBJ)\util.jar
119155
120156 $(OBJ)\image_service.res : $(OBJ) resources\image_service.rc resources\eventlog.bin
121157 $(RC) /fo$(OBJ)\image_service.res resources\image_service.rc
@@ -149,20 +185,29 @@
149185 ### Java
150186 ###
151187
152-### exewrap.core (including exewrap.util)
188+### exewrap system class loader
153189
154-$(OBJ)\core.jar : $(OBJ) $(OBJ)\exewrap\core\ExewrapClassLoader.class $(OBJ)\exewrap\core\PackInputStream.class $(OBJ)\exewrap\core\ByteBufferInputStream.class $(OBJ)\exewrap\core\URLConnection.class $(OBJ)\exewrap\core\URLStreamHandler.class $(OBJ)\exewrap\core\URLStreamHandler.class $(OBJ)\exewrap\util\EventLogHandler.class $(OBJ)\exewrap\util\EventLogStream.class $(OBJ)\exewrap\util\FileLogStream.class $(OBJ)\exewrap\util\UncaughtExceptionHandler.class $(OBJ)\exewrap\util\ConsoleOutputStream.class $(OBJ)\exewrap\util\Environment.class
155- $(JAR) cvf $(OBJ)\core.jar -C $(OBJ) exewrap
190+$(OBJ)\loader.jar : $(OBJ) $(OBJ)\exewrap-loader\Loader.class
191+ $(JAR) cvfM $(OBJ)\loader.jar -C $(OBJ) Loader.class
156192
193+$(OBJ)\exewrap-loader\Loader.class : $(OBJ) java\Loader.java
194+ $(JAVAC) -Xlint:none -source 1.5 -target 1.5 -sourcepath java -d $(OBJ) java\Loader.java
195+
196+
197+### exewrap.core
198+
157199 $(OBJ)\exewrap\core\ExewrapClassLoader.class : $(OBJ) java\exewrap\core\ExewrapClassLoader.java
158200 $(JAVAC) -Xlint:none -source 1.5 -target 1.5 -sourcepath java -d $(OBJ) java\exewrap\core\ExewrapClassLoader.java
159201
202+$(OBJ)\exewrap\core\ByteBufferInputStream.class : $(OBJ) java\exewrap\core\ByteBufferInputStream.java
203+ $(JAVAC) -Xlint:none -source 1.5 -target 1.5 -sourcepath java -d $(OBJ) java\exewrap\core\ByteBufferInputStream.java
204+
205+$(OBJ)\exewrap\core\NativeMethods.class : $(OBJ) java\exewrap\core\NativeMethods.java
206+ $(JAVAC) -Xlint:none -source 1.5 -target 1.5 -sourcepath java -d $(OBJ) java\exewrap\core\NativeMethods.java
207+
160208 $(OBJ)\exewrap\core\PackInputStream.class : $(OBJ) java\exewrap\core\PackInputStream.java
161209 $(JAVAC) -Xlint:none -source 1.5 -target 1.5 -sourcepath java -d $(OBJ) java\exewrap\core\PackInputStream.java
162210
163-$(OBJ)\exewrap\core\ByteBufferInputStream.class : $(OBJ) java\exewrap\core\ByteBufferInputStream.java
164- $(JAVAC) -Xlint:none -source 1.5 -target 1.5 -sourcepath java -d $(OBJ) java\exewrap\core\ByteBufferInputStream.java
165-
166211 $(OBJ)\exewrap\core\URLConnection.class : $(OBJ) java\exewrap\core\URLConnection.java
167212 $(JAVAC) -Xlint:none -source 1.5 -target 1.5 -sourcepath java -d $(OBJ) java\exewrap\core\URLConnection.java
168213
@@ -175,8 +220,14 @@
175220 ### exewrap.util
176221
177222 $(OBJ)\util.jar : $(OBJ) $(OBJ)\exewrap\util\EventLogHandler.class $(OBJ)\exewrap\util\EventLogStream.class $(OBJ)\exewrap\util\FileLogStream.class $(OBJ)\exewrap\util\UncaughtExceptionHandler.class $(OBJ)\exewrap\util\ConsoleOutputStream.class $(OBJ)\exewrap\util\Environment.class
178- $(JAR) cvf $(OBJ)\util.jar -C $(OBJ) exewrap\util
223+ $(JAR) cvfM $(OBJ)\util.jar -C $(OBJ) exewrap\util
179224
225+$(OBJ)\exewrap\util\ConsoleOutputStream.class : $(OBJ) java\exewrap\util\ConsoleOutputStream.java
226+ $(JAVAC) -Xlint:none -source 1.5 -target 1.5 -sourcepath java -d $(OBJ) java\exewrap\util\ConsoleOutputStream.java
227+
228+$(OBJ)\exewrap\util\Environment.class : $(OBJ) java\exewrap\util\Environment.java
229+ $(JAVAC) -Xlint:none -source 1.5 -target 1.5 -sourcepath java -d $(OBJ) java\exewrap\util\Environment.java
230+
180231 $(OBJ)\exewrap\util\EventLogHandler.class : $(OBJ) java\exewrap\util\EventLogHandler.java
181232 $(JAVAC) -Xlint:none -source 1.5 -target 1.5 -sourcepath java -d $(OBJ) java\exewrap\util\EventLogHandler.java
182233
@@ -189,20 +240,14 @@
189240 $(OBJ)\exewrap\util\UncaughtExceptionHandler.class : $(OBJ) java\exewrap\util\UncaughtExceptionHandler.java
190241 $(JAVAC) -Xlint:none -source 1.5 -target 1.5 -sourcepath java -d $(OBJ) java\exewrap\util\UncaughtExceptionHandler.java
191242
192-$(OBJ)\exewrap\util\ConsoleOutputStream.class : $(OBJ) java\exewrap\util\ConsoleOutputStream.java
193- $(JAVAC) -Xlint:none -source 1.5 -target 1.5 -sourcepath java -d $(OBJ) java\exewrap\util\ConsoleOutputStream.java
194-
195-$(OBJ)\exewrap\util\Environment.class : $(OBJ) java\exewrap\util\Environment.java
196- $(JAVAC) -Xlint:none -source 1.5 -target 1.5 -sourcepath java -d $(OBJ) java\exewrap\util\Environment.java
197-
198243 ### exewrap.tool
199244
200-$(OBJ)\tool.jar : $(OBJ) $(OBJ)\exewrap-tool $(OBJ)\exewrap\tool\JarProcessor.class $(OBJ)\exewrap\tool\PackOutputStream.class
201- $(JAR) cvfe $(OBJ)\tool.jar exewrap.tool.JarProcessor -C $(OBJ)\exewrap-tool exewrap\tool
245+$(OBJ)\tool.jar : $(OBJ) $(OBJ)\exewrap\tool\JarProcessor.class $(OBJ)\exewrap\tool\PackOutputStream.class
246+ $(JAR) cvfe $(OBJ)\tool.jar exewrap.tool.JarProcessor -C $(OBJ) exewrap\tool
202247
203248 $(OBJ)\exewrap\tool\PackOutputStream.class : $(OBJ) java\exewrap\tool\PackOutputStream.java
204- $(JAVAC) -Xlint:none -source 1.5 -target 1.5 -sourcepath java -d $(OBJ)\exewrap-tool java\exewrap\tool\PackOutputStream.java
249+ $(JAVAC) -Xlint:none -source 1.5 -target 1.5 -sourcepath java -d $(OBJ) java\exewrap\tool\PackOutputStream.java
205250
206251 $(OBJ)\exewrap\tool\JarProcessor.class : $(OBJ) java\exewrap\tool\JarProcessor.java
207- $(JAVAC) -Xlint:none -source 1.5 -target 1.5 -sourcepath java -d $(OBJ)\exewrap-tool java\exewrap\tool\JarProcessor.java
252+ $(JAVAC) -Xlint:none -source 1.5 -target 1.5 -sourcepath java -d $(OBJ) java\exewrap\tool\JarProcessor.java
208253
--- exewrap/trunk/exewrap/src/java/Loader.java (revision 0)
+++ exewrap/trunk/exewrap/src/java/Loader.java (revision 40)
@@ -0,0 +1,203 @@
1+import java.io.ByteArrayOutputStream;
2+import java.io.IOException;
3+import java.net.MalformedURLException;
4+import java.net.URL;
5+import java.net.URLStreamHandler;
6+import java.net.URLStreamHandlerFactory;
7+import java.security.CodeSource;
8+import java.security.PermissionCollection;
9+import java.security.Policy;
10+import java.security.ProtectionDomain;
11+import java.security.cert.Certificate;
12+import java.util.HashMap;
13+import java.util.LinkedList;
14+import java.util.Map;
15+import java.util.Queue;
16+import java.util.jar.JarEntry;
17+import java.util.jar.JarInputStream;
18+import java.util.jar.Manifest;
19+import java.util.jar.Attributes.Name;
20+
21+public class Loader extends ClassLoader {
22+
23+ private static String CONTEXT_PATH;
24+ private static Map<String, byte[]> classes = new HashMap<String, byte[]>();
25+ public static Map<String, byte[]> resources = new HashMap<String, byte[]>();
26+ private static Queue<JarInputStream> inputs = new LinkedList<JarInputStream>();
27+ private static JarInputStream jar;
28+ private static String MAIN_CLASS;
29+ private static String SPECIFICATION_TITLE;
30+ private static String SPECIFICATION_VERSION;
31+ private static String SPECIFICATION_VENDOR;
32+ private static String IMPLEMENTATION_TITLE;
33+ private static String IMPLEMENTATION_VERSION;
34+ private static String IMPLEMENTATION_VENDOR;
35+ private static boolean SEALED = true;
36+ private static URL context;
37+ private static URLStreamHandler handler;
38+
39+ public static Class<?> initialize(JarInputStream[] jars, URLStreamHandlerFactory factory, String utilities, String mainClassName) throws MalformedURLException, ClassNotFoundException {
40+ URL.setURLStreamHandlerFactory(factory);
41+ handler = factory.createURLStreamHandler("exewrap");
42+ context = new URL("exewrap:" + CONTEXT_PATH + "!/");
43+
44+ for(int i = 0; i < jars.length; i++) {
45+ JarInputStream jar = jars[i];
46+ if(jar == null) {
47+ continue;
48+ }
49+ if(i == jars.length - 1) {
50+ Manifest manifest = jar.getManifest();
51+ if(manifest != null) {
52+ MAIN_CLASS = manifest.getMainAttributes().getValue(Name.MAIN_CLASS);
53+ SPECIFICATION_TITLE = manifest.getMainAttributes().getValue(Name.SPECIFICATION_TITLE);
54+ SPECIFICATION_VERSION = manifest.getMainAttributes().getValue(Name.SPECIFICATION_VERSION);
55+ SPECIFICATION_VENDOR = manifest.getMainAttributes().getValue(Name.SPECIFICATION_VENDOR);
56+ IMPLEMENTATION_TITLE = manifest.getMainAttributes().getValue(Name.IMPLEMENTATION_TITLE);
57+ IMPLEMENTATION_VERSION = manifest.getMainAttributes().getValue(Name.IMPLEMENTATION_VERSION);
58+ IMPLEMENTATION_VENDOR = manifest.getMainAttributes().getValue(Name.IMPLEMENTATION_VENDOR);
59+ SEALED = "true".equalsIgnoreCase(manifest.getMainAttributes().getValue(Name.SEALED));
60+ }
61+ }
62+ inputs.offer(jar);
63+ }
64+ jar = inputs.poll();
65+
66+ ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
67+
68+ if(utilities != null) {
69+ if(utilities.contains("UncaughtExceptionHandler;")) {
70+ Class.forName("exewrap.util.UncaughtExceptionHandler", true, systemClassLoader);
71+ }
72+ if(utilities.contains("FileLogStream;")) {
73+ Class.forName("exewrap.util.FileLogStream", true, systemClassLoader);
74+ }
75+ if(utilities.contains("EventLogStream;")) {
76+ Class.forName("exewrap.util.EventLogStream", true, systemClassLoader);
77+ }
78+ if(utilities.contains("EventLogHandler;")) {
79+ Class.forName("exewrap.util.EventLogHandler", true, systemClassLoader);
80+ }
81+ if(utilities.contains("ConsoleOutputStream;")) {
82+ Class.forName("exewrap.util.ConsoleOutputStream", true, systemClassLoader);
83+ }
84+ }
85+
86+ if(mainClassName != null) {
87+ return Class.forName(mainClassName, true, systemClassLoader);
88+ } else {
89+ return Class.forName(MAIN_CLASS, true, systemClassLoader);
90+ }
91+ }
92+
93+
94+ private ProtectionDomain protectionDomain;
95+
96+ public Loader(ClassLoader parent) throws MalformedURLException {
97+ super(parent);
98+
99+ String path = System.getProperty("java.application.path");
100+ if(path == null) {
101+ path = "";
102+ }
103+ String name = System.getProperty("java.application.name");
104+ if(name == null) {
105+ name = "";
106+ }
107+
108+ CONTEXT_PATH = "file:/" + path.replace('\\', '/') + '/' + name;
109+ URL url = new URL(CONTEXT_PATH);
110+ CodeSource codesource = new CodeSource(url, (Certificate[])null);
111+ PermissionCollection permissions = Policy.getPolicy().getPermissions(new CodeSource(null, (Certificate[])null));
112+ protectionDomain = new ProtectionDomain(codesource, permissions, this, null);
113+ }
114+
115+ protected Class<?> findClass(String name) throws ClassNotFoundException {
116+ String entryName = name.replace('.', '/').concat(".class");
117+ byte[] bytes = classes.remove(entryName);
118+ if(bytes == null) {
119+ try {
120+ bytes = find(entryName);
121+ } catch(IOException ex) {
122+ throw new ClassNotFoundException(name, ex);
123+ }
124+ }
125+ if(bytes == null) {
126+ throw new ClassNotFoundException(name);
127+ }
128+
129+ if(name.indexOf('.') >= 0) {
130+ String packageName = name.substring(0, name.lastIndexOf('.'));
131+ if(getPackage(packageName) == null) {
132+ definePackage(packageName,
133+ SPECIFICATION_TITLE,
134+ SPECIFICATION_VERSION,
135+ SPECIFICATION_VENDOR,
136+ IMPLEMENTATION_TITLE,
137+ IMPLEMENTATION_VERSION,
138+ IMPLEMENTATION_VENDOR,
139+ SEALED ? protectionDomain.getCodeSource().getLocation() : null);
140+ }
141+ }
142+ return defineClass(name, bytes, 0, bytes.length, protectionDomain);
143+ }
144+
145+ protected URL findResource(String name) {
146+ byte[] bytes = resources.get(name);
147+ if(bytes == null) {
148+ try {
149+ bytes = find(name);
150+ } catch (IOException ex) {
151+ throw new RuntimeException(ex);
152+ }
153+ }
154+ if(bytes == null) {
155+ return null;
156+ }
157+
158+ try {
159+ return new URL(context, name, handler);
160+ } catch (MalformedURLException e) {
161+ e.printStackTrace();
162+ return null;
163+ }
164+ }
165+
166+ private byte[] find(String name) throws IOException {
167+ while(jar != null) {
168+ JarEntry jarEntry;
169+ while((jarEntry = jar.getNextJarEntry()) != null) {
170+ byte[] bytes = readJarEntryBytes(jar);
171+ resources.put(jarEntry.getName(), bytes);
172+ if(jarEntry.getName().endsWith(".class")) {
173+ if(jarEntry.getName().equals(name)) {
174+ return bytes;
175+ } else {
176+ classes.put(jarEntry.getName(), bytes);
177+ }
178+ } else {
179+ if(jarEntry.getName().equals(name)) {
180+ return bytes;
181+ }
182+ }
183+ jar.closeEntry();
184+ }
185+ jar.close();
186+ jar = inputs.poll();
187+ }
188+ return null;
189+ }
190+
191+ private byte[] readJarEntryBytes(JarInputStream in) throws IOException {
192+ ByteArrayOutputStream buf = new ByteArrayOutputStream();
193+ byte[] bytes = new byte[65536];
194+ int len = 0;
195+ while(len != -1) {
196+ len = in.read(bytes);
197+ if(len > 0) {
198+ buf.write(bytes, 0, len);
199+ }
200+ }
201+ return buf.toByteArray();
202+ }
203+}
\ No newline at end of file
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- exewrap/trunk/exewrap/src/java/exewrap/util/Environment.java (revision 39)
+++ exewrap/trunk/exewrap/src/java/exewrap/util/Environment.java (revision 40)
@@ -4,7 +4,7 @@
44 import java.util.Map;
55 import java.util.Set;
66
7-import exewrap.core.ExewrapClassLoader;
7+import exewrap.core.NativeMethods;
88
99 public class Environment implements Map<String, String> {
1010
@@ -44,7 +44,7 @@
4444
4545 @Override
4646 public String put(String key, String value) {
47- return ExewrapClassLoader.SetEnvironment(key, value);
47+ return NativeMethods.SetEnvironment(key, value);
4848 }
4949
5050 @Override
--- exewrap/trunk/exewrap/src/java/exewrap/util/UncaughtExceptionHandler.java (revision 39)
+++ exewrap/trunk/exewrap/src/java/exewrap/util/UncaughtExceptionHandler.java (revision 40)
@@ -3,7 +3,7 @@
33 import java.io.PrintWriter;
44 import java.io.StringWriter;
55
6-import exewrap.core.ExewrapClassLoader;
6+import exewrap.core.NativeMethods;
77
88 public class UncaughtExceptionHandler implements java.lang.Thread.UncaughtExceptionHandler {
99
@@ -13,7 +13,7 @@
1313
1414 public void uncaughtException(Thread t, Throwable e) {
1515 e.printStackTrace();
16- ExewrapClassLoader.UncaughtException(t.getName(), e.toString(), getStackTrace(e));
16+ NativeMethods.UncaughtException(t.getName(), e.toString(), getStackTrace(e));
1717 }
1818
1919 private static String getStackTrace(Throwable t) {
--- exewrap/trunk/exewrap/src/java/exewrap/util/ConsoleOutputStream.java (revision 39)
+++ exewrap/trunk/exewrap/src/java/exewrap/util/ConsoleOutputStream.java (revision 40)
@@ -4,7 +4,7 @@
44 import java.io.OutputStream;
55 import java.io.PrintStream;
66
7-import exewrap.core.ExewrapClassLoader;
7+import exewrap.core.NativeMethods;
88
99 public class ConsoleOutputStream extends OutputStream {
1010 static {
@@ -13,13 +13,13 @@
1313
1414 @Override
1515 public void write(int b) throws IOException {
16- ExewrapClassLoader.WriteConsole(new byte[] { (byte)(b & 0xFF) }, 0, 1);
16+ NativeMethods.WriteConsole(new byte[] { (byte)(b & 0xFF) }, 0, 1);
1717 }
1818
1919 @Override
2020 public void write(byte[] b) throws IOException {
2121 if(b != null) {
22- ExewrapClassLoader.WriteConsole(b, 0, b.length);
22+ NativeMethods.WriteConsole(b, 0, b.length);
2323 }
2424 }
2525
@@ -26,7 +26,7 @@
2626 @Override
2727 public void write(byte[] b, int off, int len) throws IOException {
2828 if(b != null) {
29- ExewrapClassLoader.WriteConsole(b, off, len);
29+ NativeMethods.WriteConsole(b, off, len);
3030 }
3131 }
3232 }
--- exewrap/trunk/exewrap/src/java/exewrap/util/EventLogStream.java (revision 39)
+++ exewrap/trunk/exewrap/src/java/exewrap/util/EventLogStream.java (revision 40)
@@ -6,7 +6,7 @@
66 import java.io.PrintWriter;
77 import java.io.StringWriter;
88
9-import exewrap.core.ExewrapClassLoader;
9+import exewrap.core.NativeMethods;
1010
1111 public class EventLogStream extends PrintStream {
1212 public static final int INFORMATION = 0;
@@ -32,7 +32,7 @@
3232 }
3333
3434 public void flush() {
35- ExewrapClassLoader.WriteEventLog(type, new String(buffer.toByteArray()));
35+ NativeMethods.WriteEventLog(type, new String(buffer.toByteArray()));
3636 buffer.reset();
3737 }
3838
--- exewrap/trunk/exewrap/src/java/exewrap/util/EventLogHandler.java (revision 39)
+++ exewrap/trunk/exewrap/src/java/exewrap/util/EventLogHandler.java (revision 40)
@@ -5,7 +5,7 @@
55 import java.util.logging.LogRecord;
66 import java.util.logging.Logger;
77
8-import exewrap.core.ExewrapClassLoader;
8+import exewrap.core.NativeMethods;
99
1010 public class EventLogHandler extends Handler {
1111 public static final int INFORMATION = 0;
@@ -22,11 +22,11 @@
2222 int level = record.getLevel().intValue();
2323
2424 if(level >= Level.SEVERE.intValue()) {
25- ExewrapClassLoader.WriteEventLog(ERROR, record.getMessage() + "");
25+ NativeMethods.WriteEventLog(ERROR, record.getMessage() + "");
2626 } else if(level >= Level.WARNING.intValue()) {
27- ExewrapClassLoader.WriteEventLog(WARNING, record.getMessage() + "");
27+ NativeMethods.WriteEventLog(WARNING, record.getMessage() + "");
2828 } else if(level >= Level.INFO.intValue()) {
29- ExewrapClassLoader.WriteEventLog(INFORMATION, record.getMessage() + "");
29+ NativeMethods.WriteEventLog(INFORMATION, record.getMessage() + "");
3030 }
3131 }
3232
--- exewrap/trunk/exewrap/src/java/exewrap/core/ExewrapClassLoader.java (revision 39)
+++ exewrap/trunk/exewrap/src/java/exewrap/core/ExewrapClassLoader.java (revision 40)
@@ -1,207 +0,0 @@
1-package exewrap.core;
2-
3-import java.io.ByteArrayOutputStream;
4-import java.io.IOException;
5-import java.lang.reflect.Field;
6-import java.net.MalformedURLException;
7-import java.net.URL;
8-import java.security.CodeSource;
9-import java.security.PermissionCollection;
10-import java.security.Policy;
11-import java.security.ProtectionDomain;
12-import java.security.cert.Certificate;
13-import java.util.HashMap;
14-import java.util.LinkedList;
15-import java.util.Map;
16-import java.util.Queue;
17-import java.util.jar.Attributes.Name;
18-import java.util.jar.JarEntry;
19-import java.util.jar.JarInputStream;
20-import java.util.jar.Manifest;
21-
22-public class ExewrapClassLoader extends ClassLoader {
23-
24- private static Map<String, byte[]> classes = new HashMap<String, byte[]>();
25- private static Map<String, byte[]> resources = new HashMap<String, byte[]>();
26- private static Queue<JarInputStream> inputs = new LinkedList<JarInputStream>();
27- private static JarInputStream in;
28- private static String mainClassName;
29- private static String specTitle;
30- private static String specVersion;
31- private static String specVendor;
32- private static String implTitle;
33- private static String implVersion;
34- private static String implVendor;
35- private static URL context;
36- private static ProtectionDomain protectionDomain;
37-
38- public static void setInputs(JarInputStream[] jars) throws MalformedURLException {
39- for(JarInputStream jar : jars) {
40- if(jar == null) {
41- continue;
42- }
43- Manifest manifest = jar.getManifest();
44- if(manifest != null) {
45- mainClassName = manifest.getMainAttributes().getValue(Name.MAIN_CLASS);
46- specTitle = manifest.getMainAttributes().getValue(Name.SPECIFICATION_TITLE);
47- specVersion = manifest.getMainAttributes().getValue(Name.SPECIFICATION_VERSION);
48- specVendor = manifest.getMainAttributes().getValue(Name.SPECIFICATION_VENDOR);
49- implTitle = manifest.getMainAttributes().getValue(Name.IMPLEMENTATION_TITLE);
50- implVersion = manifest.getMainAttributes().getValue(Name.IMPLEMENTATION_VERSION);
51- implVendor = manifest.getMainAttributes().getValue(Name.IMPLEMENTATION_VENDOR);
52- }
53- inputs.offer(jar);
54- }
55- in = inputs.poll();
56-
57- String path = System.getProperty("java.application.path");
58- if(path == null) {
59- path = "";
60- }
61- String name = System.getProperty("java.application.name");
62- if(name == null) {
63- name = "";
64- }
65-
66- ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
67- URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory(systemClassLoader));
68- context = new URL("exewrap:file:/" + path.replace('\\', '/') + '/' + name + "!/");
69-
70- URL url = new URL("file:/" + path.replace('\\', '/') + '/' + name);
71- CodeSource codesource = new CodeSource(url, (Certificate[])null);
72- PermissionCollection permissions = Policy.getPolicy().getPermissions(new CodeSource(null, (Certificate[])null));
73- protectionDomain = new ProtectionDomain(codesource, permissions, systemClassLoader, null);
74- }
75-
76- public static void loadUtilities(String utilities) throws ClassNotFoundException {
77- if(utilities == null) {
78- return;
79- }
80- if(utilities.contains("UncaughtExceptionHandler;")) {
81- Class.forName("exewrap.util.UncaughtExceptionHandler");
82- }
83- if(utilities.contains("FileLogStream;")) {
84- Class.forName("exewrap.util.FileLogStream");
85- }
86- if(utilities.contains("EventLogStream;")) {
87- Class.forName("exewrap.util.EventLogStream");
88- }
89- if(utilities.contains("EventLogHandler;")) {
90- Class.forName("exewrap.util.EventLogHandler");
91- }
92- if(utilities.contains("ConsoleOutputStream;")) {
93- Class.forName("exewrap.util.ConsoleOutputStream");
94- }
95- }
96-
97- public static Class<?> getMainClass(String mainClassName) throws ClassNotFoundException {
98- ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
99-
100- if(mainClassName != null) {
101- return Class.forName(mainClassName, true, systemClassLoader);
102- }
103- if(ExewrapClassLoader.mainClassName != null) {
104- return Class.forName(ExewrapClassLoader.mainClassName, true, systemClassLoader);
105- }
106- return null;
107- }
108-
109- public static void setSplashScreenResource(String name, byte[] image) {
110- resources.put(name, image);
111- }
112-
113- public static native void WriteConsole(byte[] b, int off, int len);
114- public static native void WriteEventLog(int type, String message);
115- public static native void UncaughtException(String thread, String message, String trace);
116- public static native String SetEnvironment(String key, String value);
117-
118-
119- public ExewrapClassLoader(ClassLoader parent) {
120- super(parent);
121- }
122-
123- protected Class<?> findClass(String name) throws ClassNotFoundException {
124- String entryName = name.replace('.', '/') + ".class";
125- byte[] bytes = this.classes.remove(entryName);
126- if(bytes == null) {
127- try {
128- bytes = find(entryName);
129- } catch(IOException ex) {
130- throw new ClassNotFoundException(name, ex);
131- }
132- }
133- if(bytes == null) {
134- throw new ClassNotFoundException(name);
135- }
136-
137- if(name.indexOf('.') >= 0) {
138- String packageName = name.substring(0, name.lastIndexOf('.'));
139- if(getPackage(packageName) == null) {
140- definePackage(packageName,
141- specTitle, specVersion, specVendor,
142- implTitle, implVersion, implVendor,
143- null);
144- }
145- }
146- return defineClass(name, bytes, 0, bytes.length, protectionDomain);
147- }
148-
149- protected URL findResource(String name) {
150- byte[] bytes = this.resources.get(name);
151- if(bytes == null) {
152- try {
153- bytes = find(name);
154- } catch (IOException ex) {
155- throw new RuntimeException(ex);
156- }
157- }
158- if(bytes == null) {
159- return null;
160- }
161-
162- try {
163- return new URL(this.context, name, new URLStreamHandler(bytes));
164- } catch (MalformedURLException e) {
165- e.printStackTrace();
166- return null;
167- }
168- }
169-
170- private byte[] find(String name) throws IOException {
171- while(this.in != null) {
172- JarEntry jarEntry;
173- while((jarEntry = this.in.getNextJarEntry()) != null) {
174- byte[] bytes = readJarEntryBytes(in);
175- this.resources.put(jarEntry.getName(), bytes);
176- if(jarEntry.getName().endsWith(".class")) {
177- if(jarEntry.getName().equals(name)) {
178- return bytes;
179- } else {
180- this.classes.put(jarEntry.getName(), bytes);
181- }
182- } else {
183- if(jarEntry.getName().equals(name)) {
184- return bytes;
185- }
186- }
187- in.closeEntry();
188- }
189- this.in.close();
190- this.in = this.inputs.poll();
191- }
192- return null;
193- }
194-
195- private byte[] readJarEntryBytes(JarInputStream in) throws IOException {
196- ByteArrayOutputStream buf = new ByteArrayOutputStream();
197- byte[] bytes = new byte[65536];
198- int len = 0;
199- while(len != -1) {
200- len = in.read(bytes);
201- if(len > 0) {
202- buf.write(bytes, 0, len);
203- }
204- }
205- return buf.toByteArray();
206- }
207-}
--- exewrap/trunk/exewrap/src/java/exewrap/core/URLStreamHandlerFactory.java (revision 39)
+++ exewrap/trunk/exewrap/src/java/exewrap/core/URLStreamHandlerFactory.java (revision 40)
@@ -1,13 +1,14 @@
11 package exewrap.core;
22
33 import java.net.URLStreamHandler;
4+import java.util.Map;
45
56 public class URLStreamHandlerFactory implements java.net.URLStreamHandlerFactory {
67
78 private URLStreamHandler handler;
89
9- public URLStreamHandlerFactory(ClassLoader loader) {
10- this.handler = new exewrap.core.URLStreamHandler(loader);
10+ public URLStreamHandlerFactory(ClassLoader loader, Map<String, byte[]> resources) {
11+ this.handler = new exewrap.core.URLStreamHandler(loader, resources);
1112 }
1213
1314 @Override
--- exewrap/trunk/exewrap/src/java/exewrap/core/NativeMethods.java (revision 0)
+++ exewrap/trunk/exewrap/src/java/exewrap/core/NativeMethods.java (revision 40)
@@ -0,0 +1,8 @@
1+package exewrap.core;
2+
3+public class NativeMethods {
4+ public static native void WriteConsole(byte[] b, int off, int len);
5+ public static native void WriteEventLog(int type, String message);
6+ public static native void UncaughtException(String thread, String message, String trace);
7+ public static native String SetEnvironment(String key, String value);
8+}
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- exewrap/trunk/exewrap/src/java/exewrap/core/URLStreamHandler.java (revision 39)
+++ exewrap/trunk/exewrap/src/java/exewrap/core/URLStreamHandler.java (revision 40)
@@ -2,31 +2,27 @@
22
33 import java.io.IOException;
44 import java.net.URL;
5+import java.util.Map;
56
67 public class URLStreamHandler extends java.net.URLStreamHandler {
78
8- private byte[] buf;
99 private ClassLoader loader;
10+ private Map<String, byte[]> resources;
1011
11- public URLStreamHandler(byte[] buf) {
12- this.buf = buf;
13- }
14-
15- public URLStreamHandler(ClassLoader loader) {
12+ public URLStreamHandler(ClassLoader loader, Map<String, byte[]> resources) {
1613 this.loader = loader;
14+ this.resources = resources;
1715 }
1816
1917 protected java.net.URLConnection openConnection(URL url) throws IOException {
20- if(this.buf != null) {
21- return new URLConnection(url, this.buf);
22- } else if(this.loader != null) {
18+ if(this.loader != null) {
2319 String s = url.toExternalForm();
2420 int i = s.toLowerCase().indexOf(".exe!/");
2521 if(i >= 0) {
2622 String name = s.substring(i + 6);
27- URL resource = loader.getResource(name);
28- if(resource != null) {
29- return resource.openConnection();
23+ byte[] bytes = resources.get(name);
24+ if(bytes != null) {
25+ return new URLConnection(url, bytes);
3026 }
3127 }
3228 }
--- exewrap/trunk/exewrap/src/Make.bat (revision 39)
+++ exewrap/trunk/exewrap/src/Make.bat (revision 40)
@@ -35,36 +35,6 @@
3535 IF ERRORLEVEL 1 GOTO ERR
3636
3737
38-REM SKIP TRACE VERSION
39-goto SUCCESS
40-
41-REM TRACE IMAGE ######################################################
42-
43-CALL :SETENV_X86
44-nmake /nologo TRACE_IMAGE_X86
45-IF ERRORLEVEL 1 GOTO ERR
46-
47-CALL :SETENV_X64
48-nmake /nologo TRACE_IMAGE_X64
49-IF ERRORLEVEL 1 GOTO ERR
50-
51-REM TRACE EXEWRAP ####################################################
52-
53-CALL :SETENV_X86
54-nmake /nologo TRACE_EXEWRAP_X86
55-IF ERRORLEVEL 1 GOTO ERR
56-
57-nmake /nologo JREMIN_X86
58-IF ERRORLEVEL 1 GOTO ERR
59-
60-CALL :SETENV_X64
61-nmake /nologo TRACE_EXEWRAP_X64
62-IF ERRORLEVEL 1 GOTO ERR
63-
64-nmake /nologo JREMIN_X64
65-IF ERRORLEVEL 1 GOTO ERR
66-
67-
6838 REM ##################################################################
6939
7040 :SUCCESS
--- exewrap/trunk/exewrap/src/image_service.c (revision 39)
+++ exewrap/trunk/exewrap/src/image_service.c (revision 40)
@@ -71,10 +71,6 @@
7171 int i;
7272
7373 utilities[0] = '\0';
74- #ifdef TRACE
75- StartTrace(TRUE);
76- strcat(utilities, UTIL_CONSOLE_OUTPUT_STREAM);
77- #endif
7874
7975 service_name = get_service_name(NULL);
8076 is_service = (flags & SERVICE_START_BY_SCM);
@@ -94,7 +90,7 @@
9490 if(vm_args_opt == NULL) {
9591 vm_args_opt = (char*)GetResource("VMARGS", NULL);
9692 }
97- CreateJavaVM(vm_args_opt, "exewrap.core.ExewrapClassLoader", use_server_vm, use_side_by_side_jre, &err);
93+ CreateJavaVM(vm_args_opt, "Loader", use_server_vm, use_side_by_side_jre, &err);
9894 if (err != JNI_OK)
9995 {
10096 OutputMessage(GetWinErrorMessage(err, &result.msg_id, result.msg));
@@ -232,10 +228,6 @@
232228 }
233229 }
234230
235- #ifdef TRACE
236- StopTrace();
237- #endif
238-
239231 return result.msg_id;
240232 }
241233
--- exewrap/trunk/exewrap/src/include/trace.h (revision 39)
+++ exewrap/trunk/exewrap/src/include/trace.h (revision 40)
@@ -1,17 +0,0 @@
1-#ifndef _TRACE_H_
2-#define _TRACE_H_
3-
4-#include <Windows.h>
5-
6-#ifdef __cplusplus
7-extern "C" {
8-#endif
9-
10- extern const char* StartTrace(BOOL replace_stdout);
11- extern void StopTrace();
12-
13-#ifdef __cplusplus
14-}
15-#endif
16-
17-#endif
--- exewrap/trunk/exewrap/src/include/message.h (revision 39)
+++ exewrap/trunk/exewrap/src/include/message.h (revision 40)
@@ -7,7 +7,7 @@
77 #define MSG_LANG_ID_EN 0
88 #define MSG_LANG_ID_JA 1
99
10-#define MSG_ID_COUNT 32
10+#define MSG_ID_COUNT 35
1111 #define MSG_ID_ERR_CREATE_JVM_UNKNOWN 1
1212 #define MSG_ID_ERR_CREATE_JVM_EDETACHED 2
1313 #define MSG_ID_ERR_CREATE_JVM_EVERSION 3
@@ -18,28 +18,31 @@
1818 #define MSG_ID_ERR_UNCAUGHT_EXCEPTION 8
1919 #define MSG_ID_ERR_RESOURCE_NOT_FOUND 9
2020 #define MSG_ID_ERR_TARGET_VERSION 10
21-#define MSG_ID_ERR_FIND_CLASS 11
22-#define MSG_ID_ERR_GET_METHOD 12
23-#define MSG_ID_ERR_GET_CONSTRUCTOR 13
24-#define MSG_ID_ERR_NEW_OBJECT 14
25-#define MSG_ID_ERR_FIND_CLASSLOADER 15
26-#define MSG_ID_ERR_REGISTER_NATIVE 16
27-#define MSG_ID_ERR_LOAD_MAIN_CLASS 17
28-#define MSG_ID_ERR_FIND_MAIN_CLASS 18
29-#define MSG_ID_ERR_FIND_MAIN_METHOD 19
30-#define MSG_ID_ERR_FIND_METHOD_SERVICE_START 20
31-#define MSG_ID_ERR_FIND_METHOD_SERVICE_STOP 21
32-#define MSG_ID_ERR_SERVICE_ABORT 22
33-#define MSG_ID_ERR_SERVICE_NOT_STOPPED 23
34-#define MSG_ID_SUCCESS_SERVICE_INSTALL 24
35-#define MSG_ID_SUCCESS_SERVICE_REMOVE 25
36-#define MSG_ID_SERVICE_STARTING 26
37-#define MSG_ID_SERVICE_STOPING 27
38-#define MSG_ID_SUCCESS_SERVICE_START 28
39-#define MSG_ID_SUCCESS_SERVICE_STOP 29
40-#define MSG_ID_CTRL_SERVICE_STOP 30
41-#define MSG_ID_CTRL_SERVICE_TERMINATE 31
42-#define MSG_ID_CTRL_BREAK 32
21+#define MSG_ID_ERR_DEFINE_CLASS 11
22+#define MSG_ID_ERR_FIND_CLASS 12
23+#define MSG_ID_ERR_GET_FIELD 13
24+#define MSG_ID_ERR_GET_METHOD 14
25+#define MSG_ID_ERR_GET_CONSTRUCTOR 15
26+#define MSG_ID_ERR_NEW_OBJECT 16
27+#define MSG_ID_ERR_NULL_OBJECT 17
28+#define MSG_ID_ERR_FIND_CLASSLOADER 18
29+#define MSG_ID_ERR_REGISTER_NATIVE 19
30+#define MSG_ID_ERR_LOAD_MAIN_CLASS 20
31+#define MSG_ID_ERR_FIND_MAIN_CLASS 21
32+#define MSG_ID_ERR_FIND_MAIN_METHOD 22
33+#define MSG_ID_ERR_FIND_METHOD_SERVICE_START 23
34+#define MSG_ID_ERR_FIND_METHOD_SERVICE_STOP 24
35+#define MSG_ID_ERR_SERVICE_ABORT 25
36+#define MSG_ID_ERR_SERVICE_NOT_STOPPED 26
37+#define MSG_ID_SUCCESS_SERVICE_INSTALL 27
38+#define MSG_ID_SUCCESS_SERVICE_REMOVE 28
39+#define MSG_ID_SERVICE_STARTING 29
40+#define MSG_ID_SERVICE_STOPING 30
41+#define MSG_ID_SUCCESS_SERVICE_START 31
42+#define MSG_ID_SUCCESS_SERVICE_STOP 32
43+#define MSG_ID_CTRL_SERVICE_STOP 33
44+#define MSG_ID_CTRL_SERVICE_TERMINATE 34
45+#define MSG_ID_CTRL_BREAK 35
4346
4447 extern const char* get_message(int msg_id);
4548
Show on old repository browser