Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions substratevm/docs/runtime-class-loading.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,4 @@ A typical way to address this is to use `-H:Preserve=package=...` at build time
* "condy" entries are not supported in the constant pool of run-time-loaded classes.
* The boot layer modules are frozen at build time, and it may not be possible to load additional classes at run time from modules of the build-time module path.
* The assertion status of classes is fixed at image build time.
* Reflection is limited for run-time-loaded classes:
* `getRecordComponents` does not work.
* Methods or static fields that are removed by analysis in a class that is inluded in the image have no fall-back and will cause an error if used by runtime loaded code.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2025, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -167,6 +167,9 @@ private Constructor<?> fromResolvedConstructor(DynamicHub declaringClass, CremaR
@Override
public RecordComponent[] getRecordComponents(DynamicHub declaringClass, @SuppressWarnings("unused") int layerNum) {
List<? extends CremaResolvedJavaRecordComponent> recordComponents = type.getRecordComponents();
if (recordComponents == null) {
return null;
}
RecordComponent[] result = new RecordComponent[recordComponents.size()];
Class<?> clazz = DynamicHub.toClass(declaringClass);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public ResolvedJavaMethod getClassInitializer() {
public List<? extends CremaResolvedJavaRecordComponent> getRecordComponents() {
RecordAttribute recordAttribute = getAttribute(RecordAttribute.NAME, RecordAttribute.class);
if (recordAttribute == null) {
return List.of();
return null;
}
RecordComponentInfo[] components = recordAttribute.getComponents();
if (components.length == 0) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -36,7 +36,6 @@
import com.oracle.svm.core.SubstrateMetadata;
import com.oracle.svm.core.hub.DynamicHub;
import com.oracle.svm.core.hub.RuntimeClassLoading;
import com.oracle.svm.core.hub.crema.CremaResolvedJavaRecordComponent;
import com.oracle.svm.core.hub.registry.SymbolsSupport;
import com.oracle.svm.espresso.classfile.descriptors.Name;
import com.oracle.svm.espresso.classfile.descriptors.Symbol;
Expand Down Expand Up @@ -255,11 +254,6 @@ public final boolean isRecord() {
throw VMError.intentionallyUnimplemented();
}

@Override
public List<? extends CremaResolvedJavaRecordComponent> getRecordComponents() {
throw VMError.intentionallyUnimplemented();
}

@Override
public final boolean isInitialized() {
return DynamicHub.fromClass(clazz).isInitialized();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -45,14 +45,15 @@
import com.oracle.svm.espresso.classfile.descriptors.Type;
import com.oracle.svm.espresso.classfile.descriptors.TypeSymbols;
import com.oracle.svm.espresso.shared.meta.TypeAccess;
import com.oracle.svm.shared.Uninterruptible;
import com.oracle.svm.interpreter.metadata.serialization.VisibleForSerialization;
import com.oracle.svm.shared.Uninterruptible;
import com.oracle.svm.shared.singletons.MultiLayeredImageSingleton;
import com.oracle.svm.shared.util.VMError;

import jdk.vm.ci.meta.JavaConstant;
import jdk.vm.ci.meta.JavaKind;
import jdk.vm.ci.meta.JavaType;
import jdk.vm.ci.meta.ResolvedJavaRecordComponent;
import jdk.vm.ci.meta.ResolvedJavaType;

/**
Expand Down Expand Up @@ -220,6 +221,14 @@ public List<JavaType> getPermittedSubclasses() {
throw VMError.unimplemented("getPermittedSubclasses");
}

@Override
public List<? extends ResolvedJavaRecordComponent> getRecordComponents() {
if (isArray()) {
return null;
}
throw VMError.shouldNotReachHere("getRecordComponents");
}

@Override
public final JavaKind getJavaKind() {
return JavaKind.Object;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -28,6 +28,7 @@
import java.util.Collections;
import java.util.List;

import com.oracle.svm.core.hub.crema.CremaResolvedJavaRecordComponent;
import com.oracle.svm.core.hub.registry.SymbolsSupport;
import com.oracle.svm.espresso.classfile.ConstantPool;
import com.oracle.svm.espresso.classfile.descriptors.ByteSequence;
Expand Down Expand Up @@ -110,6 +111,11 @@ public List<JavaType> getPermittedSubclasses() {
return null;
}

@Override
public List<? extends CremaResolvedJavaRecordComponent> getRecordComponents() {
return null;
}

@Override
public JavaKind getJavaKind() {
return kind;
Expand Down