Skip to content

Commit

Permalink
Updated to OpenJDK-22
Browse files Browse the repository at this point in the history
  • Loading branch information
aploese committed Apr 8, 2024
1 parent 14be46b commit 949414c
Show file tree
Hide file tree
Showing 24 changed files with 229 additions and 232 deletions.
32 changes: 0 additions & 32 deletions de.ibapl.jnhw.common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,6 @@
</dependencies>

<build>
<!-- move native to separate jar testResources>
<testResource>
<directory>${basedir}/src/test/resources</directory>
</testResource>
<testResource>
<directory>${basedir}/src/main/native/lib</directory>
<targetPath>./lib/</targetPath>
</testResource>
</testResources-->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -60,7 +51,6 @@
</goals>
<configuration>
<compilerArgs>
<arg>--enable-preview</arg>
<arg>-h</arg>
<arg>${basedir}/src/main/native/include/</arg>
</compilerArgs>
Expand All @@ -71,29 +61,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>${commandLineArg.ChooseVM} ${commandLineArg.NativeProvider} --enable-preview</argLine>
</configuration>
</plugin>
<!-- move native to separate jar plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.4.2</version>
<executions>
<execution>
<id>assembly-native-libs</id> <!- - this is used for inheritance merges - ->
<phase>package</phase> <!- - append to the packaging phase. - ->
<goals>
<goal>single</goal> <!- - goals == mojos - ->
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assembly/native-libs.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin-->
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.lang.foreign.ValueLayout;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.Charset;

/**
*
Expand Down Expand Up @@ -249,13 +250,23 @@ public void uintptr_t_AtIndex(MemorySegment mem, long index, MemorySegment dest)
}

@Override
public String getUTF_8String(MemorySegment mem, long offset) {
return mem.getUtf8String(offset);
public String getString(MemorySegment mem, long offset) {
return mem.getString(offset);
}

@Override
public void setUTF_8String(MemorySegment mem, long offset, String s) {
mem.setUtf8String(offset, s);
public void setString(MemorySegment mem, long offset, String s) {
mem.setString(offset, s);
}

@Override
public String getString(MemorySegment mem, long offset, Charset charset) {
return mem.getString(offset, charset);
}

@Override
public void setString(MemorySegment mem, long offset, String s, Charset charset) {
mem.setString(offset, s, charset);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.lang.foreign.MemorySegment;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.Charset;

/**
*
Expand Down Expand Up @@ -654,12 +655,18 @@ default String getSignedLongOf_nativeToString(MemorySegment mem, long offset, in
* @param offset
* @return
*/
String getUTF_8String(MemorySegment mem, long offset);
String getString(MemorySegment mem, long offset);

void setUTF_8String(MemorySegment mem, long offset, String s);
void setString(MemorySegment mem, long offset, String s);

String getString(MemorySegment mem, long offset, Charset charset);

void setString(MemorySegment mem, long offset, String s, Charset charset);

@Deprecated //TODO use getString + Charset
String getUnicodeString(MemorySegment mem, long offset, int len);

@Deprecated //TODO use setString + Charset
void setUnicodeString(MemorySegment mem, long offset, int len, String s);

static long getBitsInLong(long value, int bitpos, int bitsize) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ public BaseDataType getBaseDataType() {
return BaseDataType.intptr_t;
}

/*
@Deprecated
public long nextOffset(OpaqueMemory fieldOnTheFly, Alignment fieldAlignment) {
return OpaqueMemory.calcOffsetForAlignment(this, fieldAlignment, memorySegment.segmentOffset(fieldOnTheFly.memorySegment) + fieldOnTheFly.sizeof());
//return OpaqueMemory.calcOffsetForAlignment(this, fieldAlignment, memorySegment.segmentOffset(fieldOnTheFly.memorySegment) + fieldOnTheFly.sizeof());
}
*/

@Deprecated
public long getAlignmentOffset(long offset, Alignment alignment) {
return OpaqueMemory.calcOffsetForAlignment(this, alignment, offset);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.io.IOException;
import java.lang.foreign.Arena;
import java.lang.foreign.MemorySegment;
import java.nio.charset.Charset;

/**
*
Expand All @@ -47,11 +48,19 @@ public static PtrChar map(OpaqueMemory mem, long offset) {
}

public String get() {
return MEM_ACCESS.getUTF_8String(memorySegment, 0);
return MEM_ACCESS.getString(memorySegment, 0);
}

public void set(String value) {
MEM_ACCESS.setUTF_8String(memorySegment, 0, value);
MEM_ACCESS.setString(memorySegment, 0, value);
}

public String get(Charset charset) {
return MEM_ACCESS.getString(memorySegment, 0, charset);
}

public void set(String value, Charset charset) {
MEM_ACCESS.setString(memorySegment, 0, value, charset);
}

@Override
Expand Down
Loading

0 comments on commit 949414c

Please sign in to comment.