Project

Profile

Help

Revision 0608038f

Added by O'Neil Delpratt over 5 years ago

Bug fix relating to issue 2772

View differences:

latest9.6/hec/Saxon.C.API/SaxonProcessor.cpp
28 28

  
29 29
//jobject cpp;
30 30
const char * failure;
31
sxnc_environment * SaxonProcessor::environ = 0;
32
int SaxonProcessor::refCount = 0;
33
int SaxonProcessor::jvmCreatedCPP=0;
31
sxnc_environment * environ = 0;
32
int refCount = 0;
33
int jvmCreatedCPP=0;
34 34

  
35 35
bool SaxonProcessor::exceptionOccurred(){
36 36
	return environ->env->ExceptionCheck();
......
232 232
	if(versionStr != NULL) {
233 233
		delete versionStr;
234 234
	}
235
	refCount--;	//The might be redundant due to the bug fix 2670
235
	refCount--;	//This might be redundant due to the bug fix 2670
236 236
   }
237 237

  
238 238

  
......
278 278
	saxonCAPIClass = other.saxonCAPIClass;
279 279
	cwd = other.cwd;
280 280
	proc = other.proc;
281
	environ = other.environ;
281
	//environ = other.environ;
282 282
	parameters = other.parameters;
283 283
	configProperties = other.configProperties;
284 284
	licensei = other.licensei;
