microstream是否已经支持JDK 15-记录问题

我正在使用JDK 15.0.1,并尝试保存一条记录。我在微流代码中遇到错误。语句if (declaringClass.isRecord())中的异常引发了文本无法在记录(预览)上获得字段偏移量:

在文档中,声明从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'

我做错了吗?

真诚的

shikabulu 回答:microstream是否已经支持JDK 15-记录问题

感谢您对微流的关注。 不幸的是,我无法从问题的描述中找到问题所在。描述中的代码来自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>

本文链接:https://www.f2er.com/1243023.html

大家都在问