View | Details | Raw Unified | Return to issue 92926
Collapse All | Expand All

(-)jvmfwk/plugins/sunmajor/pluginlib/makefile.mk (-1 / +4 lines)
Lines 82-88 Link Here
82
.ELSE
82
.ELSE
83
SHL1STDLIBS += -luwinapi -ladvapi32 
83
SHL1STDLIBS += -luwinapi -ladvapi32 
84
.ENDIF # GCC
84
.ENDIF # GCC
85
.ENDIF #WNT
85
.ELIF "$(OS)" == "MACOSX" #WNT
86
# add -framework JavaVM
87
SHL1LINKFLAGS+=$(JAVA_RUNTIME)
88
.ENDIF
86
89
87
SHL1VERSIONMAP = sunjavaplugin.map
90
SHL1VERSIONMAP = sunjavaplugin.map
88
SHL1DEPN=
91
SHL1DEPN=
(-)jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx (-2 / +81 lines)
Lines 69-74 Link Here
69
69
70
struct PluginMutex: public ::rtl::Static<osl::Mutex, PluginMutex> {}; 
70
struct PluginMutex: public ::rtl::Static<osl::Mutex, PluginMutex> {}; 
71
71
72
#ifdef MACOSX
73
struct mac_start_params {
74
    JavaVM** vmPP;
75
    JNIEnv** envPP;
76
    JavaVMInitArgs* vmargsP;
77
    jint* retP;
78
};
79
80
pthread_mutex_t java_mutex;
81
pthread_cond_t java_cond;
82
#endif
83
72
#if defined UNX
84
#if defined UNX
73
OString getPluginJarPath(
85
OString getPluginJarPath(
74
    const OUString & sVendor,
86
    const OUString & sVendor,
Lines 432-437 Link Here
432
    return errcode;
444
    return errcode;
433
}
445
}
434
446
447
#ifdef MACOSX
448
static void* startupJava(void *options) {    
449
    mac_start_params* dataP = (mac_start_params*) options;
450
    int result = 1;
451
452
    JFW_TRACE2(OUSTR("startupJava - trying to start the VM.\n"));
453
    pthread_mutex_lock(&java_mutex);
454
    result = JNI_CreateJavaVM(dataP->vmPP, (void**) dataP->envPP, dataP->vmargsP);
455
    *dataP->retP = result;
456
    if ( result != 0 ) {
457
        fprintf(stderr, "[Java framework] startupJava: failed to start VM - result: %i \n",result);
458
    }
459
    /* signal we're done - whether successful or not */
460
    pthread_cond_signal(&java_cond);
461
    pthread_mutex_unlock(&java_mutex);
462
    return NULL;
463
}
464
#endif
465
435
/** starts a Java Virtual Machine.
466
/** starts a Java Virtual Machine.
436
    <p>
467
    <p>
437
    The function shall ensure, that the VM does not abort the process
468
    The function shall ensure, that the VM does not abort the process
Lines 491-496 Link Here
491
    putenv(strdup(osJavaHome.getStr()));
522
    putenv(strdup(osJavaHome.getStr()));
492
#endif
523
#endif
493
524
525
// Mac links against Java.Framework - one JVM-Launcher for all installed java version
526
#ifndef MACOSX
494
    typedef jint JNICALL JNI_InitArgs_Type(void *);
527
    typedef jint JNICALL JNI_InitArgs_Type(void *);
495
    typedef jint JNICALL JNI_CreateVM_Type(JavaVM **, JNIEnv **, void *);
528
    typedef jint JNICALL JNI_CreateVM_Type(JavaVM **, JNIEnv **, void *);
496
    rtl::OUString sSymbolCreateJava(
529
    rtl::OUString sSymbolCreateJava(
Lines 510-515 Link Here
510
                sLib.getStr(), sSymbol.getStr());
543
                sLib.getStr(), sSymbol.getStr());
511
        return JFW_PLUGIN_E_VM_CREATION_FAILED;
544
        return JFW_PLUGIN_E_VM_CREATION_FAILED;
512
    }
545
    }
546
#endif
513
547
514
    // The office sets a signal handler at startup. That causes a crash
548
    // The office sets a signal handler at startup. That causes a crash
515
    // with java 1.3 under Solaris. To make it work, we set back the
549
    // with java 1.3 under Solaris. To make it work, we set back the
Lines 581-593 Link Here
581
    vm_args.nOptions= cOptions + 1;
615
    vm_args.nOptions= cOptions + 1;
582
    vm_args.ignoreUnrecognized= JNI_TRUE;
616
    vm_args.ignoreUnrecognized= JNI_TRUE;
583
617
618
    jint err;
619
#ifdef MACOSX
620
    /* Need to start the JVM in a sperate thread, otherwise AWT/Swing UI won't work */
