aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/gluegen/CMethodBindingEmitter.java
Commit message (Collapse)AuthorAgeFilesLines
* Bug 1481 - Hide [ArgumentIs]PascalString argument's lengthSven Gothel2023-12-021-11/+46
| | | | | | | | Native pascal strings shall be just treated as normal Java strings on the Java side. Hence drop the length parameter across generated API, i.e. - C Function bindings - Java Callbacks
* CMethodBindingEmitter.emitBodyPassCArguments(): Either pass ↵Sven Gothel2023-08-041-2/+4
| | | | | | | | STRING_CHARS_PREFIX or javaCallbackEmitter.emitCOptArgumentSuffix(..) We only produce one variant in code. Use case: String type as userParam (barely tested and not useful)
* JavaCallbackEmitter.emitCSetFuncPreCall(): Drop redundant arg ↵Sven Gothel2023-08-031-1/+1
| | | | | | | 'CMethodBindingEmitter jcbFuncCMethodEmitter', use local 'info.cbFuncBinding' Was added in commit ad69716fda64b517c33ed847c4b215ea398aac99 'callback without userData', while adding ad-hoc compound conversion.
* JavaCallbackEmitter.{emitCSetFuncPreCall, emitCAdditionalCode, ↵Sven Gothel2023-08-031-8/+8
| | | | | | | | | | | | | | emitJavaCallbackBodyPassJavaArguments}(): Fix exclusion of ad-hoc compound conversion for userParam Passed CMethodBindingEmitter denotes the callback-function, including the binding. The new iteration to handle the ad-hoc compound conversion, introduced in commit ad69716fda64b517c33ed847c4b215ea398aac99 'callback without userData', iterates over the callback-function argument list. Hence it shall only exclude the ad-hoc compound conversion if index != info.cbFuncUserParamIdx. Dropping the addition exclusion 'i != info.setFuncUserParamIdx'.
* CMethodBindingEmitter.emitBodyMapCToJNIType(..): Add proper intendation to ↵Sven Gothel2023-08-031-9/+13
| | | | NIO ByteBuffer generation (isNIOBuffer || isCompoundTypeWrapper)
* feat(callbackGenerator): Add basic management of callback without userDataMathieu Féry2023-07-311-1/+1
|
* GlueGen: Add 'PascalString' string semantics (length + value-ptr), added ↵Sven Gothel2023-07-051-3/+27
| | | | | | | | | | | | | | | | | | | | | | | | | prelim code for JavaCallback use-case emitBodyMapCToJNIType() It is common in toolkit APIs that a string might not be passed as a 'nul' terminated (EOS) C string, but as a Pascal string with a given length argument. A C string is specied as ArgumentIsString alEventCallbackInject 3 while allowing multiple indices .. A Pascal string can be specified as ArgumentIsPascalString ALEVENTPROCSOFT 3 4 while allowing multiple indice-tuples for length and value .. The tuple consist of the length agrument-index first (usually an int) followed by the value argument-index (usually a 'char*'). +++ CMethodBindingEmitter.emitBodyMapCToJNIType(), where PascalString is implemented, is currently being used for - JNI return statement (no PascalString impact possible) - JavaCallback C type -> JNI type, PascalString impacting
* GlueGen JavaCallback: Revised: Static Java callback dispatcher, dropping ↵Sven Gothel2023-07-041-296/+59
| | | | | | | | | | | | | | | | | | | | | | | | | native heap, support Struct UserParam ... Implementation now generates a static Java callback dispatcher for each defined SetCallbackFunction, which gets invoked by the generated native static counterpart with all arguments required. The static callback utilizes its own synchronization for thread-safety and fetches the required data set stored at SetCallbackFunction to dispatch the call to the users' CallbackFunction. In case the callback has been removed already, the static callback simply bails out quietly. The native code does not create, release or manage heap memory and therefore is considered safe. +++ Further Struct Type UserParam are now supported including Heterogeneous UserParam mapping (read GlueGen_Mapping.*). +++ Cleaned up code by extracting all JavaCallback emitter code into JavaCallbackEmitter class in one place, leaving JavaMethodbindingEmitter and CMethodbindingEmitter mostly in their original stage (non-convoluted). In this regard, I had to refactor a few function, i.e. moving CMethodbindingEmitter.getJNIMangledArg(..) into JavaType.appendDescriptor(..) and JavaType.appendJNIDescriptor(..) while reusing the toJNIMethodDescriptor(..) conversion. Test4JavaCallback covers and passes all cases.
* GlueGen JavaCallback: Unify native 'T_JavaCallbackGlueData' typedef structcallback_jniuserparamproxySven Gothel2023-07-021-11/+7
|
* GlueGen JavaCallback: CMethodBindingEmitter: Check, describe & clear ↵Sven Gothel2023-07-021-0/+5
| | | | | | exception if occurring - we must assume async off-thread source in general Covered by unit tests now
* GlueGen JavaCallback: CMethodBindingEmitter: Check lockObj for NULL before ↵Sven Gothel2023-07-021-0/+1
| | | | GetObjectRefType(), avoid certain (older) Hotspot issues
* CMethodBindingEmitter JavaCallback: Use a friendly readable basename for errorsSven Gothel2023-07-021-16/+19
|
* GlueGen JavaCallback: Native Callback: Reduce 'look-ahead' of ↵Sven Gothel2023-07-021-9/+9
| | | | read-after-free to critical lockObj only
* GlueGen JavaCallback: Document native callback use-after-free potential ↵Sven Gothel2023-07-021-1/+6
| | | | (caught), zero-mem @ release
* GlueGen JavaCallback: Native callback: Check ObjectRef validity and ↵Sven Gothel2023-07-021-9/+44
| | | | synchronize (MonitorEnter/Exit) with same Object of Java impl. -> thread safe
* GlueGen JavaCallback: Only produce default 'Key' class if keys are used, ↵Sven Gothel2023-07-011-1/+1
| | | | | | | | | | | expose 'Key' to public and use it. Expose release*() and get*Keys() methods Further we use a dedicated lock Object used in the Java implementation. TODO: Native static callback dispatch code shall - (also) acquire the lock - handle case where the data has been released already to render this solution thread-safe and data-race free
* GlueGen JavaCallback: Resolve key mapping of callback and associated ↵Sven Gothel2023-06-301-15/+17
| | | | | | | | | | | | | | | | resources via 'JavaCallbackKey' config and custom `SetCallback-KeyClass` Updated unit test and doc accordingly. Unit tests handle OpenAL's AL_SOFT_callback_buffer and AL_SOFT_events. Tested global scope (no key, default) and 1 key (default) and 1 key (custom class). Added more query functions, which all only take the `SetCallbackFunction` key arguments as specified. Cleaned up JavaCallback* config class field naminig scheme. Added 'synchronized (..Map) { }' block in crucial `SetCallbackFunction`, rendering implementation thread safe.
* GlueGen FunctionType/MethodBinding: get*ParameterList(): Use a more flexible ↵Sven Gothel2023-06-301-2/+2
| | | | way via a ParameterConsumer visitor, also usable for other iterative parameter generator
* GlueGen JavaCallback: 1st Working Draft: Changed 'JavaCallbackDef' config, ↵Sven Gothel2023-06-291-2/+186
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | added code generation incl. native to Java dispatch and resource management Tested via Test4JavaCallback.java (using test2.[hc]). Please read the GlueGen_Mapping.md as well as Test4JavaCallback.java . +++ Some implementation details: JavaConfiguration maps JavaCallbackDef to JavaCallback set-function and maintains a list. JavaCallbackDef itself holds all configured details. JavaConfiguration also maps JavaCallbackInfo to JavaCallback set-function. JavaCallbackInfo itself holds all compile time information, as produced by JavaEmitter.beginFunctions(..). This extends JavaCallbackDef and avoid repetetive computation for the callback-function-type and its MethodBinding, parameter indices for the callback interface and userParam, etc. CMethodBindingEmitter: Native callback to Java dispatch - The JavaCallback setter function creates a native 'UserParam' struct instance, which holds the callback-interface-jobject, its callback-jmethodID and the userParam-jobject for invocation of the actual JavaCallback interface method. - To produce the C-Type -> JNI-Type conversion, An internal CMethodBindingEmitter instance for the native-callback function binding is created inside the CMethodBindingEmitter of the callback setter method. It is being used to map the types to JNI within the generated native callback function, passed to the actual JavaCallback method. JavaMethodBindingEmitter: Native callback to Java dispatch - The JavaCallbacl setter passes the callback-interface-object, the userParam-object and the callback-method-signature (to have the native method retrieve the jmethodID). - It receives the native pointer of the native `UserParam` struct instance, which gets mapped to the userParam-object. (*TODO: Refine ownership + release*).
* GlueGen CMethodBindingEmitter: Refactor emitBodyReturnResult() -> ↵Sven Gothel2023-06-291-98/+148
| | | | emitBodyMapCToJNIType(): Reuse to converting any C-type argument to java JNI type (i.e. native callback to JavaCallback)
* GlueGen JavaCallback: Expose getJNIMethodDescriptor() for JNI mangled method ↵Sven Gothel2023-06-261-3/+1
| | | | names, used in CMethodBindingEmitter; Use JavaCallback's function-pointer-type capital-name as simple-class-name and its FQN for JNI resolution.
* GlueGen JavaCallback: Use new JavaType nature 'named-class', denoting the ↵Sven Gothel2023-06-261-0/+4
| | | | | | | | | | | | generated callback interface mapping the callback function. This passes the jobject for the callback function/interface and the userParam (from 'void*') down to the native implementation. TODO: Add specific native implementation for JavaCallback, wrapping the jobject's into a native struct as user-param and a universal C-function as the native callback to dispatch the call to the java method with known arguments.
* GlueGen: Expose CMethodBindingEmitter.getJNIMangledArgs() as a public static ↵Sven Gothel2023-06-251-14/+24
| | | | to be reusable
* GlueGen: Type: Have get{Base,Target}Type() stop at isFunctionPointer(), ↵Sven Gothel2023-06-231-8/+3
| | | | | | | | | | enhance API doc; Add getArrayBaseOrPointerTargetType() and getTargetFunction() Added getArrayBaseOrPointerTargetType() returns getBaseType() for arrays or getTargetType() for pointer, i.e. stops traversing if an elementType is a pointer and returns the elementType as target-type. This resolves 'int* intPtrArray[10]', but also simplifies all cases of 'int** intPtrPtr' and 'int intPtr[10]' etc. Since get{Base,Target}Type() returns the functionPointer, getTargetFunction() allows to retrieve the actual target function type.
* GlueGen Type: Use virt getTargetType() for ArrayType dropping ↵Sven Gothel2023-06-191-4/+4
| | | | getElementType(); Rename getBase{Elem ->}Type() to align with getTargetType()
* GlueGen Struct [3]: Adopt to CodeUnit Abstraction (replacing plain ↵Sven Gothel2023-06-161-346/+335
| | | | PrintWriter...)
* Bug 1144 - Add 'DelegateImplementation': Requires own MethodBinding for ↵Sven Gothel2015-03-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | delegates impl. / Adding ReturnsOpaque - DelegateImplementation requires own MethodBinding for delegates impl. The delegation name must be included within the FunctionSymbol's aliases _only_ for implementations, where delegation applies. This allows all subsequent type/cfg checks to hit on AliasedSymbol! Hence we need to create individual MethodBinding instances for interfaces and public/private implementations. - Adding ReturnsOpaque Configuration: ReturnsOpaque <Primitive Java Type> <Function Name> This feature is necessary to achieve 'Opaque' functionality for function's return type - instead of types in general. - Fix AliasedSymbolImpl copy-ctor, i.e. this.name = o.name !
* Bug 1144 - Add 'DelegateImplementation': Cleanup ↵Sven Gothel2015-03-111-10/+14
| | | | | | | | MethodBinding/FunctionBinding Semantics - Clarify name semantics: name -> [interfaceName, implName, nativeName] - JavaMethodBindingEmitter: Refine native identity via isNativeMethod + isPrivateNativeMethod - ProcAddressEmitter: Remove hack whether we need to wrap .. use isNativeMethod + isPrivateNativeMethod
* Bug 1134 - Fix CMethodBindingEmitter return type '_res' qualifiers (part 2)Sven Gothel2015-03-091-1/+7
| | | | | | | | | Commit 414a0146660cadd35d5ae270f7f819717e9c7374 removed the const/volatile of the local return variable. This change also casts the function calling result to the same - hence removing a possible c-compiler warning of dropping qualifier const.
* Bug 1134 - Fix CMethodBindingEmitter return type '_res' qualifiersSven Gothel2015-03-091-2/+3
| | | | | We cannot have the local variable holding the return type 'const' and assign a value to it later.
* Bug 1134 - Fix IntType 'unsigned'; Type: Use copy-ctor instead of Clonable, ..Sven Gothel2015-03-091-2/+2
| | | | | | | | | | | | - Fix IntType 'unsigned' - Need to handle 'unsigned' for typedef and !typedef, when exposing 'unsigned' for code emission. - Consider IntType.typedefUnsigned in hash/equals - Type: Use copy-ctor instead of Clonable enhancing strong typing. - add 'Type clone(final ASTLocusTag newLoc)' - Consider Type.typedefCVAttributes in hash/equals
* Bug 1134 - Logging's formatter now takes care of Type -> getDebugString() ↵Sven Gothel2015-03-081-1/+1
| | | | | | | when desired, not at 'log' call Removes load to assemble the getDebugString() of Type and JavaType when invoking log function. Note: the log may be skipped if log-level is not reached.
* Bug 1134 - Use ASTLocationTag in Logging (PCPP, Emitter); Refine ↵Sven Gothel2015-03-081-8/+8
| | | | | | | | ASTLocationTag log/exception formatting. Since commit eca019cdea4017227e951d8a9eb30cb34fca4a07, we have ASTLocationTag available. Hence use it for all logging purposes and emit a standard compiler output, which shall be parsable by other tools.
* Bug 1134 - Fix IntType: Add getCName(..) for proper C-type code; Fix its ↵Sven Gothel2015-03-071-14/+3
| | | | | | | | | | | | | | | newCVVariant(..), don't pass given cv-attr as typedef Add getCName(..) for proper C-type code - Add 'unsigned ' if not typedef and is unsigned. - Allows removal of special case in CMethodBindingEmitter - Fixes ProcAddressCMethodBindingEmitter typedef emission and removes clang warnings, caused by this (many). Fix its newCVVariant(..), don't pass given cv-attr as typedef - Proper delegation of 'const', regression of prev. commits
* Bug 1134 - Pass ASTLocationTag to all types, used for GlueGenExceptionSven Gothel2015-03-071-30/+40
| | | | | Enhances semantic exception in code generation by adding the AST location of the type or function declaration.
* Bug 1134 - Refine Logging using 'LoggerIf' - Replace System.err w/ Logging ↵Sven Gothel2015-03-061-4/+3
| | | | where appropriate
* Bug 1134 - Fix regression: Static C-Function call must use original API nameSven Gothel2015-03-051-1/+1
| | | | | | | | | - Regression of commit 72d3635279ffc8ad88e47dff9bbe95d211226d11 CMethodBindingEmitter emits statically linked function calls, hence needs to use the original name of AliasedSymbol. AliasedSymbol: Add 'getOrigName()' at creation!
* Bug 1134 - Enhance GlueGen Compiler: Minimal GL Header Changes _and_ TypesafetySven Gothel2015-03-051-41/+89
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - We shall be able to import 'most' vanilla GL header, i.e. only change the typedef part using our GlueGen types - Type Safety: - GlueGen now detects '#define' and 'enum' redefines and throw an exception in this case. This helps detecting wrongly renamed GL extensions into core! - GlueGen now detects function redefines (overloading) and throw an exception in this case. Hence the semantics of duplicate functions has to be equal! This helps detecting wrongly renamed GL extensions into core! - Semantic equality for all types is provided via interface TypeComparator.SemanticEqualityOp, i.e. 'boolean equalSemantics(..)' implemented by com.jogamp.gluegen.cgram.types.Type. Semantic equality can be relaxed via config "RelaxedEqualSemanticsTest true", i.e. ignoring integer size, and const / volatile qualifiers. - All equality/hash methods of 'com.jogamp.gluegen.cgram.types.*' are restructured. - Track and simplify renamed 'symbol', i.e. use a common sub-interface for all renamed symbols (ConstantDefinition, FunctionSymbol, ..) - This is provided in a unified manner via interface com.jogamp.gluegen.cgram.types.AliasedSymbol and its common implementation AliasedSymbolImpl - All JavaConfiguration.shouldIgnore* methods operate w/ 'AliasedSymbol' trying to match all aliases. - Support 'struct NAME [ { ... } ]' w/o typedef's - New GL / CL headers do not use typedef's for anonymous opaque types - Opaque Type handling - JavaConfiguration.typeInfo(..), identifying opaque types, no more back references from target-type -> typedef. Hence the following is possible now: typedef void * Opaque01; // Opaque typedef void * APointerBuffer; // A Buffer - All Logger instances are no more static and derive their warning level from the package's root Logger via Logging.getLogger(..).
* Bug 1126 - Remove static query requirement of MachineDescriptor, find ↵Sven Gothel2015-02-021-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | matching StaticConfig at runtime; Fix PPC (Bug 1056) and MIPSLE (Bug 1014) issues. Currently the StaticConfig is being queried via the key[OSType, CPUType ..] as pre-determined by Java properties or the ELF parser. This adds complication to maintain different platforms and the key query might not even be sufficient. The MachineDescriptor's StaticConfig only purpose shall be to speed-up native data size and offset/alignment retrieval. This is done by using the StaticConfig index within all StaticConfig[]s as a lookup-index for the precomputed struct's size and offset tables. +++ Solution: Rename: MachineDescriptor -> MachineDataInfo Rename: MachineDescriptorRuntime -> MachineDataInfoRuntime After having defined os.and.arch (OSType, CPUType and ABIType) w/ the optional help of the now self containing ELF Reader (Bug 1125), the native gluegen-rt library gets loaded enabling JNI methods. It is satisfactory to retrieve MachineDataInfo at runtime w/ JNI and find the matching/compatible StaticConfig. Only in case none is found, the program needs to abort. Otherwise the found MachineDataInfo.StaticConfig and MachineDataInfo are stored for further use (see above). This removes above complication and key to StaticConfig mapping. New platforms simply need to add a new unique entry into the StaticConfig[] table. ++ Also fixes Bug 1056 (PPC), thanks to tmancill [@] debian [.] org, and Bug 1014 (MIPSLE), thanks to Dejan Latinovic. Parts of the patch for Bug 1014 from Dejan Latinovic are included. also solved by this change set.
* Code Clean-Up based on our Recommended Settings (jogamp-scripting ↵Sven Gothel2014-07-031-122/+122
| | | | | | | | | | | | | | | c47bc86ae2ee268a1f38c5580d11f93d7f8d6e74) Code Clean-Up based on our Recommended Settings (jogamp-scripting c47bc86ae2ee268a1f38c5580d11f93d7f8d6e74) - Change non static accesses to static members using declaring type - Change indirect accesses to static members to direct accesses (accesses through subtypes) - Add final modifier to private fields - Add final modifier to method parameters - Add final modifier to local variables - Remove unnecessary casts - Remove unnecessary '$NON-NLS$' tags - Remove trailing white spaces on all lines
* CMethodBindingEmitter: Suppress compiler warning in NewDirectByteBuffer ↵Sven Gothel2014-06-251-2/+2
| | | | usage (cast to void*)
* Bug 1025 - GlueGen: Add accessor for compound fields of type array, pointer ↵Sven Gothel2014-06-251-16/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and string (code generation) Enhance compound access as delivered by Bug 1022, to also generate accessors (getter and setter) for array, pointer and string types. Allow configuration of array length either via their internal size (c-header) or config 'ReturnedArrayLength'. 'ReturnedArrayLength' allows specifying a java expression. Canonical field names of compounds are _now_ specified as follows for configuration entries: COMPOUND.FIELD e.g. StructA.fieldB Also allow configuration of pointer fields to be treated as referenced arrays via 'ReturnedArrayLength'. Further, allow specifying 'pointer fields' as String values via 'ReturnsString' configuration. ++++ Implementation details: - handle above described accessor features - enhance JavaDoc for generated accessors - generate native JNI compound and string accessor on demand - encapsule accessor code generation in their own methods - enhance exception messages - enhance type verbosity in debug mode - verbose debug output via GlueGen.debug() Tests: - Features covered by test1.[ch] and Test1p1JavaEmitter and Test1p2ProcAddressEmitter - Validated compilation and unit tests for modules: - joal - jogl (minor config changes req.) - jocl (minor config changes req.)
* GlueGen: Add support for 'compound array call-by-value'Sven Gothel2014-06-171-82/+97
| | | | | | | | | | | | | | | | | | | | | | | | | Completing commit c3054a01990e55ab35756ea23ab7d7c05f24dd37 by allowing passing compound arrays via 'call-by-value. - Creating linear temp heap, copying NIO values into it and passing to C function. Copy-back if not 'const', see below. - Respect 'const' qualifier to skip write-back of temp heap passed to C function - See tag: // FIXME: Compound and Compound-Arrays for code changes and validation of completeness - triggers for compound arrays are: - javaType.isArrayOfCompoundTypeWrappers() - type.isArray() - simplified const query by c-type: FunctionEmitter.isBaseTypeConst(ctype) +++ Tests: Added call-by-value to test1.[ch] binding test!
* GlueGen: Add support for 'compound call-by-value', i.e. passing and ↵Sven Gothel2014-06-171-23/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | returning struct instance 'compound call-by-value' is not efficient. However, to allow mapping APIs utilizing passing small structs as arguments and return values - this feature has been added. +++ To return the struct value, native code needs to allocate a NIO ByteBuffer and copy the data. The stack return value can be dismissed afterwards and the NIO buffer is returned. We include this functionality for all generated [impl] classes, native method: 'static jobject JVMUtil_NewDirectByteBufferCopy(JNIEnv *env, void * source_address, jlong capacity)' (See: 'JavaEmitter.initClassAccessCode') Since this code requires knowledge of java classes and methods, for which a reference needs to be acquired, a static initialization method has been introduced for all generated [impl] classes: 'private static native boolean initializeImpl();' Per default the this method will be called in the new static initializer block of the class, which can be supressed via the configuration element: 'ManualStaticInit <class-name>' 'ManualStaticInit' can be used to issue the 'initializeImpl()' call in a custom static initializer written by the user. However, at the time 'initializeImpl()' gets called the JNI native library must have been loaded, of course! +++ - See tag: // FIXME: Compound call-by-value for code changes and validation of completeness Trigger for compond call-by-value in CMethodBindingEmitter is: !cArgType.isPointer() && javaArgType.isCompoundTypeWrapper() Trigger for compond call-by-value in JavaEmitter is: t.isCompound() +++ Further more we do tolerate 'javaType.isCPrimitivePointerType()', i.e. adding comments for offset/size and field entries, which are all NOP. This allows to utilize the remaining fields of the native structure. +++ Tests: Added call-by-value to test1.[ch] binding test!
* Minor Cleanup after merging fixes for bugs 987, 990, 992 and 994Sven Gothel2014-03-101-5/+6
|
* Fix accidental tabs.Wade Walker2014-03-041-7/+7
|
* Remove warnings in emitted C code.Wade Walker2014-03-041-1/+11
| | | | | | | | Fix 1: Only emit "int * _offsetHandle = NULL" if it will be used, to avoid unused variable warning. Fix 2: Add "unsigned" to typecasts in C function calls when needed to avoid implicit typecast warning. This commit also adds a unit test for a method that uses an "unsigned char **" parameter, to mimic the JOCL clCreateProgramWithBinary() function that caused the typecast warnings.
* gluegen: add all missing @Override annotationsHarvey Harrison2013-10-171-0/+6
| | | | Signed-off-by: Harvey Harrison <[email protected]>
* gluegen: remove trailing whitespaceHarvey Harrison2013-10-171-65/+65
| | | | Signed-off-by: Harvey Harrison <[email protected]>
* Fix Bug 715: Don't modify 'carray' pointer returned from ↵Sven Gothel2013-04-131-5/+15
| | | | | | | | | | | | | | | GetPrimitiveArrayCritical(..) The 'carray' pointer returned from GetPrimitiveArrayCritical(..) was moved about the array offset and used in ReleasePrimitiveArrayCritical(..) to release the pinpointed memory. Even though this 'is' a bug by violating the _sparse_ specification, Hotspot impl. doesn't use the value at all (NOP) and hence this code didn't produce an error since .. (Same w/ Dalvik). Now the array offset is added while passing the carray pointer to the native function call and hence is no more modified and the orig. value is passed to ReleasePrimitiveArrayCritical(..). Tested w/ GlueGen unit tests and all JOGL unit tests (on Linux x64 w/ 'a' hotspot VM).