• R/O
  • SSH
  • HTTPS

exewrap: Commit


Commit MetaInfo

Revision88 (tree)
Time2020-05-18 21:53:06
Authorhirukawa_ryo

Log Message

* exewrap 1.6.0
サービスアプリケーションのメインクラスにmainメソッドを定義していなくても動作するようにしました。
サービスアプリケーションではstartメソッドとstopメソッドがエントリーポイントとなるためmainメソッドは必要ありませんが従来はmainメソッドが検出できないとエラーになっていました。

Change Summary

Incremental Difference

--- exewrap/trunk/exewrap/samples/service-1/ServiceSample1.java (revision 87)
+++ exewrap/trunk/exewrap/samples/service-1/ServiceSample1.java (revision 88)
@@ -14,31 +14,23 @@
1414
1515 public class ServiceSample1 {
1616
17- public static void main(String[] args) throws IOException {
18- start(args);
19- }
20-
2117 private static AtomicBoolean isStopRequested = new AtomicBoolean(false);
2218 private static ServerSocket serverSocket;
2319
2420 public static void start(String[] args) throws IOException {
25- SERVER: for(;;) {
26- serverSocket = new ServerSocket(80, 50, InetAddress.getLoopbackAddress());
27- for(;;) {
28- Socket socket;
29- try {
30- socket = serverSocket.accept();
31- } catch(SocketException e) {
32- if(isStopRequested.get()) {
33- break SERVER;
34- }
35- throw e;
21+ serverSocket = new ServerSocket(80, 50, InetAddress.getLoopbackAddress());
22+ for(;;) {
23+ Socket socket;
24+ try {
25+ socket = serverSocket.accept();
26+ } catch(SocketException e) {
27+ if(isStopRequested.get()) {
28+ return;
3629 }
37- new Worker(socket).start();
30+ throw e;
3831 }
32+ new Worker(socket).start();
3933 }
40- serverSocket = null;
41- isStopRequested.set(false);
4234 }
4335
4436 public static void stop() throws IOException {
--- exewrap/trunk/exewrap/src/image_service.c (revision 87)
+++ exewrap/trunk/exewrap/src/image_service.c (revision 88)
@@ -210,6 +210,7 @@
210210 goto EXIT;
211211 }
212212 utilities[0] = L'\0';
213+ wcscat_s(utilities, BUFFER_SIZE, UTIL_NO_MAIN);
213214
214215 result.msg_id = NO_ERROR;
215216 result.msg = (wchar_t*)malloc(BUFFER_SIZE * sizeof(wchar_t));
--- exewrap/trunk/exewrap/src/include/loader.h (revision 87)
+++ exewrap/trunk/exewrap/src/include/loader.h (revision 88)
@@ -6,6 +6,7 @@
66 #include <Windows.h>
77 #include <jni.h>
88
9+#define UTIL_NO_MAIN L"NO-MAIN;"
910 #define UTIL_ENCODING_FIX L"ENCODING-FIX;"
1011 #define UTIL_UNCAUGHT_EXCEPTION_HANDLER L"UncaughtExceptionHandler;"
1112 #define UTIL_FILE_LOG_STREAM L"FileLogStream;"
--- exewrap/trunk/exewrap/src/loader.c (revision 87)
+++ exewrap/trunk/exewrap/src/loader.c (revision 88)
@@ -411,20 +411,24 @@
411411 swprintf_s(result->msg, LOAD_RESULT_MAX_MESSAGE_LENGTH, _(MSG_ID_ERR_LOAD_MAIN_CLASS), main_class);
412412 goto EXIT;
413413 }
414- MainClass_main = (*env)->GetStaticMethodID(env, MainClass, "main", "([Ljava/lang/String;)V");
415- if(MainClass_main == NULL)
414+
415+ if(utilities == NULL || wcsstr(utilities, UTIL_NO_MAIN) == NULL) // NO-MAIN; が指定されている場合はmainメソッドを探しません。NO-MAIN; はサービスアプリケーションで指定されます。
416416 {
417- result->msg_id = MSG_ID_ERR_FIND_MAIN_METHOD;
418- wcscpy_s(result->msg, LOAD_RESULT_MAX_MESSAGE_LENGTH, _(MSG_ID_ERR_FIND_MAIN_METHOD));
419- goto EXIT;
420- }
421- result->MainClass_main_args = (*env)->NewObjectArray(env, argc - 1, (*env)->FindClass(env, "java/lang/String"), NULL);
422- {
423- int i;
424- for (i = 1; i < argc; i++)
417+ MainClass_main = (*env)->GetStaticMethodID(env, MainClass, "main", "([Ljava/lang/String;)V");
418+ if(MainClass_main == NULL)
425419 {
426- (*env)->SetObjectArrayElement(env, result->MainClass_main_args, (i - 1), to_jstring(env, argv[i]));
420+ result->msg_id = MSG_ID_ERR_FIND_MAIN_METHOD;
421+ wcscpy_s(result->msg, LOAD_RESULT_MAX_MESSAGE_LENGTH, _(MSG_ID_ERR_FIND_MAIN_METHOD));
422+ goto EXIT;
427423 }
424+ result->MainClass_main_args = (*env)->NewObjectArray(env, argc - 1, (*env)->FindClass(env, "java/lang/String"), NULL);
425+ {
426+ int i;
427+ for (i = 1; i < argc; i++)
428+ {
429+ (*env)->SetObjectArrayElement(env, result->MainClass_main_args, (i - 1), to_jstring(env, argv[i]));
430+ }
431+ }
428432 }
429433 result->MainClass = MainClass;
430434 result->MainClass_main = MainClass_main;
Show on old repository browser