621
    pthread_t vmthread;
622
    pthread_mutex_init(&java_mutex, NULL);
623
    pthread_cond_init(&java_cond, NULL);
624
625
    /* create a new pthread copying the stack size of the primordial pthread */ 
626
    struct rlimit limit;
627
    size_t stack_size = 0;
628
    int rc = getrlimit(RLIMIT_STACK, &limit);
629
    if (rc == 0) {
630
        if (limit.rlim_cur != 0LL) {
631
            stack_size = (size_t)limit.rlim_cur;
632
        }
633
    }
634
635
    jint* pRet = &err;
636
    mac_start_params launchOptions = {ppVm,ppEnv,&vm_args,pRet}; 
637
638
    pthread_attr_t thread_attr;
639
    pthread_attr_init(&thread_attr);
640
    pthread_attr_setscope(&thread_attr, PTHREAD_SCOPE_SYSTEM);
641
    pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED);
642
    if (stack_size > 0) {
643
        pthread_attr_setstacksize(&thread_attr, stack_size);
644
    }
645
646
    /* Start the thread that we will start the JVM on, wait until the start-routine is done */
647
    pthread_mutex_lock(&java_mutex);
648
    pthread_create(&vmthread, &thread_attr, startupJava, &launchOptions);
649
    pthread_attr_destroy(&thread_attr);
650
    pthread_cond_wait(&java_cond, &java_mutex);
651
652
    jint attachres = (*ppVm)->AttachCurrentThread((void**)ppEnv,NULL);
653
    if (attachres != 0) {
654
        fprintf(stderr, "[Java Framework] failed to attach current thread - errorcode: %i\n", (int)attachres);
655
        err=attachres;
656
    }
657
    pthread_mutex_unlock(&java_mutex);
658
    pthread_mutex_destroy(&java_mutex);
659
    pthread_cond_destroy(&java_cond);
660
#else
584
    /* We set a global flag which is used by the abort handler in order to
661
    /* We set a global flag which is used by the abort handler in order to
585
       determine whether it is  should use longjmp to get back into this function.
662
       determine whether it is  should use longjmp to get back into this function.
586
       That is, the abort handler determines if it is on the same stack as this function
663
       That is, the abort handler determines if it is on the same stack as this function
587
       and then jumps back into this function.
664
       and then jumps back into this function.
588
    */
665
    */
589
    g_bInGetJavaVM = 1;
666
    g_bInGetJavaVM = 1;
590
    jint err;
591
    JavaVM * pJavaVM = 0;
667
    JavaVM * pJavaVM = 0;
592
    memset( jmp_jvm_abort, 0, sizeof(jmp_jvm_abort));
668
    memset( jmp_jvm_abort, 0, sizeof(jmp_jvm_abort));
593
    int jmpval= setjmp( jmp_jvm_abort );
669
    int jmpval= setjmp( jmp_jvm_abort );
Lines 604-610 Link Here
604
        // set err to a positive number, so as or recognize that an abort (longjmp)
680
        // set err to a positive number, so as or recognize that an abort (longjmp)
605
        //occurred
681
        //occurred
606
        err= 1;
682
        err= 1;
607
    
683
#endif
684
608
    if(err != 0)
685
    if(err != 0)
609
    {
686
    {
610
        rtl::OUString message;
687
        rtl::OUString message;
Lines 623-629 Link Here
623
    }
700
    }
624
    else
701
    else
625
    {
702
    {
703
#ifndef MACOSX
626
        *ppVm = pJavaVM;
704
        *ppVm = pJavaVM;
705
#endif
627
        JFW_TRACE2("[Java framework] sunjavaplugin"SAL_DLLEXTENSION " has created a VM.\n");
706
        JFW_TRACE2("[Java framework] sunjavaplugin"SAL_DLLEXTENSION " has created a VM.\n");
628
    }
707
    }
629
        
708
        
(-)stoc/source/javavm/javavm.cxx (+2 lines)
Lines 950-956 Link Here
950
        if (bStarted)
950
        if (bStarted)
951
        {
951
        {
952
            {
952
            {
953
#ifndef MACOSX // Mac creates the JVM in a seperate thread already
953
                DetachCurrentThread detach(m_pJavaVm);
954
                DetachCurrentThread detach(m_pJavaVm);
955
#endif
954
                    // necessary to make debugging work; this thread will be
956
                    // necessary to make debugging work; this thread will be
955
                    // suspended when the destructor of detach returns
957
                    // suspended when the destructor of detach returns
956
                m_xVirtualMachine = new jvmaccess::VirtualMachine(
958
                m_xVirtualMachine = new jvmaccess::VirtualMachine(

Return to issue 92926