Skip to content

Fix primitive boolean field lookup#15

Open
minyanyi wants to merge 1 commit into
Syncleus:masterfrom
minyanyi:fix/boolean-primitive-field
Open

Fix primitive boolean field lookup#15
minyanyi wants to merge 1 commit into
Syncleus:masterfrom
minyanyi:fix/boolean-primitive-field

Conversation

@minyanyi
Copy link
Copy Markdown

Fixes the native runtime lookup for primitive boolean kernel fields.

Aparapi currently maps the generated OpenCL argument to a byte-sized value, but the Java field itself still has the JVM boolean descriptor Z. The non-static primitive boolean path was looking up the field with descriptor B and reading it as a byte, which causes NoSuchFieldError for kernels like Syncleus/aparapi#91.

This matches the existing static boolean path by looking up descriptor Z and reading the value with GetBooleanField.

Verification:

I could not build the native library in this Windows environment because no C++ compiler or Docker runtime is installed.

@minyanyi
Copy link
Copy Markdown
Author

I also verified the native fix locally on Windows x64 with VS Build Tools 2022.

Build notes:

  • Generated JNI headers with JDK 17 javac -h from the Aparapi Java classes.
  • Built libaparapi_x86_64.dll from this branch using MSBuild/PlatformToolset v143.
  • Used Khronos OpenCL headers and an import library generated from C:\Windows\System32\OpenCL.dll.

Repro/control:

  • Running UseBooleanTest$BooleanKernel with the published aparapi-jni:1.4.3 native DLL still throws:
    NoSuchFieldError: com.aparapi.runtime.UseBooleanTest$BooleanKernel.isInverse B

After fix:

  • Putting the locally built DLL from this branch first on the test classpath and running the same kernel.execute(1) completes without the NoSuchFieldError.
  • Output: mode=AUTO

So the failing boolean field lookup is resolved by changing the non-static primitive boolean JNI lookup from descriptor B/GetByteField to descriptor Z/GetBooleanField.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant