Project

Profile

Help

Revision 0e42f323

Added by O'Neil Delpratt almost 6 years ago

Saxon/C updates

View differences:

latest9.6/hec/Saxon.C.API/HEC/SaxonCGlue.c
70 70
#endif
71 71

  
72 72
    if (!hDll) {
73
        printf ("Unable to load %s\n", name);
73
        fprintf (stderr, "Unable to load %s\n", name);
74 74
	perror("Error: ");
75 75
        exit(1);
76 76
    }
77 77
#ifdef DEBUG
78
    printf ("%s loaded\n", name);
78
    fprintf (stderr, "%s loaded\n", name);
79 79
#endif
80 80

  
81 81
    return hDll;
......
98 98
 */
99 99
void initJavaRT(HANDLE myDllHandle, JavaVM** pjvm, JNIEnv** penv)
100 100
{
101
    //perror ("initJavaRT - load Saxon/C library\n");
101
if(jvmCreated==0) {
102
     jvmCreated=1;
103
#ifdef DEBUG
104
    perror ("initJavaRT - load Saxon/C library\n");
105
#endif
102 106
    int result;
103 107
    JavaVMInitArgs args;
104 108
    JNI_GetDefaultJavaVMInitArgs_func =
......
108 112
#else
109 113
    GetProcAddress (myDllHandle, "JNI_GetDefaultJavaVMInitArgs");
110 114
#endif
115
 
111 116
    
112 117
    JNI_CreateJavaVM_func =
113 118
    (jint (JNICALL *) (JavaVM **pvm, void **penv, void *args))
......
118 123
    GetProcAddress (myDllHandle, "JNI_CreateJavaVM");
119 124
    
120 125
#endif
126

  
121 127
    
122 128
    if(!JNI_GetDefaultJavaVMInitArgs_func) {
123
        printf ("%s doesn't contain public JNI_GetDefaultJavaVMInitArgs\n", getDllname());
129
        fprintf (stderr,"%s doesn't contain public JNI_GetDefaultJavaVMInitArgs\n", getDllname());
124 130
        exit (1);
125 131
    }
126 132
    
127 133
    if(!JNI_CreateJavaVM_func) {
128
        printf ("%s doesn't contain public JNI_CreateJavaVM\n", getDllname());
134
        fprintf (stderr,"%s doesn't contain public JNI_CreateJavaVM\n", getDllname());
129 135
        exit (1);
130 136
    }
131 137
    
......
134 140
    args.version = JNI_VERSION_1_2;
135 141
    result = JNI_GetDefaultJavaVMInitArgs_func(&args);
136 142
    if (result != JNI_OK) {
137
        printf("JNI_GetDefaultJavaVMInitArgs() failed with result\n");
143
        fprintf(stderr,"JNI_GetDefaultJavaVMInitArgs() failed with result\n");
138 144
        exit(1);
139
    }  
145
    }
146
  
140 147
    /*
141 148
     * NOTE: no JVM is actually created
142 149
     * this call to JNI_CreateJavaVM is intended for JET RT initialization
143 150
     */
144 151
    result = JNI_CreateJavaVM_func (pjvm, (void **)penv, &args);
145 152
    if (result != JNI_OK) {
146
        printf("JNI_CreateJavaVM() failed with result\n");
153
        fprintf(stderr,"JNI_CreateJavaVM() failed with result: %i\n",result);
147 154
        exit(1);
148 155
    }
149 156

  
150
#ifdef DEBUG
151
    printf ("JET RT initialized\n");
152 157

  
153
#endif
154 158
    fflush (stdout);
159
  } else {
160
#ifdef DEBUG
161
    perror ("initJavaRT - Saxon/C library loaded already\n");
162
#endif
163
	}
155 164
}
156 165

  
157 166

  
......
363 372
void finalizeJavaRT (JavaVM* jvm)
364 373
{
365 374

  
366
  if(!jvm){
367
	  printf("\njvm is null\n");	
375
  if(jvmCreated!= 0){
376
    (*jvm)->DestroyJavaVM (jvm);
377
    jvmCreated=0;	
368 378
  }
369
  (*jvm)->DestroyJavaVM (jvm);
370 379
}
371 380

  
372 381

  

Also available in: Unified diff