Commit 687a562dbc1507fd8d15567dc6fd47235f9e086c
1 parent
7d4f2b4e
Exists in
master
and in
5 other branches
Experimentando plugin java em windows
Showing
3 changed files
with
70 additions
and
22 deletions
Show diff stats
src/include/plugin.mak.in
... | ... | @@ -129,7 +129,8 @@ Debug: $(BINDBG)/$(PLUGIN_NAME) |
129 | 129 | |
130 | 130 | $(BINDBG)$(DLL_NAME): $(BINDBG)$(DLL_NAME).$(VERSION) |
131 | 131 | @rm -f $@ |
132 | - $(LN_S) @DLLPREFIX@$(MODULE_NAME)@DLLEXT@.$(VERSION) $@ | |
132 | + @rm -f $(BINRLS)@DLLDIR@/@DLLPREFIX@$(MODULE_NAME)@DLLEXT@ | |
133 | + @cd $(BINDBG)@DLLDIR@ && $(LN_S) @DLLPREFIX@$(MODULE_NAME)@DLLEXT@.$(VERSION) @DLLPREFIX@$(MODULE_NAME)@DLLEXT@ | |
133 | 134 | |
134 | 135 | $(BINRLS)$(DLL_NAME): $(BINRLS)$(DLL_NAME).$(VERSION) |
135 | 136 | @rm -f $@ | ... | ... |
src/java/plugin.cc
... | ... | @@ -358,34 +358,53 @@ extern "C" { |
358 | 358 | { "JDK_HOME", "jre\\bin\\client", 0 } |
359 | 359 | }; |
360 | 360 | |
361 | - kernel = LoadLibrary("kernel32.dll"); | |
362 | - AddDllDirectory = (HANDLE WINAPI (*)(PCWSTR)) GetProcAddress(kernel,"AddDllDirectory"); | |
363 | - RemoveDllDirectory = (BOOL WINAPI (*)(HANDLE)) GetProcAddress(kernel,"RemoveDllDirectory"); | |
361 | + kernel = LoadLibrary("kernel32.dll"); | |
362 | + | |
363 | + debug("---[ %s ]---------------------------------------------------",__FUNCTION__); | |
364 | + | |
365 | + AddDllDirectory = (HANDLE WINAPI (*)(PCWSTR)) GetProcAddress(kernel,"AddDllDirectory"); | |
366 | + if(AddDllDirectory) { | |
364 | 367 | |
365 | - // Acrescenta mais caminhos para achar a dll | |
366 | - for(size_t f = 0; f < G_N_ELEMENTS(dlldir); f++) { | |
368 | + // Acrescenta mais caminhos para achar a dll | |
369 | + for(size_t f = 0; f < G_N_ELEMENTS(dlldir); f++) { | |
367 | 370 | |
368 | - const char *env = getenv(dlldir[f].env); | |
369 | - if(env && AddDllDirectory) { | |
371 | + const char *env = getenv(dlldir[f].env); | |
370 | 372 | |
371 | - gchar *p = g_build_filename(env,dlldir[f].path,NULL); | |
373 | + debug("%s=\"%s\"",dlldir[f].env,env); | |
372 | 374 | |
373 | - debug("Adicionando diretório \"%s\"",p); | |
375 | + if(env) { | |
374 | 376 | |
375 | - wchar_t *path = (wchar_t *) malloc(4096*sizeof(wchar_t)); | |
376 | - mbstowcs(path, p, 4095); | |
377 | - dlldir[f].cookie = AddDllDirectory(path); | |
378 | - free(path); | |
377 | + gchar *p = g_build_filename(env,dlldir[f].path,NULL); | |
379 | 378 | |
380 | - g_free(p); | |
379 | + debug("Adicionando diretório \"%s\"",p); | |
381 | 380 | |
381 | + wchar_t *path = (wchar_t *) malloc(4096*sizeof(wchar_t)); | |
382 | + mbstowcs(path, p, 4095); | |
383 | + dlldir[f].cookie = AddDllDirectory(path); | |
384 | + free(path); | |
385 | + | |
386 | + g_free(p); | |
387 | + | |
388 | + } | |
382 | 389 | } |
390 | + | |
391 | + } | |
392 | +#ifdef DEBUG | |
393 | + else { | |
394 | + debug("Can't get %s: %s","AddDllDirectory",session::win32_strerror(GetLastError()).c_str()) | |
383 | 395 | } |
396 | +#endif // DEBUG | |
384 | 397 | |
385 | 398 | hModule = LoadLibrary("jvm.dll"); |
386 | 399 | |
400 | + debug("hModule=%08lx",(long) hModule); | |
401 | + | |
387 | 402 | if(!hModule) { |
388 | 403 | |
404 | + DWORD err = GetLastError(); | |
405 | + | |
406 | + debug("%s",session::win32_strerror(err).c_str()); | |
407 | + | |
389 | 408 | GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(gtk_widget_get_toplevel(widget)), |
390 | 409 | GTK_DIALOG_DESTROY_WITH_PARENT, |
391 | 410 | GTK_MESSAGE_ERROR, |
... | ... | @@ -393,7 +412,7 @@ extern "C" { |
393 | 412 | "%s", _( "Can't load java virtual machine" ) ); |
394 | 413 | |
395 | 414 | gtk_window_set_title(GTK_WINDOW(dialog),_( "JVM error" )); |
396 | - gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s", session::win32_strerror(GetLastError()).c_str()); | |
415 | + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s", session::win32_strerror(err).c_str()); | |
397 | 416 | |
398 | 417 | gtk_dialog_run(GTK_DIALOG (dialog)); |
399 | 418 | gtk_widget_destroy(dialog); |
... | ... | @@ -401,18 +420,27 @@ extern "C" { |
401 | 420 | } |
402 | 421 | |
403 | 422 | // Libera caminhos extras. |
404 | - for(size_t f = 0; f < G_N_ELEMENTS(dlldir); f++) { | |
423 | + RemoveDllDirectory = (BOOL WINAPI (*)(HANDLE)) GetProcAddress(kernel,"RemoveDllDirectory"); | |
424 | + if(RemoveDllDirectory) { | |
405 | 425 | |
406 | - if(dlldir[f].cookie && RemoveDllDirectory) { | |
426 | + for(size_t f = 0; f < G_N_ELEMENTS(dlldir); f++) { | |
407 | 427 | |
408 | - RemoveDllDirectory(dlldir[f].cookie); | |
428 | + if(dlldir[f].cookie) { | |
409 | 429 | |
430 | + RemoveDllDirectory(dlldir[f].cookie); | |
431 | + | |
432 | + } | |
410 | 433 | } |
434 | + | |
411 | 435 | } |
436 | +#ifdef DEBUG | |
437 | + else { | |
438 | + debug("Can't get %s: %s","RemoveDllDirectory",session::win32_strerror(GetLastError()).c_str()) | |
439 | + } | |
440 | +#endif // DEBUG | |
412 | 441 | |
413 | 442 | FreeLibrary(kernel); |
414 | 443 | |
415 | - | |
416 | 444 | } |
417 | 445 | |
418 | 446 | |
... | ... | @@ -473,6 +501,8 @@ extern "C" |
473 | 501 | |
474 | 502 | load_jvm(widget,hJVM); |
475 | 503 | |
504 | + debug("hJVM=%p",hJVM); | |
505 | + | |
476 | 506 | if(!hJVM) { |
477 | 507 | v3270_set_script(widget,'J',FALSE); |
478 | 508 | |
... | ... | @@ -488,6 +518,7 @@ extern "C" |
488 | 518 | |
489 | 519 | #endif // _WIN32 |
490 | 520 | |
521 | + debug("%s",__FUNCTION__); | |
491 | 522 | |
492 | 523 | // Start JNI |
493 | 524 | JavaVMInitArgs vm_args; |
... | ... | @@ -515,6 +546,8 @@ extern "C" |
515 | 546 | |
516 | 547 | gchar * dirname = g_path_get_dirname(filename); |
517 | 548 | |
549 | + debug("Dirname=%s",dirname); | |
550 | + | |
518 | 551 | #if defined( WIN32 ) |
519 | 552 | |
520 | 553 | gchar * exports = NULL; |
... | ... | @@ -523,7 +556,13 @@ extern "C" |
523 | 556 | |
524 | 557 | if(GetModuleFileName(NULL,buffer,sizeof(buffer)) < sizeof(buffer)) { |
525 | 558 | |
526 | - gchar * myDir = g_path_get_dirname(buffer); | |
559 | + gchar * ptr = strrchr(buffer,G_DIR_SEPARATOR); | |
560 | + if(ptr) { | |
561 | + *ptr = 0; | |
562 | + myDir = g_strdup(buffer); | |
563 | + } else { | |
564 | + myDir = g_strdup("."); | |
565 | + } | |
527 | 566 | |
528 | 567 | |
529 | 568 | } else { |
... | ... | @@ -532,6 +571,8 @@ extern "C" |
532 | 571 | |
533 | 572 | } |
534 | 573 | |
574 | + debug("myDir=%s",myDir); | |
575 | + | |
535 | 576 | exports = g_build_filename(myDir,"jvm-exports",NULL); |
536 | 577 | g_mkdir_with_parents(exports,0777); |
537 | 578 | |
... | ... | @@ -550,7 +591,9 @@ extern "C" |
550 | 591 | if(!CreateJavaVM) { |
551 | 592 | rc = ENOENT; |
552 | 593 | } else { |
594 | + debug("Calling %s","CreateJavaVM"); | |
553 | 595 | rc = CreateJavaVM(&jvm,(void **)&env,&vm_args); |
596 | + debug("%s exits with rc=%d","CreateJavaVM",rc); | |
554 | 597 | } |
555 | 598 | |
556 | 599 | #else |
... | ... | @@ -640,10 +683,13 @@ extern "C" |
640 | 683 | |
641 | 684 | try { |
642 | 685 | |
686 | + debug("%s: Calling CallStaticVoidMethod()",__FUNCTION__); | |
643 | 687 | env->CallStaticVoidMethod(cls, mid, args); |
688 | + debug("%s: CallStaticVoidMethod() has returned",__FUNCTION__); | |
644 | 689 | |
645 | 690 | } catch(std::exception &e) { |
646 | 691 | |
692 | + debug("Java error: %s",e.what()); | |
647 | 693 | trace("%s",e.what()); |
648 | 694 | } |
649 | 695 | |
... | ... | @@ -654,6 +700,7 @@ extern "C" |
654 | 700 | |
655 | 701 | g_free(classname); |
656 | 702 | |
703 | + exit(-1); | |
657 | 704 | |
658 | 705 | jvm->DestroyJavaVM(); |
659 | 706 | } | ... | ... |
src/plugins/hllapi/Makefile.in
... | ... | @@ -45,7 +45,7 @@ include $(CLASSLIBDIR)/class.mak |
45 | 45 | $(BINRLS)/$(PLUGIN_NAME): $(foreach SRC, $(basename $(PLUGIN_SRC)), $(OBJRLS)/$(SRC).o) $(BINRLS)$(DLL_NAME) |
46 | 46 | @echo " CCLD `basename $@`" |
47 | 47 | @$(MKDIR) `dirname $@` |
48 | - $(CXX) $(DLL_FLAGS) @LDSOFLAGS@ $(LDFLAGS) @RLS_LDFLAGS@ -o $@ $^ $(LIBS) $(LIB3270_LIBS) $(GTK_LIBS) $(GLIB_LIBS) $(PW3270_LIBS) | |
48 | + @$(CXX) $(DLL_FLAGS) @LDSOFLAGS@ $(LDFLAGS) @RLS_LDFLAGS@ -o $@ $^ $(LIBS) $(LIB3270_LIBS) $(GTK_LIBS) $(GLIB_LIBS) $(PW3270_LIBS) | |
49 | 49 | |
50 | 50 | $(BINRLS)$(DLL_NAME).$(VERSION): $(foreach SRC, $(basename $(EXTAPI_SRC)), $(OBJRLS)/$(SRC).o) $(CLASS_RELEASE_OBJECTS) |
51 | 51 | @echo " CCLD `basename $@`" | ... | ... |