......
457 457

  
458 458

  
459 459
void SaxonProcessor::release(){
460
	if(SaxonProcessor::jvmCreatedCPP!=0) {
461
		SaxonProcessor::jvmCreatedCPP =0;
460
	if(jvmCreatedCPP!=0) {
461
		jvmCreatedCPP =0;
462 462

  
463
 		finalizeJavaRT (SaxonProcessor::environ->jvm);
463
 		finalizeJavaRT (environ->jvm);
464 464

  
465 465
		//delete environ ;
466 466
	/*clearParameters();
latest9.6/hec/Saxon.C.API/SaxonProcessor.h
47 47
class XdmItem;
48 48
class XdmAtomicValue;
49 49

  
50

  
50
extern int jvmCreatedCPP;
51
extern sxnc_environment * environ;
52
extern int refCount;
51 53

  
52 54
// The Saxon XSLT interface class
53 55

  
......
515 517
//	SchemaManager
516 518

  
517 519
   // static JNIEnv *env;
518
    extern static sxnc_environment * environ;
520
    
519 521
    std::string cwd; /*!< current working directory */
520 522
    jobject proc; /*!< Java Processor object */
521
    extern static int jvmCreatedCPP;
522 523
    
523 524
    /*static JavaVM *jvm;*/
524
    static int refCount;
525
    
525 526
protected:
526 527
	jclass xdmAtomicClass;
527 528
	jclass  versionClass;
latest9.6/hec/Saxon.C.API/SchemaValidator.cpp
15 15
	/*
16 16
	 * Look for class.
17 17
	 */
18
	cppClass = lookForClass(proc->environ->env,
18
	cppClass = lookForClass(environ->env,
19 19
			"net/sf/saxon/option/cpp/SchemaValidatorForCpp");
20 20
	if ((proc->proc) == NULL) {
21 21
		std::cerr << "Processor is NULL" << std::endl;
22 22
	}
23 23

  
24
	cppV = createSaxonProcessor2(proc->environ->env, cppClass,
24
	cppV = createSaxonProcessor2(environ->env, cppClass,
25 25
			"(Lnet/sf/saxon/s9api/Processor;)V", proc->proc);
26 26

  
27 27
#ifdef DEBUG
28
	jmethodID debugMID = proc->environ->env->GetStaticMethodID(cppClass, "setDebugMode", "(Z)V");
29
	proc->environ->env->CallStaticVoidMethod(cppClass, debugMID, (jboolean)true);
28
	jmethodID debugMID = environ->env->GetStaticMethodID(cppClass, "setDebugMode", "(Z)V");
29
	environ->env->CallStaticVoidMethod(cppClass, debugMID, (jboolean)true);
30 30
#endif    
31 31

  
32 32
	proc->exception = NULL;
......
39 39
				if(proc->exception != NULL) {
40 40
					delete proc->exception;
41 41
				}
42
				proc->exception = proc->checkForExceptionCPP(proc->environ->env, cppClass, NULL);
42
				proc->exception = proc->checkForExceptionCPP(environ->env, cppClass, NULL);
43 43
				
44 44
     			
45 45
			
46 46
#ifdef DEBUG
47
		proc->environ->env->ExceptionDescribe();
47
		environ->env->ExceptionDescribe();
48 48
#endif
49 49
		proc->exceptionClear();
50 50
	}
......
63 63

  
64 64
  XdmNode * SchemaValidator::getValidationReport(){
65 65
	jmethodID mID =
66
		(jmethodID) proc->environ->env->GetMethodID(cppClass, "getValidationReport", "()Lnet/sf/saxon/s9api/XdmNode;");
66
		(jmethodID) environ->env->GetMethodID(cppClass, "getValidationReport", "()Lnet/sf/saxon/s9api/XdmNode;");
67 67
	if (!mID) {
68 68
		std::cerr << "Error: libsaxon." << "validate.getValidationReport()" << " not found\n"
69 69
			<< std::endl;
70 70
	} else {
71 71
		jobject result = (jobject)(
72
			proc->environ->env->CallObjectMethod(cppV, mID));
72
			environ->env->CallObjectMethod(cppV, mID));
73 73
		
74 74
		if (result) {
75 75
			XdmNode * node = new XdmNode(result);
......
87 87
        }
88 88
	
89 89
	jmethodID mID =
90
		(jmethodID) proc->environ->env->GetMethodID(cppClass, "registerSchema",
90
		(jmethodID) environ->env->GetMethodID(cppClass, "registerSchema",
91 91
				"(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)V");
92 92
	if (!mID) {
93 93
		std::cerr << "Error: libsaxon." << "validate" << " not found\n"
......
95 95
	} else {
96 96
	jobjectArray stringArray = NULL;
97 97
	jobjectArray objectArray = NULL;
98
	jclass objectClass = lookForClass(proc->environ->env, "java/lang/Object");
99
	jclass stringClass = lookForClass(proc->environ->env, "java/lang/String");
98
	jclass objectClass = lookForClass(environ->env, "java/lang/Object");
99
	jclass stringClass = lookForClass(environ->env, "java/lang/String");
100 100

  
101 101
	int size = parameters.size() + properties.size();
102 102
#ifdef DEBUG
......
105 105
		std::cerr<<"size:"<<size<<std::endl;
106 106
#endif
107 107
	if (size > 0) {
108
		objectArray = proc->environ->env->NewObjectArray((jint) size,
108
		objectArray = environ->env->NewObjectArray((jint) size,
109 109
				objectClass, 0);
110
		stringArray = proc->environ->env->NewObjectArray((jint) size,
110
		stringArray = environ->env->NewObjectArray((jint) size,
111 111
				stringClass, 0);
112 112
		int i = 0;
113 113
		for (std::map<std::string, XdmValue*>::iterator iter = parameters.begin();
114 114
				iter != parameters.end(); ++iter, i++) {
115
			proc->environ->env->SetObjectArrayElement(stringArray, i,
116
					proc->environ->env->NewStringUTF((iter->first).c_str()));
117
			proc->environ->env->SetObjectArrayElement(objectArray, i,
115
			environ->env->SetObjectArrayElement(stringArray, i,
116
					environ->env->NewStringUTF((iter->first).c_str()));
117
			environ->env->SetObjectArrayElement(objectArray, i,
118 118
					(iter->second)->getUnderlyingValue(proc));
119 119
#ifdef DEBUG
120 120
				std::string s1 = typeid(iter->second).name();
......
133 133
		}
134 134
		for (std::map<std::string, std::string>::iterator iter = properties.begin();
135 135
				iter != properties.end(); ++iter, i++) {
136
			proc->environ->env->SetObjectArrayElement(stringArray, i,
137
					proc->environ->env->NewStringUTF((iter->first).c_str()));
138
			proc->environ->env->SetObjectArrayElement(objectArray, i,
139
					proc->environ->env->NewStringUTF((iter->second).c_str()));
136
			environ->env->SetObjectArrayElement(stringArray, i,
137
					environ->env->NewStringUTF((iter->first).c_str()));
138
			environ->env->SetObjectArrayElement(objectArray, i,
139
					environ->env->NewStringUTF((iter->second).c_str()));
140 140
		}
141 141
	}
142 142
	
143
			proc->environ->env->CallVoidMethod(cppV, mID,
144
					proc->environ->env->NewStringUTF(cwdV.c_str()),
145
					proc->environ->env->NewStringUTF(sourceFile), stringArray, objectArray);
143
			environ->env->CallVoidMethod(cppV, mID,
144
					environ->env->NewStringUTF(cwdV.c_str()),
145
					environ->env->NewStringUTF(sourceFile), stringArray, objectArray);
146 146

  
147 147
	if (size > 0) {
148
		proc->environ->env->DeleteLocalRef(stringArray);
149
		proc->environ->env->DeleteLocalRef(objectArray);
148
		environ->env->DeleteLocalRef(stringArray);
149
		environ->env->DeleteLocalRef(objectArray);
150 150
	}
151 151

  
152 152
}
......
154 154
				if(proc->exception != NULL) {
155 155
					delete proc->exception;
156 156
				}
157
				proc->exception = proc->checkForExceptionCPP(proc->environ->env, cppClass, NULL);
157
				proc->exception = proc->checkForExceptionCPP(environ->env, cppClass, NULL);
158 158
				
159 159
     			
160 160
			
161 161
#ifdef DEBUG
162
		proc->environ->env->ExceptionDescribe();
162
		environ->env->ExceptionDescribe();
163 163
#endif
164 164
		proc->exceptionClear();
165 165
	}
......
173 173
	     return;
174 174
        }
175 175
	jmethodID mID =
176
		(jmethodID) proc->environ->env->GetMethodID(cppClass, "registerSchemaString",
176
		(jmethodID) environ->env->GetMethodID(cppClass, "registerSchemaString",
177 177
				"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)V");
178 178

  
179 179
	if (!mID) {
......
182 182
	} else {
183 183
	jobjectArray stringArray = NULL;
184 184
	jobjectArray objectArray = NULL;
185
	jclass objectClass = lookForClass(proc->environ->env, "java/lang/Object");
186
	jclass stringClass = lookForClass(proc->environ->env, "java/lang/String");
185
	jclass objectClass = lookForClass(environ->env, "java/lang/Object");
186
	jclass stringClass = lookForClass(environ->env, "java/lang/String");
187 187

  
188 188
	int size = parameters.size() + properties.size();
189 189
#ifdef DEBUG
......
193 193
#endif
194 194

  
195 195
	if (size > 0) {
196
		objectArray = proc->environ->env->NewObjectArray((jint) size,
196
		objectArray = environ->env->NewObjectArray((jint) size,
197 197
				objectClass, 0);
198
		stringArray = proc->environ->env->NewObjectArray((jint) size,
198
		stringArray = environ->env->NewObjectArray((jint) size,
199 199
				stringClass, 0);
200 200
		int i = 0;
201 201
		for (std::map<std::string, XdmValue*>::iterator iter = parameters.begin();
202 202
				iter != parameters.end(); ++iter, i++) {
203
			proc->environ->env->SetObjectArrayElement(stringArray, i,
204
					proc->environ->env->NewStringUTF((iter->first).c_str()));
205
			proc->environ->env->SetObjectArrayElement(objectArray, i,
203
			environ->env->SetObjectArrayElement(stringArray, i,
204
					environ->env->NewStringUTF((iter->first).c_str()));
205
			environ->env->SetObjectArrayElement(objectArray, i,
206 206
					(iter->second)->getUnderlyingValue(proc));
207 207
#ifdef DEBUG
208 208
				std::string s1 = typeid(iter->second).name();
......
221 221
		}
222 222
		for (std::map<std::string, std::string>::iterator iter = properties.begin();
223 223
				iter != properties.end(); ++iter, i++) {
224
			proc->environ->env->SetObjectArrayElement(stringArray, i,
225
					proc->environ->env->NewStringUTF((iter->first).c_str()));
226
			proc->environ->env->SetObjectArrayElement(objectArray, i,
227
					proc->environ->env->NewStringUTF((iter->second).c_str()));
224
			environ->env->SetObjectArrayElement(stringArray, i,
225
					environ->env->NewStringUTF((iter->first).c_str()));
226
			environ->env->SetObjectArrayElement(objectArray, i,
227
					environ->env->NewStringUTF((iter->second).c_str()));
228 228
		}
229 229
	}
230 230

  
231 231
	
232
			proc->environ->env->CallVoidMethod(cppV, mID,
233
					proc->environ->env->NewStringUTF(cwdV.c_str()),
234
					(sourceStr != NULL ? proc->environ->env->NewStringUTF(sourceStr) : NULL), NULL, stringArray, objectArray);
232
			environ->env->CallVoidMethod(cppV, mID,
233
					environ->env->NewStringUTF(cwdV.c_str()),
234
					(sourceStr != NULL ? environ->env->NewStringUTF(sourceStr) : NULL), NULL, stringArray, objectArray);
235 235

  
236 236
	if (size > 0) {
237
		proc->environ->env->DeleteLocalRef(stringArray);
238
		proc->environ->env->DeleteLocalRef(objectArray);
237
		environ->env->DeleteLocalRef(stringArray);
238
		environ->env->DeleteLocalRef(objectArray);
239 239
	}
240 240

  
241 241
}
......
245 245
				if(proc->exception != NULL) {
246 246
					delete proc->exception;
247 247
				}
248
				proc->exception = proc->checkForExceptionCPP(proc->environ->env, cppClass, NULL);
248
				proc->exception = proc->checkForExceptionCPP(environ->env, cppClass, NULL);
249 249
				
250 250
     			
251 251
#ifdef DEBUG
252
			proc->environ->env->ExceptionDescribe();
252
			environ->env->ExceptionDescribe();
253 253
#endif
254 254
			proc->exceptionClear();
255 255
		}
......
264 264
        }*/
265 265
setProperty("resources", proc->getResourcesDirectory());
266 266
jmethodID mID =
267
		(jmethodID) proc->environ->env->GetMethodID(cppClass, "validate",
267
		(jmethodID) environ->env->GetMethodID(cppClass, "validate",
268 268
				"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)V");
269 269
if (!mID) {
270 270
	std::cerr << "Error: libsaxon." << "validate" << " not found\n"
......
273 273
} else {
274 274
	jobjectArray stringArray = NULL;
275 275
	jobjectArray objectArray = NULL;
276
	jclass objectClass = lookForClass(proc->environ->env, "java/lang/Object");
277
	jclass stringClass = lookForClass(proc->environ->env, "java/lang/String");
276
	jclass objectClass = lookForClass(environ->env, "java/lang/Object");
277
	jclass stringClass = lookForClass(environ->env, "java/lang/String");
278 278

  
279 279
	int size = parameters.size() + properties.size();
280 280
#ifdef DEBUG
......
283 283
		std::cerr<<"size:"<<size<<std::endl;
284 284
#endif
285 285
	if (size > 0) {
286
		objectArray = proc->environ->env->NewObjectArray((jint) size,
286
		objectArray = environ->env->NewObjectArray((jint) size,
287 287
				objectClass, 0);
288
		stringArray = proc->environ->env->NewObjectArray((jint) size,
288
		stringArray = environ->env->NewObjectArray((jint) size,
289 289
				stringClass, 0);
290 290
		int i = 0;
291 291
		for (std::map<std::string, XdmValue*>::iterator iter = parameters.begin();
292 292
				iter != parameters.end(); ++iter, i++) {
293
			proc->environ->env->SetObjectArrayElement(stringArray, i,
294
					proc->environ->env->NewStringUTF((iter->first).c_str()));
295
			proc->environ->env->SetObjectArrayElement(objectArray, i,
293
			environ->env->SetObjectArrayElement(stringArray, i,
294
					environ->env->NewStringUTF((iter->first).c_str()));
295
			environ->env->SetObjectArrayElement(objectArray, i,
296 296
					(iter->second)->getUnderlyingValue(proc));
297 297

  
298 298
#ifdef DEBUG
......
312 312
		}
313 313
		for (std::map<std::string, std::string>::iterator iter = properties.begin();
314 314
				iter != properties.end(); ++iter, i++) {
315
			proc->environ->env->SetObjectArrayElement(stringArray, i,
316
					proc->environ->env->NewStringUTF((iter->first).c_str()));
317
			proc->environ->env->SetObjectArrayElement(objectArray, i,
318
					proc->environ->env->NewStringUTF((iter->second).c_str()));
315
			environ->env->SetObjectArrayElement(stringArray, i,
316
					environ->env->NewStringUTF((iter->first).c_str()));
317
			environ->env->SetObjectArrayElement(objectArray, i,
318
					environ->env->NewStringUTF((iter->second).c_str()));
319 319

  
320 320
		}
321 321
	}
322 322
	
323
			proc->environ->env->CallVoidMethod(cppV, mID,
324
					proc->environ->env->NewStringUTF(cwdV.c_str()), 
325
					(sourceFile != NULL ? proc->environ->env->NewStringUTF(sourceFile) : NULL), (outputFile.empty() ? NULL : outputFile.c_str() ), stringArray, objectArray);
323
			environ->env->CallVoidMethod(cppV, mID,
324
					environ->env->NewStringUTF(cwdV.c_str()), 
325
					(sourceFile != NULL ? environ->env->NewStringUTF(sourceFile) : NULL), (outputFile.empty() ? NULL : outputFile.c_str() ), stringArray, objectArray);
326 326

  
327 327
	if (size > 0) {
328
		proc->environ->env->DeleteLocalRef(stringArray);
329
		proc->environ->env->DeleteLocalRef(objectArray);
328
		environ->env->DeleteLocalRef(stringArray);
329
		environ->env->DeleteLocalRef(objectArray);
330 330
	}
331 331
		if(exceptionOccurred()) {
332 332
			if(proc->exception != NULL) {
333 333
				delete proc->exception;
334 334
			}
335
				proc->exception = proc->checkForExceptionCPP(proc->environ->env, cppClass, NULL);
335
				proc->exception = proc->checkForExceptionCPP(environ->env, cppClass, NULL);
336 336
				
337 337
     			
338 338

  
339 339

  
340 340
#ifdef DEBUG
341
	proc->environ->env->ExceptionDescribe();
341
	environ->env->ExceptionDescribe();
342 342
#endif
343 343
			proc->exceptionClear();
344 344
		}
......
352 352
        }
353 353
setProperty("resources", proc->getResourcesDirectory());
354 354
jmethodID mID =
355
		(jmethodID) proc->environ->env->GetMethodID(cppClass, "validateToNode",
355
		(jmethodID) environ->env->GetMethodID(cppClass, "validateToNode",
356 356
				"(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)Lnet/sf/saxon/s9api/XdmNode;");
357 357
if (!mID) {
358 358
	std::cerr << "Error: libsaxon." << "validate" << " not found\n"
......
361 361
} else {
362 362
	jobjectArray stringArray = NULL;
363 363
	jobjectArray objectArray = NULL;
364
	jclass objectClass = lookForClass(proc->environ->env, "java/lang/Object");
365
	jclass stringClass = lookForClass(proc->environ->env, "java/lang/String");
364
	jclass objectClass = lookForClass(environ->env, "java/lang/Object");
365
	jclass stringClass = lookForClass(environ->env, "java/lang/String");
366 366

  
367 367
	int size = parameters.size() + properties.size();
368 368
#ifdef DEBUG
......
371 371
		std::cerr<<"size:"<<size<<std::endl;
372 372
#endif
373 373
	if (size > 0) {
374
		objectArray = proc->environ->env->NewObjectArray((jint) size,
374
		objectArray = environ->env->NewObjectArray((jint) size,
375 375
				objectClass, 0);
376
		stringArray = proc->environ->env->NewObjectArray((jint) size,
376
		stringArray = environ->env->NewObjectArray((jint) size,
377 377
				stringClass, 0);
378 378
		int i = 0;
379 379
		for (std::map<std::string, XdmValue*>::iterator iter = parameters.begin();
380 380
				iter != parameters.end(); ++iter, i++) {
381
			proc->environ->env->SetObjectArrayElement(stringArray, i,
382
					proc->environ->env->NewStringUTF((iter->first).c_str()));
383
			proc->environ->env->SetObjectArrayElement(objectArray, i,
381
			environ->env->SetObjectArrayElement(stringArray, i,
382
					environ->env->NewStringUTF((iter->first).c_str()));
383
			environ->env->SetObjectArrayElement(objectArray, i,
384 384
					(iter->second)->getUnderlyingValue(proc));
385 385
#ifdef DEBUG
386 386
				std::string s1 = typeid(iter->second).name();
......
399 399
		}
400 400
		for (std::map<std::string, std::string>::iterator iter = properties.begin();
401 401
				iter != properties.end(); ++iter, i++) {
402
			proc->environ->env->SetObjectArrayElement(stringArray, i,
403
					proc->environ->env->NewStringUTF((iter->first).c_str()));
404
			proc->environ->env->SetObjectArrayElement(objectArray, i,
405
					proc->environ->env->NewStringUTF((iter->second).c_str()));
402
			environ->env->SetObjectArrayElement(stringArray, i,
403
					environ->env->NewStringUTF((iter->first).c_str()));
404
			environ->env->SetObjectArrayElement(objectArray, i,
405
					environ->env->NewStringUTF((iter->second).c_str()));
406 406
		}
407 407
	}
408 408
	jobject result = (jobject)(
409
			proc->environ->env->CallObjectMethod(cppV, mID,
410
					proc->environ->env->NewStringUTF(cwdV.c_str()),
411
					proc->environ->env->NewStringUTF(sourceFile), stringArray, objectArray));
409
			environ->env->CallObjectMethod(cppV, mID,
410
					environ->env->NewStringUTF(cwdV.c_str()),
411
					environ->env->NewStringUTF(sourceFile), stringArray, objectArray));
412 412
	if (size > 0) {
413
		proc->environ->env->DeleteLocalRef(stringArray);
414
		proc->environ->env->DeleteLocalRef(objectArray);
413
		environ->env->DeleteLocalRef(stringArray);
414
		environ->env->DeleteLocalRef(objectArray);
415 415
	}
416 416
	if (result) {
417 417
		XdmNode * node = new XdmNode(result);
......
421 421

  
422 422
}
423 423
#ifdef DEBUG
424
	proc->environ->env->ExceptionDescribe();
424
	environ->env->ExceptionDescribe();
425 425
#endif
426
proc->environ->env->ExceptionClear();
426
environ->env->ExceptionClear();
427 427

  
428 428
}
429 429

  
......
432 432
 	delete proc->exception;
433 433
 	proc->exception = NULL;
434 434
 }
435
   proc->environ->env->ExceptionClear();
435
   environ->env->ExceptionClear();
436 436
 }
437 437

  
438 438
const char * SchemaValidator::getErrorCode(int i) {
......
451 451

  
452 452
const char* SchemaValidator::checkException() {
453 453
	/*if(proc->exception == NULL) {
454
	 proc->exception = proc->checkForException(proc->environ, cppClass, cpp);
454
	 proc->exception = proc->checkForException(environ, cppClass, cpp);
455 455
	 }
456 456
	 return proc->exception;*/
457
	return checkForException(*(proc->environ), cppClass, cppV);
457
	return checkForException(*(environ), cppClass, cppV);
458 458
}
459 459

  
460 460
int SchemaValidator::exceptionCount(){
latest9.6/hec/Saxon.C.API/XPathProcessor.cpp
15 15
	/*
16 16
	 * Look for class.
17 17
	 */
18
	cppClass = lookForClass(proc->environ->env,
18
	cppClass = lookForClass(environ->env,
19 19
			"net/sf/saxon/option/cpp/XPathProcessor");
20 20
	if ((proc->proc) == NULL) {
21 21
		cerr << "Processor is NULL" << endl;
22 22
	}
23 23

  
24
	cppXP = createSaxonProcessor2(proc->environ->env, cppClass,
24
	cppXP = createSaxonProcessor2(environ->env, cppClass,
25 25
			"(Lnet/sf/saxon/s9api/Processor;)V", proc->proc);
26 26

  
27 27

  
28 28

  
29 29
#ifdef DEBUG
30
	jmethodID debugMID = proc->environ->env->GetStaticMethodID(cppClass, "setDebugMode", "(Z)V");
31
	proc->environ->env->CallStaticVoidMethod(cppClass, debugMID, (jboolean)true);
30
	jmethodID debugMID = environ->env->GetStaticMethodID(cppClass, "setDebugMode", "(Z)V");
31
	environ->env->CallStaticVoidMethod(cppClass, debugMID, (jboolean)true);
32 32
#endif    
33 33

  
34 34
	proc->exception = NULL;
......
47 47
}
48 48
setProperty("resources", proc->getResourcesDirectory());
49 49
jmethodID mID =
50
		(jmethodID) proc->environ->env->GetMethodID(cppClass, "evaluate",
50
		(jmethodID) environ->env->GetMethodID(cppClass, "evaluate",
51 51
				"(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)[Lnet/sf/saxon/s9api/XdmValue;");
52 52
if (!mID) {
53 53
	cerr << "Error: MyClassInDll." << "evaluate" << " not found\n"
......
56 56
} else {
57 57
	jobjectArray stringArray = NULL;
58 58
	jobjectArray objectArray = NULL;
59
	jclass objectClass = lookForClass(proc->environ->env, "java/lang/Object");
60
	jclass stringClass = lookForClass(proc->environ->env, "java/lang/String");
59
	jclass objectClass = lookForClass(environ->env, "java/lang/Object");
60
	jclass stringClass = lookForClass(environ->env, "java/lang/String");
61 61

  
62 62
	int size = parameters.size() + properties.size();
63 63
	if (size > 0) {
64
		objectArray = proc->environ->env->NewObjectArray((jint) size,
64
		objectArray = environ->env->NewObjectArray((jint) size,
65 65
				objectClass, 0);
66
		stringArray = proc->environ->env->NewObjectArray((jint) size,
66
		stringArray = environ->env->NewObjectArray((jint) size,
67 67
				stringClass, 0);
68 68
		int i = 0;
69 69
		for (map<std::string, XdmValue*>::iterator iter = parameters.begin();
70 70
				iter != parameters.end(); ++iter, i++) {
71
			proc->environ->env->SetObjectArrayElement(stringArray, i,
72
					proc->environ->env->NewStringUTF((iter->first).c_str()));
73
			proc->environ->env->SetObjectArrayElement(objectArray, i,
71
			environ->env->SetObjectArrayElement(stringArray, i,
72
					environ->env->NewStringUTF((iter->first).c_str()));
73
			environ->env->SetObjectArrayElement(objectArray, i,
74 74
					(iter->second)->getUnderlyingValue(proc));
75 75
		}
76 76
		for (map<std::string, std::string>::iterator iter = properties.begin();
77 77
				iter != properties.end(); ++iter, i++) {
78
			proc->environ->env->SetObjectArrayElement(stringArray, i,
79
					proc->environ->env->NewStringUTF((iter->first).c_str()));
80
			proc->environ->env->SetObjectArrayElement(objectArray, i,
81
					proc->environ->env->NewStringUTF((iter->second).c_str()));
78
			environ->env->SetObjectArrayElement(stringArray, i,
79
					environ->env->NewStringUTF((iter->first).c_str()));
80
			environ->env->SetObjectArrayElement(objectArray, i,
81
					environ->env->NewStringUTF((iter->second).c_str()));
82 82
		}
83 83
	}
84 84
	jobjectArray results = (jobjectArray)(
85
			proc->environ->env->CallObjectMethod(cppXP, mID,
86
					proc->environ->env->NewStringUTF(cwdXP.c_str()),
87
					proc->environ->env->NewStringUTF(xpathStr), stringArray, objectArray));
85
			environ->env->CallObjectMethod(cppXP, mID,
86
					environ->env->NewStringUTF(cwdXP.c_str()),
87
					environ->env->NewStringUTF(xpathStr), stringArray, objectArray));
88 88
	if(!results) {
89 89
		if(exceptionOccurred()) {
90 90
			if(proc->exception != NULL) {
91 91
				delete proc->exception;
92 92
			}
93
			proc->exception = proc->checkForExceptionCPP(proc->environ->env, cppClass, NULL);
93
			proc->exception = proc->checkForExceptionCPP(environ->env, cppClass, NULL);
94 94
			proc->exceptionClear();
95 95
			return NULL;
96 96
	   		
97 97
     		}
98 98
	}
99 99
	
100
	int sizex = proc->environ->env->GetArrayLength(results);
100
	int sizex = environ->env->GetArrayLength(results);
101 101
	if (size > 0) {
102
		proc->environ->env->DeleteLocalRef(stringArray);
103
		proc->environ->env->DeleteLocalRef(objectArray);
102
		environ->env->DeleteLocalRef(stringArray);
103
		environ->env->DeleteLocalRef(objectArray);
104 104
	}
105 105
	if (sizex>0) {
106
		jclass atomicValueClass = lookForClass(proc->environ->env, "net/sf/saxon/s9api/XdmAtomicValue");
107
		jclass nodeClass = lookForClass(proc->environ->env, "net/sf/saxon/s9api/XdmNode");
108
		jclass functionItemClass = lookForClass(proc->environ->env, "net/sf/saxon/s9api/XdmFunctionItem");
106
		jclass atomicValueClass = lookForClass(environ->env, "net/sf/saxon/s9api/XdmAtomicValue");
107
		jclass nodeClass = lookForClass(environ->env, "net/sf/saxon/s9api/XdmNode");
108
		jclass functionItemClass = lookForClass(environ->env, "net/sf/saxon/s9api/XdmFunctionItem");
109 109

  
110 110
		XdmValue * value = new XdmValue();
111 111
		value->setProcessor(proc);
112 112
		XdmItem * xdmItem = NULL;
113 113
		for (int p=0; p < sizex; ++p) 
114 114
		{
115
			jobject resulti = proc->environ->env->GetObjectArrayElement(results, p);
115
			jobject resulti = environ->env->GetObjectArrayElement(results, p);
116 116
			//value->addUnderlyingValue(resulti);
117 117

  
118
			if(proc->environ->env->IsInstanceOf(resulti, atomicValueClass)           == JNI_TRUE) {
118
			if(environ->env->IsInstanceOf(resulti, atomicValueClass)           == JNI_TRUE) {
119 119
				xdmItem = new XdmAtomicValue(resulti);
120 120
				
121 121

  
122
			} else if(proc->environ->env->IsInstanceOf(resulti, nodeClass)           == JNI_TRUE) {
122
			} else if(environ->env->IsInstanceOf(resulti, nodeClass)           == JNI_TRUE) {
123 123
				xdmItem = new XdmNode(resulti);
124 124

  
125 125

  
126
			} else if (proc->environ->env->IsInstanceOf(resulti, functionItemClass)           == JNI_TRUE) {
126
			} else if (environ->env->IsInstanceOf(resulti, functionItemClass)           == JNI_TRUE) {
127 127
				continue;
128 128
			}
129 129
			xdmItem->setProcessor(proc);
130 130
			value->addXdmItem(xdmItem);
131 131
		}
132
		proc->environ->env->DeleteLocalRef(results);
132
		environ->env->DeleteLocalRef(results);
133 133
		return value;
134 134
	}
135 135
}
......
144 144
        }
145 145
setProperty("resources", proc->getResourcesDirectory());
146 146
jmethodID mID =
147
		(jmethodID) proc->environ->env->GetMethodID(cppClass, "evaluateSingle",
147
		(jmethodID) environ->env->GetMethodID(cppClass, "evaluateSingle",
148 148
				"(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)Lnet/sf/saxon/s9api/XdmItem;");
149 149
if (!mID) {
150 150
	cerr << "Error: MyClassInDll." << "evaluateSingle" << " not found\n"
......
153 153
} else {
154 154
	jobjectArray stringArray = NULL;
155 155
	jobjectArray objectArray = NULL;
156
	jclass objectClass = lookForClass(proc->environ->env, "java/lang/Object");
157
	jclass stringClass = lookForClass(proc->environ->env, "java/lang/String");
156
	jclass objectClass = lookForClass(environ->env, "java/lang/Object");
157
	jclass stringClass = lookForClass(environ->env, "java/lang/String");
158 158

  
159 159
	int size = parameters.size() + properties.size();
160 160
#ifdef DEBUG
......
163 163
		cerr<<"size:"<<size<<endl;
164 164
#endif
165 165
	if (size > 0) {
166
		objectArray = proc->environ->env->NewObjectArray((jint) size,
166
		objectArray = environ->env->NewObjectArray((jint) size,
167 167
				objectClass, 0);
168
		stringArray = proc->environ->env->NewObjectArray((jint) size,
168
		stringArray = environ->env->NewObjectArray((jint) size,
169 169
				stringClass, 0);
170 170
		int i = 0;
171 171
		for (map<std::string, XdmValue*>::iterator iter = parameters.begin();
172 172
				iter != parameters.end(); ++iter, i++) {
173
			proc->environ->env->SetObjectArrayElement(stringArray, i,
174
					proc->environ->env->NewStringUTF((iter->first).c_str()));
175
			proc->environ->env->SetObjectArrayElement(objectArray, i,
173
			environ->env->SetObjectArrayElement(stringArray, i,
174
					environ->env->NewStringUTF((iter->first).c_str()));
175
			environ->env->SetObjectArrayElement(objectArray, i,
176 176
					(iter->second)->getUnderlyingValue(proc));
177 177
#ifdef DEBUG
178 178
				string s1 = typeid(iter->second).name();
......
191 191
		}
192 192
		for (map<std::string, std::string>::iterator iter = properties.begin();
193 193
				iter != properties.end(); ++iter, i++) {
194
			proc->environ->env->SetObjectArrayElement(stringArray, i,
195
					proc->environ->env->NewStringUTF((iter->first).c_str()));
196
			proc->environ->env->SetObjectArrayElement(objectArray, i,
197
					proc->environ->env->NewStringUTF((iter->second).c_str()));
194
			environ->env->SetObjectArrayElement(stringArray, i,
195
					environ->env->NewStringUTF((iter->first).c_str()));
196
			environ->env->SetObjectArrayElement(objectArray, i,
197
					environ->env->NewStringUTF((iter->second).c_str()));
198 198
		}
199 199
	}
200 200
	jobject result = (jobject)(
201
			proc->environ->env->CallObjectMethod(cppXP, mID,
202
					proc->environ->env->NewStringUTF(cwdXP.c_str()),
203
					proc->environ->env->NewStringUTF(xpathStr), stringArray, objectArray));
201
			environ->env->CallObjectMethod(cppXP, mID,
202
					environ->env->NewStringUTF(cwdXP.c_str()),
203
					environ->env->NewStringUTF(xpathStr), stringArray, objectArray));
204 204
	if (size > 0) {
205
		proc->environ->env->DeleteLocalRef(stringArray);
206
		proc->environ->env->DeleteLocalRef(objectArray);
205
		environ->env->DeleteLocalRef(stringArray);
206
		environ->env->DeleteLocalRef(objectArray);
207 207
	}
208 208
	if (result) {
209
		jclass atomicValueClass = lookForClass(proc->environ->env, "net/sf/saxon/s9api/XdmAtomicValue");
210
		jclass nodeClass = lookForClass(proc->environ->env, "net/sf/saxon/s9api/XdmNode");
211
		jclass functionItemClass = lookForClass(proc->environ->env, "net/sf/saxon/s9api/XdmFunctionItem");
209
		jclass atomicValueClass = lookForClass(environ->env, "net/sf/saxon/s9api/XdmAtomicValue");
210
		jclass nodeClass = lookForClass(environ->env, "net/sf/saxon/s9api/XdmNode");
211
		jclass functionItemClass = lookForClass(environ->env, "net/sf/saxon/s9api/XdmFunctionItem");
212 212
		XdmItem * xdmItem = NULL;
213
		if(proc->environ->env->IsInstanceOf(result, atomicValueClass)           == JNI_TRUE) {
213
		if(environ->env->IsInstanceOf(result, atomicValueClass)           == JNI_TRUE) {
214 214
			xdmItem = new XdmAtomicValue(result);
215 215

  
216
		} else if(proc->environ->env->IsInstanceOf(result, nodeClass)           == JNI_TRUE) {
216
		} else if(environ->env->IsInstanceOf(result, nodeClass)           == JNI_TRUE) {
217 217
			
218 218
			xdmItem = new XdmNode(result);
219 219

  
220
		} else if (proc->environ->env->IsInstanceOf(result, functionItemClass)           == JNI_TRUE) {
220
		} else if (environ->env->IsInstanceOf(result, functionItemClass)           == JNI_TRUE) {
221 221
			return NULL;
222 222
		}
223 223
		xdmItem->setProcessor(proc);
......
226 226
			if(proc->exception != NULL) {
227 227
				delete proc->exception;
228 228
			}
229
			proc->exception = proc->checkForExceptionCPP(proc->environ->env, cppClass, NULL);
229
			proc->exception = proc->checkForExceptionCPP(environ->env, cppClass, NULL);
230 230
			proc->exceptionClear();
231 231
	   		
232 232
     		}
......
256 256
		return;
257 257
        }
258 258
	jmethodID mID =
259
		(jmethodID) proc->environ->env->GetMethodID(cppClass, "declareNamespace",
259
		(jmethodID) environ->env->GetMethodID(cppClass, "declareNamespace",
260 260
				"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
261 261
	if (!mID) {
262 262
	cerr << "Error: MyClassInDll." << "declareNameSpace" << " not found\n"
263 263
			<< endl;
264 264

  
265 265
	} else {
266
			proc->environ->env->CallObjectMethod(cppXP, mID,
267
					proc->environ->env->NewStringUTF(prefix),
268
					proc->environ->env->NewStringUTF(uri));
266
			environ->env->CallObjectMethod(cppXP, mID,
267
					environ->env->NewStringUTF(prefix),
268
					environ->env->NewStringUTF(uri));
269 269
	}
270 270

  
271 271
}
......
277 277
        }
278 278
setProperty("resources", proc->getResourcesDirectory());
279 279
jmethodID mID =
280
		(jmethodID) proc->environ->env->GetMethodID(cppClass, "setBaseURI",
280
		(jmethodID) environ->env->GetMethodID(cppClass, "setBaseURI",
281 281
				"(Ljava/lang/String;)Z");
282 282
if (!mID) {
283 283
	cerr << "Error: MyClassInDll." << "setBaseURI" << " not found\n"
......
285 285

  
286 286
} else {
287 287

  
288
	proc->environ->env->CallObjectMethod(cppXP, mID,
289
					proc->environ->env->NewStringUTF(uriStr));
288
	environ->env->CallObjectMethod(cppXP, mID,
289
					environ->env->NewStringUTF(uriStr));
290 290
}
291 291

  
292 292
}
......
298 298
        }
299 299
setProperty("resources", proc->getResourcesDirectory());
300 300
jmethodID mID =
301
		(jmethodID) proc->environ->env->GetMethodID(cppClass, "effectiveBooleanValue",
301
		(jmethodID) environ->env->GetMethodID(cppClass, "effectiveBooleanValue",
302 302
				"(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)Z");
303 303
if (!mID) {
304 304
	cerr << "Error: MyClassInDll." << "effectiveBooleanValue" << " not found\n"
......
307 307
} else {
308 308
	jobjectArray stringArray = NULL;
309 309
	jobjectArray objectArray = NULL;
310
	jclass objectClass = lookForClass(proc->environ->env, "java/lang/Object");
311
	jclass stringClass = lookForClass(proc->environ->env, "java/lang/String");
310
	jclass objectClass = lookForClass(environ->env, "java/lang/Object");
311
	jclass stringClass = lookForClass(environ->env, "java/lang/String");
312 312

  
313 313
	int size = parameters.size() + properties.size();
314 314
	if (size > 0) {
315
		objectArray = proc->environ->env->NewObjectArray((jint) size,
315
		objectArray = environ->env->NewObjectArray((jint) size,
316 316
				objectClass, 0);
317
		stringArray = proc->environ->env->NewObjectArray((jint) size,
317
		stringArray = environ->env->NewObjectArray((jint) size,
318 318
				stringClass, 0);
319 319
		int i = 0;
320 320
		for (map<std::string, XdmValue*>::iterator iter = parameters.begin();
321 321
				iter != parameters.end(); ++iter, i++) {
322
			proc->environ->env->SetObjectArrayElement(stringArray, i,
323
					proc->environ->env->NewStringUTF((iter->first).c_str()));
324
			proc->environ->env->SetObjectArrayElement(objectArray, i,
322
			environ->env->SetObjectArrayElement(stringArray, i,
323
					environ->env->NewStringUTF((iter->first).c_str()));
324
			environ->env->SetObjectArrayElement(objectArray, i,
325 325
					(iter->second)->getUnderlyingValue(proc));
326 326
		}
327 327
		for (map<std::string, std::string>::iterator iter = properties.begin();
328 328
				iter != properties.end(); ++iter, i++) {
329
			proc->environ->env->SetObjectArrayElement(stringArray, i,
330
					proc->environ->env->NewStringUTF((iter->first).c_str()));
331
			proc->environ->env->SetObjectArrayElement(objectArray, i,
332
					proc->environ->env->NewStringUTF((iter->second).c_str()));
329
			environ->env->SetObjectArrayElement(stringArray, i,
330
					environ->env->NewStringUTF((iter->first).c_str()));
331
			environ->env->SetObjectArrayElement(objectArray, i,
332
					environ->env->NewStringUTF((iter->second).c_str()));
333 333
		}
334 334
	}
335 335
	jboolean result = (jboolean)(
336
			proc->environ->env->CallBooleanMethod(cppXP, mID,
337
					proc->environ->env->NewStringUTF(cwdXP.c_str()),
338
					proc->environ->env->NewStringUTF(xpathStr), stringArray, objectArray));
336
			environ->env->CallBooleanMethod(cppXP, mID,
337
					environ->env->NewStringUTF(cwdXP.c_str()),
338
					environ->env->NewStringUTF(xpathStr), stringArray, objectArray));
339 339
	if (size > 0) {
340
		proc->environ->env->DeleteLocalRef(stringArray);
341
		proc->environ->env->DeleteLocalRef(objectArray);
340
		environ->env->DeleteLocalRef(stringArray);
341
		environ->env->DeleteLocalRef(objectArray);
342 342
	}
343 343
	if(exceptionOccurred()) {
344 344
			if(proc->exception != NULL) {
345 345
				delete proc->exception;
346 346
			}
347
			proc->exception = proc->checkForExceptionCPP(proc->environ->env, cppClass, NULL);
347
			proc->exception = proc->checkForExceptionCPP(environ->env, cppClass, NULL);
348 348
			proc->exceptionClear();
349 349
	   		
350 350
     	}
......
414 414
		proc->exception = NULL;	
415 415
	}
416 416

  
417
   proc->environ->env->ExceptionClear();
417
   environ->env->ExceptionClear();
418 418
 
419 419
}
420 420

  
......
442 442

  
443 443

  
444 444
    const char* XPathProcessor::checkException(){
445
	return checkForException(*(proc->environ), cppClass, cppXP);
445
	return checkForException(*(environ), cppClass, cppXP);
446 446
    }
447 447

  
latest9.6/hec/Saxon.C.API/XQueryProcessor.cpp
13 13
    proc = p;
14 14

  
15 15
  
16
     cppClass = lookForClass(proc->environ->env, "net/sf/saxon/option/cpp/XQueryEngine");
16
     cppClass = lookForClass(environ->env, "net/sf/saxon/option/cpp/XQueryEngine");
17 17

  
18 18

  
19
    cppXQ = createSaxonProcessor2 (proc->environ->env, cppClass, "(Lnet/sf/saxon/s9api/Processor;)V", proc->proc);
19
    cppXQ = createSaxonProcessor2 (environ->env, cppClass, "(Lnet/sf/saxon/s9api/Processor;)V", proc->proc);
20 20
    
21 21
#ifdef DEBUG
22
	jmethodID debugMID = proc->environ->env->GetStaticMethodID(cppClass, "setDebugMode", "(Z)V");
23
	proc->environ->env->CallStaticVoidMethod(cppClass, debugMID, (jboolean)true);
22
	jmethodID debugMID = environ->env->GetStaticMethodID(cppClass, "setDebugMode", "(Z)V");
23
	environ->env->CallStaticVoidMethod(cppClass, debugMID, (jboolean)true);
24 24
#endif
25 25

  
26 26
    proc->exception = NULL;
......
61 61
		return;
62 62
        }
63 63
	jmethodID mID =
64
		(jmethodID) proc->environ->env->GetMethodID(cppClass, "declareNamespace",
64
		(jmethodID) environ->env->GetMethodID(cppClass, "declareNamespace",
65 65
				"(Ljava/lang/String;Ljava/lang/String;)V");
66 66
	if (!mID) {
67 67
	cerr << "Error: MyClassInDll." << "declareNameSpace" << " not found\n"
......
69 69

  
70 70
	} else {
71 71
	
72
			proc->environ->env->CallObjectMethod(cppXQ, mID,
73
					proc->environ->env->NewStringUTF(prefix),
74
					proc->environ->env->NewStringUTF(uri));
72
			environ->env->CallObjectMethod(cppXQ, mID,
73
					environ->env->NewStringUTF(prefix),
74
					environ->env->NewStringUTF(uri));
75 75
	}
76 76

  
77 77
}
......
164 164
    void XQueryProcessor::executeQueryToFile(const char * infilename, const char * ofilename, const char * query){
165 165
	setProperty("resources", proc->getResourcesDirectory());  
166 166

  
167
	jmethodID mID = (jmethodID)proc->environ->env->GetMethodID (cppClass,"executeQueryToFile", "(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)V");
167
	jmethodID mID = (jmethodID)environ->env->GetMethodID (cppClass,"executeQueryToFile", "(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)V");
168 168
 	if (!mID) {
169 169
        cout<<"Error: MyClassInDll."<<"executeQueryToFile"<<" not found\n"<<endl;
170 170
    } else {
......
177 177
	if(size >0) {
178 178

  
179 179
	   int i=0;
180
           jclass objectClass = lookForClass(proc->environ->env, "java/lang/Object");
181
	   jclass stringClass = lookForClass(proc->environ->env, "java/lang/String");
182
	   objectArray = proc->environ->env->NewObjectArray( (jint)size, objectClass, 0 );
183
	   stringArray = proc->environ->env->NewObjectArray( (jint)size, stringClass, 0 );
180
           jclass objectClass = lookForClass(environ->env, "java/lang/Object");
181
	   jclass stringClass = lookForClass(environ->env, "java/lang/String");
182
	   objectArray = environ->env->NewObjectArray( (jint)size, objectClass, 0 );
183
	   stringArray = environ->env->NewObjectArray( (jint)size, stringClass, 0 );
184 184
	   if(query!= NULL) {
185
	     proc->environ->env->SetObjectArrayElement( stringArray, i, proc->environ->env->NewStringUTF("qs") );
186
     	     proc->environ->env->SetObjectArrayElement( objectArray, i, proc->environ->env->NewStringUTF(query));
185
	     environ->env->SetObjectArrayElement( stringArray, i, environ->env->NewStringUTF("qs") );
186
     	     environ->env->SetObjectArrayElement( objectArray, i, environ->env->NewStringUTF(query));
187 187
	     i++;	
188 188
	   }
189 189
	   if(infilename!= NULL) {
190
	     proc->environ->env->SetObjectArrayElement( stringArray, i, proc->environ->env->NewStringUTF("s") );
191
     	     proc->environ->env->SetObjectArrayElement( objectArray, i, proc->environ->env->NewStringUTF(infilename));
190
	     environ->env->SetObjectArrayElement( stringArray, i, environ->env->NewStringUTF("s") );
191
     	     environ->env->SetObjectArrayElement( objectArray, i, environ->env->NewStringUTF(infilename));
192 192
	     i++;	
193 193
	   }
194 194
	   for(map<std::string, XdmValue* >::iterator iter=parameters.begin(); iter!=parameters.end(); ++iter, i++) {
195
	     proc->environ->env->SetObjectArrayElement( stringArray, i, proc->environ->env->NewStringUTF( (iter->first).c_str() ) );
196
		bool checkCast = proc->environ->env->IsInstanceOf((iter->second)->getUnderlyingValue(proc), lookForClass(proc->environ->env, "net/sf/saxon/option/cpp/XdmValueForCpp") );
195
	     environ->env->SetObjectArrayElement( stringArray, i, environ->env->NewStringUTF( (iter->first).c_str() ) );
196
		bool checkCast = environ->env->IsInstanceOf((iter->second)->getUnderlyingValue(proc), lookForClass(environ->env, "net/sf/saxon/option/cpp/XdmValueForCpp") );
197 197
		if(( (bool)checkCast)==false ){
198 198
			failure = "FAILURE in  array of XdmValueForCpp";
199 199
		} 
200
	     proc->environ->env->SetObjectArrayElement( objectArray, i, (jobject)((iter->second)->getUnderlyingValue(proc)) );
200
	     environ->env->SetObjectArrayElement( objectArray, i, (jobject)((iter->second)->getUnderlyingValue(proc)) );
201 201
	   }
202 202
  	   for(map<std::string, std::string >::iterator iter=properties.begin(); iter!=properties.end(); ++iter, i++) {
203
	     proc->environ->env->SetObjectArrayElement( stringArray, i, proc->environ->env->NewStringUTF( (iter->first).c_str()  ));
204
	     proc->environ->env->SetObjectArrayElement( objectArray, i, (jobject)(proc->environ->env->NewStringUTF((iter->second).c_str())) );
203
	     environ->env->SetObjectArrayElement( stringArray, i, environ->env->NewStringUTF( (iter->first).c_str()  ));
204
	     environ->env->SetObjectArrayElement( objectArray, i, (jobject)(environ->env->NewStringUTF((iter->second).c_str())) );
205 205
	   }
206 206
	}
207 207

  
208
	 proc->environ->env->CallObjectMethod(cppXQ, mID, proc->environ->env->NewStringUTF(cwdXQ.c_str()), proc->environ->env->NewStringUTF(ofilename), stringArray, objectArray );
209
	  proc->environ->env->DeleteLocalRef(objectArray);
210
	  proc->environ->env->DeleteLocalRef(stringArray);
208
	 environ->env->CallObjectMethod(cppXQ, mID, environ->env->NewStringUTF(cwdXQ.c_str()), environ->env->NewStringUTF(ofilename), stringArray, objectArray );
209
	  environ->env->DeleteLocalRef(objectArray);
210
	  environ->env->DeleteLocalRef(stringArray);
211 211

  
212 212
	if(exceptionOccurred()) {
213 213
			if(proc->exception != NULL) {
214 214
				delete proc->exception;
215 215
			}		
216
		proc->exception = proc->checkForExceptionCPP(proc->environ->env, cppClass, NULL);	
216
		proc->exception = proc->checkForExceptionCPP(environ->env, cppClass, NULL);	
217 217
		proc->exceptionClear();
218 218
	   		
219 219
     	}
......
226 226

  
227 227
    XdmValue * XQueryProcessor::executeQueryToValue(const char * infilename, const char * query){
228 228
	setProperty("resources", proc->getResourcesDirectory()); 
229
 jmethodID mID = (jmethodID)proc->environ->env->GetMethodID (cppClass,"executeQueryToValue", "(Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)Lnet/sf/saxon/s9api/XdmValue;");
229
 jmethodID mID = (jmethodID)environ->env->GetMethodID (cppClass,"executeQueryToValue", "(Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)Lnet/sf/saxon/s9api/XdmValue;");
230 230
 if (!mID) {
231 231
        cout<<"Error: MyClassInDll."<<"executeQueryToValue"<<" not found\n"<<endl;
232 232
    } else {
......
238 238
	if(infilename!= NULL) size++;
239 239
	if(size >0) {
240 240
	   int i=0;
241
           jclass objectClass = lookForClass(proc->environ->env, "java/lang/Object");
242
	   jclass stringClass = lookForClass(proc->environ->env, "java/lang/String");
243
	   objectArray = proc->environ->env->NewObjectArray( (jint)size, objectClass, 0 );
244
	   stringArray = proc->environ->env->NewObjectArray( (jint)size, stringClass, 0 );
241
           jclass objectClass = lookForClass(environ->env, "java/lang/Object");
242
	   jclass stringClass = lookForClass(environ->env, "java/lang/String");
243
	   objectArray = environ->env->NewObjectArray( (jint)size, objectClass, 0 );
244
	   stringArray = environ->env->NewObjectArray( (jint)size, stringClass, 0 );
245 245

  
246 246
	   if(query!= NULL) {
247
	     proc->environ->env->SetObjectArrayElement( stringArray, i, proc->environ->env->NewStringUTF("qs") );
248
     	     proc->environ->env->SetObjectArrayElement( objectArray, i, proc->environ->env->NewStringUTF(query));
247
	     environ->env->SetObjectArrayElement( stringArray, i, environ->env->NewStringUTF("qs") );
248
     	     environ->env->SetObjectArrayElement( objectArray, i, environ->env->NewStringUTF(query));
249 249
	     i++;	
250 250
	   }
251 251
	   if(infilename!= NULL) {
252
	     proc->environ->env->SetObjectArrayElement( stringArray, i, proc->environ->env->NewStringUTF("s") );
253
     	     proc->environ->env->SetObjectArrayElement( objectArray, i, proc->environ->env->NewStringUTF(infilename));
252
	     environ->env->SetObjectArrayElement( stringArray, i, environ->env->NewStringUTF("s") );
253
     	     environ->env->SetObjectArrayElement( objectArray, i, environ->env->NewStringUTF(infilename));
254 254
	     i++;	
255 255
	   }
256 256
	   for(map<std::string, XdmValue* >::iterator iter=parameters.begin(); iter!=parameters.end(); ++iter, i++) {
257
	     proc->environ->env->SetObjectArrayElement( stringArray, i, proc->environ->env->NewStringUTF( (iter->first).c_str() ) );
258
		bool checkCast = proc->environ->env->IsInstanceOf((iter->second)->getUnderlyingValue(proc), lookForClass(proc->environ->env, "net/sf/saxon/option/cpp/XdmValueForCpp") );
257
	     environ->env->SetObjectArrayElement( stringArray, i, environ->env->NewStringUTF( (iter->first).c_str() ) );
258
		bool checkCast = environ->env->IsInstanceOf((iter->second)->getUnderlyingValue(proc), lookForClass(environ->env, "net/sf/saxon/option/cpp/XdmValueForCpp") );
259 259
		if(( (bool)checkCast)==false ){
260 260
			failure = "FAILURE in  array of XdmValueForCpp";
261 261
		} 
262
	     proc->environ->env->SetObjectArrayElement( objectArray, i, (jobject)((iter->second)->getUnderlyingValue(proc)) );
262
	     environ->env->SetObjectArrayElement( objectArray, i, (jobject)((iter->second)->getUnderlyingValue(proc)) );
263 263
	   }
264 264
  	   for(map<std::string, std::string >::iterator iter=properties.begin(); iter!=properties.end(); ++iter, i++) {
265
	     proc->environ->env->SetObjectArrayElement( stringArray, i, proc->environ->env->NewStringUTF( (iter->first).c_str()  ));
266
	     proc->environ->env->SetObjectArrayElement( objectArray, i, (jobject)(proc->environ->env->NewStringUTF((iter->second).c_str())) );
265
	     environ->env->SetObjectArrayElement( stringArray, i, environ->env->NewStringUTF( (iter->first).c_str()  ));
266
	     environ->env->SetObjectArrayElement( objectArray, i, (jobject)(environ->env->NewStringUTF((iter->second).c_str())) );
267 267
	   }
268 268
	}
269 269

  
270
	  jobject result = (jobject)(proc->environ->env->CallObjectMethod(cppXQ, mID, proc->environ->env->NewStringUTF(cwdXQ.c_str()), stringArray, objectArray ));
271
	  proc->environ->env->DeleteLocalRef(objectArray);
272
	  proc->environ->env->DeleteLocalRef(stringArray);
270
	  jobject result = (jobject)(environ->env->CallObjectMethod(cppXQ, mID, environ->env->NewStringUTF(cwdXQ.c_str()), stringArray, objectArray ));
271
	  environ->env->DeleteLocalRef(objectArray);
272
	  environ->env->DeleteLocalRef(stringArray);
273 273
    if(result) {
274
		jclass atomicValueClass = lookForClass(proc->environ->env, "net/sf/saxon/s9api/XdmAtomicValue");
275
		jclass nodeClass = lookForClass(proc->environ->env, "net/sf/saxon/s9api/XdmNode");
276
		jclass functionItemClass = lookForClass(proc->environ->env, "net/sf/saxon/s9api/XdmFunctionItem");
274
		jclass atomicValueClass = lookForClass(environ->env, "net/sf/saxon/s9api/XdmAtomicValue");
275
		jclass nodeClass = lookForClass(environ->env, "net/sf/saxon/s9api/XdmNode");
276
		jclass functionItemClass = lookForClass(environ->env, "net/sf/saxon/s9api/XdmFunctionItem");
277 277
		XdmValue * xdmValue = NULL;
278
		if(proc->environ->env->IsInstanceOf(result, atomicValueClass)           == JNI_TRUE) {
278
		if(environ->env->IsInstanceOf(result, atomicValueClass)           == JNI_TRUE) {
279 279
				xdmValue = new XdmAtomicValue(result);
280 280
				
281 281

  
282
			} else if(proc->environ->env->IsInstanceOf(result, nodeClass)           == JNI_TRUE) {
282
			} else if(environ->env->IsInstanceOf(result, nodeClass)           == JNI_TRUE) {
283 283
				xdmValue = new XdmNode(result);
284 284

  
285
			} else if (proc->environ->env->IsInstanceOf(result, functionItemClass)           == JNI_TRUE) {
285
			} else if (environ->env->IsInstanceOf(result, functionItemClass)           == JNI_TRUE) {
286 286
				return NULL;
287 287
			} else {
288 288
				xdmValue = new XdmValue(result);
......
294 294
			if(proc->exception != NULL) {
295 295
				delete proc->exception;
296 296
			}
297
			proc->exception = proc->checkForExceptionCPP(proc->environ->env, cppClass, NULL);
297
			proc->exception = proc->checkForExceptionCPP(environ->env, cppClass, NULL);
298 298
			proc->exceptionClear();
299 299
	   		
300 300
     		} 
......
305 305

  
306 306
    const char * XQueryProcessor::executeQueryToString(const char * infilename, const char * query){
307 307
	setProperty("resources", proc->getResourcesDirectory()); 
308
 jmethodID mID = (jmethodID)proc->environ->env->GetMethodID (cppClass,"executeQueryToString", "(Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;");
308
 jmethodID mID = (jmethodID)environ->env->GetMethodID (cppClass,"executeQueryToString", "(Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;");
309 309
 if (!mID) {
310 310
        cout<<"Error: MyClassInDll."<<"executeQueryToString"<<" not found\n"<<endl;
311 311
    } else {
......
317 317
	if(infilename!= NULL) size++;
318 318
	if(size >0) {
319 319
	   int i=0;
320
           jclass objectClass = lookForClass(proc->environ->env, "java/lang/Object");
321
	   jclass stringClass = lookForClass(proc->environ->env, "java/lang/String");
322
	   objectArray = proc->environ->env->NewObjectArray( (jint)size, objectClass, 0 );
323
	   stringArray = proc->environ->env->NewObjectArray( (jint)size, stringClass, 0 );
320
           jclass objectClass = lookForClass(environ->env, "java/lang/Object");
321
	   jclass stringClass = lookForClass(environ->env, "java/lang/String");
322
	   objectArray = environ->env->NewObjectArray( (jint)size, objectClass, 0 );
323
	   stringArray = environ->env->NewObjectArray( (jint)size, stringClass, 0 );
324 324

  
325 325
	   if(query!= NULL) {
326
	     proc->environ->env->SetObjectArrayElement( stringArray, i, proc->environ->env->NewStringUTF("qs") );
327
     	     proc->environ->env->SetObjectArrayElement( objectArray, i, proc->environ->env->NewStringUTF(query));
326
	     environ->env->SetObjectArrayElement( stringArray, i, environ->env->NewStringUTF("qs") );
327
     	     environ->env->SetObjectArrayElement( objectArray, i, environ->env->NewStringUTF(query));
328 328
	     i++;	
329 329
	   }
330 330
	   if(infilename!= NULL) {
331
	     proc->environ->env->SetObjectArrayElement( stringArray, i, proc->environ->env->NewStringUTF("s") );
332
     	     proc->environ->env->SetObjectArrayElement( objectArray, i, proc->environ->env->NewStringUTF(infilename));
331
	     environ->env->SetObjectArrayElement( stringArray, i, environ->env->NewStringUTF("s") );
332
     	     environ->env->SetObjectArrayElement( objectArray, i, environ->env->NewStringUTF(infilename));
333 333
	     i++;	
334 334
	   }
335 335
	   for(map<std::string, XdmValue* >::iterator iter=parameters.begin(); iter!=parameters.end(); ++iter, i++) {
336
	     proc->environ->env->SetObjectArrayElement( stringArray, i, proc->environ->env->NewStringUTF( (iter->first).c_str() ) );
337
		bool checkCast = proc->environ->env->IsInstanceOf((iter->second)->getUnderlyingValue(proc), lookForClass(proc->environ->env, "net/sf/saxon/option/cpp/XdmValueForCpp") );
336
	     environ->env->SetObjectArrayElement( stringArray, i, environ->env->NewStringUTF( (iter->first).c_str() ) );
337
		bool checkCast = environ->env->IsInstanceOf((iter->second)->getUnderlyingValue(proc), lookForClass(environ->env, "net/sf/saxon/option/cpp/XdmValueForCpp") );
338 338
		if(( (bool)checkCast)==false ){
339 339
			failure = "FAILURE in  array of XdmValueForCpp";
340 340
		} 
341
	     proc->environ->env->SetObjectArrayElement( objectArray, i, (jobject)((iter->second)->getUnderlyingValue(proc)) );
341
	     environ->env->SetObjectArrayElement( objectArray, i, (jobject)((iter->second)->getUnderlyingValue(proc)) );
342 342
	   }
343 343
  	   for(map<std::string, std::string >::iterator iter=properties.begin(); iter!=properties.end(); ++iter, i++) {
344
	     proc->environ->env->SetObjectArrayElement( stringArray, i, proc->environ->env->NewStringUTF( (iter->first).c_str()  ));
345
	     proc->environ->env->SetObjectArrayElement( objectArray, i, (jobject)(proc->environ->env->NewStringUTF((iter->second).c_str())) );
344
	     environ->env->SetObjectArrayElement( stringArray, i, environ->env->NewStringUTF( (iter->first).c_str()  ));
345
	     environ->env->SetObjectArrayElement( objectArray, i, (jobject)(environ->env->NewStringUTF((iter->second).c_str())) );
346 346
	   }
347 347
	}
348 348

  
349
	  jstring result = (jstring)(proc->environ->env->CallObjectMethod(cppXQ, mID, proc->environ->env->NewStringUTF(cwdXQ.c_str()), stringArray, objectArray ));
350
	  proc->environ->env->DeleteLocalRef(objectArray);
351
	  proc->environ->env->DeleteLocalRef(stringArray);
349
	  jstring result = (jstring)(environ->env->CallObjectMethod(cppXQ, mID, environ->env->NewStringUTF(cwdXQ.c_str()), stringArray, objectArray ));
350
	  environ->env->DeleteLocalRef(objectArray);
351
	  environ->env->DeleteLocalRef(stringArray);
352 352

  
353 353
	  if(result) {
354
             const char * str = proc->environ->env->GetStringUTFChars(result, NULL);
354
             const char * str = environ->env->GetStringUTFChars(result, NULL);
355 355
            //return "result should be ok";            
356 356
	    return str;
357 357
	   } else if(exceptionOccurred()) {
358 358
			if(proc->exception != NULL) {
359 359
				delete proc->exception;
360 360
			}
361
			proc->exception = proc->checkForExceptionCPP(proc->environ->env, cppClass, NULL);
361
			proc->exception = proc->checkForExceptionCPP(environ->env, cppClass, NULL);
362 362
			proc->exceptionClear();
363 363
	   		
364 364
     		}
......
401 401
	if(proc->exception != NULL) {
402 402
		delete proc->exception;
403 403
		proc->exception = NULL;	
404
		proc->environ->env->ExceptionClear();
404
		environ->env->ExceptionClear();
405 405
	}
406 406

  
407 407
   
......
426 426

  
427 427
const char* XQueryProcessor::checkException(){
428 428
	/*if(proc->exception == NULL) {
429
		proc->exception = proc->checkForException(proc->environ->env, cppClass, cppXQ);
429
		proc->exception = proc->checkForException(environ->env, cppClass, cppXQ);
430 430
	}
431 431
        return proc->exception;*/
432
	return checkForException(*(proc->environ), cppClass, cppXQ);
432
	return checkForException(*(environ), cppClass, cppXQ);
433 433
}
434 434

  
435 435

  
latest9.6/hec/Saxon.C.API/XdmAtomicValue.cpp
30 30
	}
31 31
	
32 32
	if(proc != NULL) {
33
		jclass xdmUtilsClass = lookForClass(proc->environ->env, "net/sf/saxon/option/cpp/XdmUtils");
34
		jmethodID xmID = (jmethodID) proc->environ->env->GetStaticMethodID(xdmUtilsClass,"getPrimitiveTypeName",
33
		jclass xdmUtilsClass = lookForClass(environ->env, "net/sf/saxon/option/cpp/XdmUtils");
34
		jmethodID xmID = (jmethodID) environ->env->GetStaticMethodID(xdmUtilsClass,"getPrimitiveTypeName",
35 35
					"(Lnet/sf/saxon/s9api/XdmAtomicValue;)Ljava/lang/String;");
36 36
		if (!xmID) {
37 37
			std::cerr << "Error: SaxonDll." << "getPrimitiveTypeName"
38 38
				<< " not found\n" << std::endl;
39 39
			return "";
40 40
		}
41
		jstring result = (jstring)(proc->environ->env->CallStaticObjectMethod(xdmUtilsClass, xmID,value->xdmvalue));
41
		jstring result = (jstring)(environ->env->CallStaticObjectMethod(xdmUtilsClass, xmID,value->xdmvalue));
42 42
		if(result) {
43
			const char * stri = proc->environ->env->GetStringUTFChars(result,
43
			const char * stri = environ->env->GetStringUTFChars(result,
44 44
					NULL);
45 45
		
46
		//proc->environ->env->DeleteLocalRef(result);
46
		//environ->env->DeleteLocalRef(result);
47 47

  
48 48
			return stri;
49 49
		}
......
55 55

  
56 56
    bool XdmAtomicValue::getBooleanValue(){
57 57
	if(proc != NULL) {
58
		jclass xdmNodeClass = lookForClass(proc->environ->env, "net/sf/saxon/s9api/XdmAtomicValue");
59
		jmethodID bmID = (jmethodID) proc->environ->env->GetMethodID(xdmNodeClass,
58
		jclass xdmNodeClass = lookForClass(environ->env, "net/sf/saxon/s9api/XdmAtomicValue");
59
		jmethodID bmID = (jmethodID) environ->env->GetMethodID(xdmNodeClass,
60 60
					"getBooleanValue",
61 61
					"()Z");
62 62
		if (!bmID) {
......
64 64
				<< " not found\n" << std::endl;
65 65
			return false;
66 66
		} else {
67
			jboolean result = (jboolean)(proc->environ->env->CallBooleanMethod(value->xdmvalue, bmID));
67
			jboolean result = (jboolean)(environ->env->CallBooleanMethod(value->xdmvalue, bmID));
68 68
			if(result) {
69 69
				return (bool)result;
70 70
			}
......
77 77

  
78 78
    double XdmAtomicValue::getDoubleValue(){
79 79
	if(proc != NULL) {
80
		jclass xdmNodeClass = lookForClass(proc->environ->env, "net/sf/saxon/s9api/XdmAtomicValue");
81
		jmethodID bmID = (jmethodID) proc->environ->env->GetMethodID(xdmNodeClass,
80
		jclass xdmNodeClass = lookForClass(environ->env, "net/sf/saxon/s9api/XdmAtomicValue");
81
		jmethodID bmID = (jmethodID) environ->env->GetMethodID(xdmNodeClass,
82 82
					"getDoubleValue",
83 83
					"()D");
84 84
		if (!bmID) {
......
86 86
				<< " not found\n" << std::endl;
87 87
			return 0;
88 88
		} else {
89
			jdouble result = (jdouble)(proc->environ->env->CallDoubleMethod(value->xdmvalue, bmID));
89
			jdouble result = (jdouble)(environ->env->CallDoubleMethod(value->xdmvalue, bmID));
90 90
			if(result) {
91 91
				return (double)result;
92 92
			}
93
checkForException(*(proc->environ), xdmNodeClass, NULL);
93
checkForException(*(environ), xdmNodeClass, NULL);
94 94
		}
95 95
	} else {
96 96
		std::cerr<<"Error: Processor not set in XdmAtomicValue"<<std::endl;
......
109 109

  
110 110
    long XdmAtomicValue::getLongValue(){
111 111
		if(proc != NULL) {
112
		jclass xdmNodeClass = lookForClass(proc->environ->env, "net/sf/saxon/s9api/XdmAtomicValue");
113
		jmethodID bmID = (jmethodID) proc->environ->env->GetMethodID(xdmNodeClass,
112
		jclass xdmNodeClass = lookForClass(environ->env, "net/sf/saxon/s9api/XdmAtomicValue");
113
		jmethodID bmID = (jmethodID) environ->env->GetMethodID(xdmNodeClass,
114 114
					"getLongValue",
115 115
					"()J");
116 116
		if (!bmID) {
......
118 118
				<< " not found\n" << std::endl;
119 119
			return 0;
120 120
		} else {
121
			jlong result = (jlong)(proc->environ->env->CallObjectMethod(value->xdmvalue, bmID));
121
			jlong result = (jlong)(environ->env->CallObjectMethod(value->xdmvalue, bmID));
122 122
			if(result) {
123 123
				return (long)result;
124 124
			}
latest9.6/hec/Saxon.C.API/XdmItem.h
27 27
    virtual ~XdmItem(){
28 28
//std::cerr<<std::endl<<"XdmItem destructor called, refCount"<<getRefCount()<<std::endl;
29 29
	if(value !=NULL && proc != NULL) {
30
			proc->environ->env->DeleteLocalRef(value->xdmvalue);
30
			environ->env->DeleteLocalRef(value->xdmvalue);
31 31
	}
32 32
	free(value);
33 33
    }
latest9.6/hec/Saxon.C.API/XdmNode.cpp
31 31
		return nodeName;
32 32
	}
33 33
	XDM_NODE_KIND kind = getNodeKind();
34
 	jclass xdmUtilsClass = lookForClass(proc->environ->env, "net/sf/saxon/option/cpp/XdmUtils");
35
	jmethodID xmID = (jmethodID) proc->environ->env->GetStaticMethodID(xdmUtilsClass,"getNodeName",
34
 	jclass xdmUtilsClass = lookForClass(environ->env, "net/sf/saxon/option/cpp/XdmUtils");
35
	jmethodID xmID = (jmethodID) environ->env->GetStaticMethodID(xdmUtilsClass,"getNodeName",
36 36
					"(Lnet/sf/saxon/s9api/XdmNode;)Ljava/lang/String;");
37 37
	switch (kind) {
38 38
            case DOCUMENT:
......
48 48
			std::cerr << "Error: MyClassInDll." << "getNodeName"<< " not found\n" << std::endl;
49 49
			return NULL;
50 50
		} else {
51
			jstring result = (jstring)(proc->environ->env->CallStaticObjectMethod(xdmUtilsClass, xmID, value->xdmvalue));
51
			jstring result = (jstring)(environ->env->CallStaticObjectMethod(xdmUtilsClass, xmID, value->xdmvalue));
52 52
			if(!result) {
53 53
				return NULL;
54 54
			} else {
55
				nodeName = proc->environ->env->GetStringUTFChars(result, NULL);
55
				nodeName = environ->env->GetStringUTFChars(result, NULL);
56 56
				return nodeName;
57 57
			} 
58 58
		}
......
69 69
		return baseURI;
70 70
	}
71 71

  
72
	jclass xdmNodeClass = lookForClass(proc->environ->env, "net/sf/saxon/s9api/XdmNode");
73
	jmethodID bmID = (jmethodID) proc->environ->env->GetMethodID(xdmNodeClass,
72
	jclass xdmNodeClass = lookForClass(environ->env, "net/sf/saxon/s9api/XdmNode");
73
	jmethodID bmID = (jmethodID) environ->env->GetMethodID(xdmNodeClass,
74 74
					"getBaseURI",
75 75
					"()Ljava/net/URI;");
76 76
	if (!bmID) {
......
78 78
				<< " not found\n" << std::endl;
79 79
		return NULL;
80 80
	} else {
81
		jobject nodeURIObj = (proc->environ->env->CallObjectMethod(value->xdmvalue, bmID));
81
		jobject nodeURIObj = (environ->env->CallObjectMethod(value->xdmvalue, bmID));
82 82
		if(!nodeURIObj){
83 83
			return NULL;
84 84
		} else {
85
			jclass URIClass = lookForClass(proc->environ->env, "java/net/URI");
86
			jmethodID strMID = (jmethodID) proc->environ->env->GetMethodID(URIClass,
85
			jclass URIClass = lookForClass(environ->env, "java/net/URI");
86
			jmethodID strMID = (jmethodID) environ->env->GetMethodID(URIClass,
87 87
					"toString",
88 88
					"()Ljava/lang/String;");
89 89
			if(strMID){
90 90
				jstring result = (jstring)(
91
				proc->environ->env->CallObjectMethod(nodeURIObj, strMID));
92
				baseURI = proc->environ->env->GetStringUTFChars(result,
91
				environ->env->CallObjectMethod(nodeURIObj, strMID));
92
				baseURI = environ->env->GetStringUTFChars(result,
93 93
					NULL);
94 94
			
95 95
				return baseURI;
......
106 106

  
107 107
    XdmNode* XdmNode::getParent(){
108 108
	if(parent == NULL && proc!= NULL) {
109
		jclass xdmNodeClass = lookForClass(proc->environ->env, "net/sf/saxon/s9api/XdmNode");
110
		jmethodID bmID = (jmethodID) proc->environ->env->GetMethodID(xdmNodeClass,
109
		jclass xdmNodeClass = lookForClass(environ->env, "net/sf/saxon/s9api/XdmNode");
110
		jmethodID bmID = (jmethodID) environ->env->GetMethodID(xdmNodeClass,
111 111
					"getParent",
112 112
					"()Lnet/sf/saxon/s9api/XdmNode;");
113 113
		if (!bmID) {
......
115 115
				<< " not found\n" << std::endl;
116 116
			return NULL;
117 117
		} else {
118
			jobject nodeObj = (proc->environ->env->CallObjectMethod(value->xdmvalue, bmID));
118
			jobject nodeObj = (environ->env->CallObjectMethod(value->xdmvalue, bmID));
119 119
			if(nodeObj) {
120 120
				parent = new XdmNode(NULL, nodeObj, UNKNOWN);
121 121
				parent->setProcessor(proc);
......
133 133
    const char* XdmNode::getAttributeValue(const char *str){
134 134

  
135 135
	if(str == NULL) { return NULL;}
136
	jclass xdmUtilsClass = lookForClass(proc->environ->env, "net/sf/saxon/option/cpp/XdmUtils");
137
	jmethodID xmID = (jmethodID) proc->environ->env->GetStaticMethodID(xdmUtilsClass,"getAttributeValue",
136
	jclass xdmUtilsClass = lookForClass(environ->env, "net/sf/saxon/option/cpp/XdmUtils");
137
	jmethodID xmID = (jmethodID) environ->env->GetStaticMethodID(xdmUtilsClass,"getAttributeValue",
138 138
					"(Lnet/sf/saxon/s9api/XdmNode;Ljava/lang/String;)Ljava/lang/String;");
139 139
	if (!xmID) {
140 140
			std::cerr << "Error: SaxonDll." << "getAttributeValue"
......
144 144
	if(str == NULL) {
145 145
		return NULL;
146 146
	}
147
	jstring eqname = proc->environ->env->NewStringUTF(str);
147
	jstring eqname = environ->env->NewStringUTF(str);
148 148

  
149
	jstring result = (jstring)(proc->environ->env->CallStaticObjectMethod(xdmUtilsClass, xmID,value->xdmvalue, eqname));
150
	proc->environ->env->DeleteLocalRef(eqname);
151
	checkForException(*(proc->environ), xdmUtilsClass, (jobject)result);//Remove code
149
	jstring result = (jstring)(environ->env->CallStaticObjectMethod(xdmUtilsClass, xmID,value->xdmvalue, eqname));
150
	environ->env->DeleteLocalRef(eqname);
151
	checkForException(*(environ), xdmUtilsClass, (jobject)result);//Remove code
152 152
	if(result) {
153
		const char * stri = proc->environ->env->GetStringUTFChars(result,
153
		const char * stri = environ->env->GetStringUTFChars(result,
154 154
					NULL);
155 155
		
156
		//proc->environ->env->DeleteLocalRef(result);
156
		//environ->env->DeleteLocalRef(result);
157 157

  
158 158
		return stri;
159 159
	} else {
......
165 165

  
166 166
    XdmNode** XdmNode::getAttributeNodes(){
167 167
	if(attrValues == NULL) {
168
		jclass xdmUtilsClass = lookForClass(proc->environ->env, "net/sf/saxon/option/cpp/XdmUtils");
169
		jmethodID xmID = (jmethodID) proc->environ->env->GetStaticMethodID(xdmUtilsClass,"getAttributeNodes",
168
		jclass xdmUtilsClass = lookForClass(environ->env, "net/sf/saxon/option/cpp/XdmUtils");
169
		jmethodID xmID = (jmethodID) environ->env->GetStaticMethodID(xdmUtilsClass,"getAttributeNodes",
170 170
					"(Lnet/sf/saxon/s9api/XdmNode;)[Lnet/sf/saxon/s9api/XdmNode;");
171
		jobjectArray results = (jobjectArray)(proc->environ->env->CallStaticObjectMethod(xdmUtilsClass, xmID, 
171
		jobjectArray results = (jobjectArray)(environ->env->CallStaticObjectMethod(xdmUtilsClass, xmID, 
172 172
		value->xdmvalue));
173 173
		if(results == NULL) {
174 174
			return NULL;	
175 175
		}
176
		int sizex = proc->environ->env->GetArrayLength(results);
176
		int sizex = environ->env->GetArrayLength(results);
177 177
		attrCount = sizex;
178 178
		if(sizex>0) {	
179 179
			attrValues =  new XdmNode*[sizex];
180 180
			XdmNode * tempNode =NULL;
181 181
			for (int p=0; p < sizex; ++p){
182
				jobject resulti = proc->environ->env->GetObjectArrayElement(results, p);
182
				jobject resulti = environ->env->GetObjectArrayElement(results, p);
183 183
				tempNode = new XdmNode(this, resulti, ATTRIBUTE);
184 184
				tempNode->setProcessor(proc);
185 185
				this->incrementRefCount();
......
192 192

  
193 193
    int XdmNode::getAttributeCount(){
194 194
	if(attrCount == -1 && proc!= NULL) {
195
		jclass xdmUtilsClass = lookForClass(proc->environ->env, "net/sf/saxon/option/cpp/XdmUtils");
196
		jmethodID xmID = (jmethodID) proc->environ->env->GetStaticMethodID(xdmUtilsClass,"getAttributeCount",
195
		jclass xdmUtilsClass = lookForClass(environ->env, "net/sf/saxon/option/cpp/XdmUtils");
196
		jmethodID xmID = (jmethodID) environ->env->GetStaticMethodID(xdmUtilsClass,"getAttributeCount",
197 197
					"(Lnet/sf/saxon/s9api/XdmNode;)I");
198 198
		
199 199
		if (!xmID) {
......
201 201
				<< " not found\n" << std::endl;
202 202
			return 0;
203 203
		}
204
		jint result = (jlong)(proc->environ->env->CallStaticObjectMethod(xdmUtilsClass, xmID,
204
		jint result = (jlong)(environ->env->CallStaticObjectMethod(xdmUtilsClass, xmID,
205 205
		value->xdmvalue));
206 206

  
207 207
		attrCount =(int)result;
......
211 211

  
212 212
    int XdmNode::getChildCount(){
213 213
	if(childCount == -1 && proc!= NULL) {
214
		jclass xdmUtilsClass = lookForClass(proc->environ->env, "net/sf/saxon/option/cpp/XdmUtils");
215
		jmethodID xmID = (jmethodID) proc->environ->env->GetStaticMethodID(xdmUtilsClass,"getChildCount",
214
		jclass xdmUtilsClass = lookForClass(environ->env, "net/sf/saxon/option/cpp/XdmUtils");
215
		jmethodID xmID = (jmethodID) environ->env->GetStaticMethodID(xdmUtilsClass,"getChildCount",
216 216
					"(Lnet/sf/saxon/s9api/XdmNode;)I");
217 217
		
218 218
		if (!xmID) {
......
220 220
				<< " not found\n" << std::endl;
221 221
			return 0;
222 222
		}
223
		jint result = (jlong)(proc->environ->env->CallStaticObjectMethod(xdmUtilsClass, xmID,
223
		jint result = (jlong)(environ->env->CallStaticObjectMethod(xdmUtilsClass, xmID,
224 224
		value->xdmvalue));
225 225

  
226 226
		childCount =(int)result;
......
231 231
    XdmNode** XdmNode::getChildren(){
232 232

  
233 233
	if(children == NULL && proc!= NULL) {
234
		jclass xdmUtilsClass = lookForClass(proc->environ->env, "net/sf/saxon/option/cpp/XdmUtils");
235
		jmethodID xmID = (jmethodID) proc->environ->env->GetStaticMethodID(xdmUtilsClass,"getChildren",
234
		jclass xdmUtilsClass = lookForClass(environ->env, "net/sf/saxon/option/cpp/XdmUtils");
235
		jmethodID xmID = (jmethodID) environ->env->GetStaticMethodID(xdmUtilsClass,"getChildren",
236 236
					"(Lnet/sf/saxon/s9api/XdmNode;)[Lnet/sf/saxon/s9api/XdmNode;");
237 237
		
238 238
		if (!xmID) {
......
240 240
				<< " not found\n" << std::endl;
241 241
			return NULL;
242 242
		}
243
		jobjectArray results = (jobjectArray)(proc->environ->env->CallStaticObjectMethod(xdmUtilsClass, xmID, 
243
		jobjectArray results = (jobjectArray)(environ->env->CallStaticObjectMethod(xdmUtilsClass, xmID, 
244 244
		value->xdmvalue));
245
		int sizex = proc->environ->env->GetArrayLength(results);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff