-
Notifications
You must be signed in to change notification settings - Fork 447
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve a issue that JNA could not map bool correctly (#2376)
ref: https://stackoverflow.com/questions/55225896/jna-maps-java-boolean-to-1-integer Fix the bug of #1814 roots from the mapping of Boolean in Java to C. Probably [this PR](rust-lang/rust#89887) within rust version 1.61 trigger that, though I'm not sure. Co-authored-by: shirly121 <[email protected]> Co-authored-by: BingqingLyu <[email protected]>
- Loading branch information
1 parent
553b517
commit 59367f8
Showing
6 changed files
with
33 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...ive_engine/compiler/src/main/java/com/alibaba/graphscope/common/jna/BooleanConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.alibaba.graphscope.common.jna; | ||
|
||
import com.sun.jna.FromNativeContext; | ||
import com.sun.jna.ToNativeContext; | ||
import com.sun.jna.TypeConverter; | ||
|
||
// to convert java boolean to i32 and define i32 as the native bool type | ||
public class BooleanConverter implements TypeConverter { | ||
@Override | ||
public Object toNative(Object value, ToNativeContext context) { | ||
return Integer.valueOf(Boolean.TRUE.equals(value) ? 1 : 0); | ||
} | ||
|
||
@Override | ||
public Object fromNative(Object value, FromNativeContext context) { | ||
return ((Integer) value).intValue() != 0 ? Boolean.TRUE : Boolean.FALSE; | ||
} | ||
|
||
@Override | ||
public Class<?> nativeType() { | ||
// BOOL is 32-bit int | ||
return Integer.class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.