microstream - 微流是否已经支持 JDK 15 - 记录问题
问题描述
我正在使用 JDK 15.0.1 并尝试保存记录。我在微流代码中遇到错误。语句if (declaringClass.isRecord())
中的异常抛出 text can't get field offset on a record (preview):。
在文档中,声明自 JDK 14 起支持记录(请参阅https://manual.docs.microstream.one/data-store/faq/java-features#can-microstream-handle-records)。
if (f == null) {
throw new NullPointerException();
}
Class<?> declaringClass = f.getDeclaringClass();
if (declaringClass.isHidden()) {
throw new UnsupportedOperationException("can't get field offset on a hidden class: " + f);
}
if (declaringClass.isRecord()) {
throw new UnsupportedOperationException("can't get field offset on a record (preview): " + f);
}
return theInternalUnsafe.objectFieldOffset(f);
}
我使用以下版本的微流
implementation 'one.microstream:storage.embedded:04.00.00-MS-GA'
我做错什么了吗?
真挚地
解决方案
感谢您对微流的关注。不幸的是,我无法从问题的描述中得出问题所在的地方。描述中的代码来自 jdk 类Unsafe.java。由于我还不能重现你的问题,所以我很快在 github 上做了一个小测试项目,其中 Records 的基本测试是用 Java 进行的。 https://github.com/johny2000uwb/microstream-records
public record PersonRecord(String firstName, String lastName) {
}
@Test
public void saveRecordTest() {
PersonRecord personRecord = new PersonRecord("Maria", "Lukasova");
EmbeddedStorageManager storage = EmbeddedStorage.start(personRecord, location);
storage.shutdown();
PersonRecord secondRecord = new PersonRecord("Kamila", "Pazourkova");
storage = EmbeddedStorage.start(secondRecord, location);
Assertions.assertEquals("Maria", secondRecord.firstName());
}
记录仍然只是预览功能,所以需要启用它。例如在 Maven 中:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>14</release> <!-- <release>13/14/15</release> -->
<compilerArgs>--enable-preview</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<argLine>--enable-preview</argLine>
</configuration>
</plugin>
</plugins>
</build>
推荐阅读
- matplotlib - 如何放大子图中的 imshow 图像?
- javascript - 如何实现服务器端less主题?
- bert-language-model - 如何在微调阶段使用 BERT 模型进行 MLM
- c# - 在 Windows 应用程序表单的文本框中打印数组时出错
- php - PHP:试图在数据库中插入日期
- python-3.x - 我在这里缺少什么,使用 ImageFolder 获取完整文件夹名称作为 MNIST 双数据集图像的标签?
- vba - 有没有办法改变 VBA 用户窗体标签中字符串部分的字体颜色?
- swift - Ubuntu 16.04 上 iOS NEVPNManager 和 StrongSwan 之间的 VPN 连接
- .net - .Net Core 应用程序内存问题
- docker - 通过端口 443 和 apache 访问 mosquitto