Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ public static void addResource(Module module, String resourcePath, byte[] resour
Objects.requireNonNull(module);
Objects.requireNonNull(resourcePath);
Objects.requireNonNull(resourceContent);
ImageSingletons.lookup(RuntimeResourceSupport.class).injectResource(
module, resourcePath, resourceContent);
ImageSingletons.lookup(RuntimeResourceSupport.class).injectResource(module, resourcePath, resourceContent);
ImageSingletons.lookup(RuntimeResourceSupport.class).addCondition(ConfigurationCondition.alwaysTrue(), module, resourcePath);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,11 @@ public int hashCode() {
return Objects.hash(type, runtimeChecked);
}

@Override
public String toString() {
return "ConfigurationCondition(" +
"type=" + type +
", runtimeChecked=" + runtimeChecked +
')';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,27 @@ static RuntimeResourceSupport<ConfigurationCondition> singleton() {

void addResources(C condition, String pattern);

void addResource(Module module, String resourcePath);

void addGlob(C condition, String module, String glob);

void injectResource(Module module, String resourcePath, byte[] resourceContent);

void ignoreResources(C condition, String pattern);

void addResourceBundles(C condition, String name);

void addResourceBundles(C condition, String basename, Collection<Locale> locales);

/* Following functions are used only from features */
void addCondition(ConfigurationCondition configurationCondition, Module module, String resourcePath);

void addResourceEntry(Module module, String resourcePath);

default void addResource(Module module, String resourcePath) {
addResource(ConfigurationCondition.alwaysTrue(), module, resourcePath);
}

default void addResource(ConfigurationCondition condition, Module module, String resourcePath) {
addResourceEntry(module, resourcePath);
addCondition(condition, module, resourcePath);
}

void injectResource(Module module, String resourcePath, byte[] resourceContent);
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.util.List;
import java.util.Locale;

import org.graalvm.nativeimage.impl.ConfigurationCondition;
import org.graalvm.nativeimage.impl.UnresolvedConfigurationCondition;
import org.junit.Assert;
import org.junit.Test;
Expand Down Expand Up @@ -102,7 +103,7 @@ public void addGlob(UnresolvedConfigurationCondition condition, String module, S
}

@Override
public void addResource(Module module, String resourcePath) {
public void addResourceEntry(Module module, String resourcePath) {
throw VMError.shouldNotReachHere("Unused function.");
}

Expand All @@ -124,6 +125,11 @@ public void addResourceBundles(UnresolvedConfigurationCondition condition, Strin

}

@Override
public void addCondition(ConfigurationCondition configurationCondition, Module module, String resourcePath) {

}

@Override
public void addClassBasedResourceBundle(UnresolvedConfigurationCondition condition, String basename, String className) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.util.concurrent.ConcurrentMap;
import java.util.regex.Pattern;

import org.graalvm.nativeimage.impl.ConfigurationCondition;
import org.graalvm.nativeimage.impl.UnresolvedConfigurationCondition;

import com.oracle.svm.configure.ConfigurationBase;
Expand Down Expand Up @@ -69,7 +70,12 @@ public void addGlob(UnresolvedConfigurationCondition condition, String module, S
}

@Override
public void addResource(Module module, String resourcePath) {
public void addResourceEntry(Module module, String resourcePath) {
throw VMError.shouldNotReachHere("Unused function.");
}

@Override
public void addCondition(ConfigurationCondition condition, Module module, String resourcePath) {
throw VMError.shouldNotReachHere("Unused function.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public boolean isNativeImageClassLoader(ClassLoader classLoader) {
public interface ResourceCollector {
List<ConfigurationCondition> isIncluded(Module module, String resourceName, URI resourceURI);

void addResource(Module module, String resourceName);
void addResourceEntry(Module module, String resourceName);

void addResourceConditionally(Module module, String resourceName, ConfigurationCondition condition);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ interface ClassInitializerFunctionPointer extends CFunctionPointer {
private boolean hasInitializer;
private boolean buildTimeInitialized;

public boolean isTypeReached() {
assert typeReached != TypeReached.UNTRACKED : "We should never emit a check for untracked types as this was known at build time";
public boolean isTypeReached(DynamicHub caller) {
assert typeReached != TypeReached.UNTRACKED : "We should never emit a check for untracked types as this was known at build time: " + caller.getName();
return typeReached == TypeReached.REACHED;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,16 @@ public static final class Options {
@Option(help = "When configuration files do not match their schema, abort the image build instead of emitting a warning.")//
public static final HostedOptionKey<Boolean> StrictConfiguration = new HostedOptionKey<>(false);

@Option(help = "Testing flag: the typeReachable condition is treated as typeReached so the semantics of programs can change.")//
@Option(help = "Testing flag: the 'typeReachable' condition is treated as typeReached so the semantics of programs can change.")//
public static final HostedOptionKey<Boolean> TreatAllTypeReachableConditionsAsTypeReached = new HostedOptionKey<>(false);

@Option(help = "Testing flag: the 'name' is treated as 'type' reflection configuration.")//
@Option(help = "Testing flag: the 'name' is treated as 'type' in reflection configuration.")//
public static final HostedOptionKey<Boolean> TreatAllNameEntriesAsType = new HostedOptionKey<>(false);

@Option(help = "Testing flag: the 'typeReached' condition is always satisfied however it prints the stack trace where it would not be satisfied.")//
public static final HostedOptionKey<Boolean> TrackUnsatisfiedTypeReachedConditions = new HostedOptionKey<>(false);

@Option(help = "Testing flag: print 'typeReached' conditions that are used on interfaces at build time.")//
@Option(help = "Testing flag: print 'typeReached' conditions that are used on interfaces without default methods at build time.")//
public static final HostedOptionKey<Boolean> TrackTypeReachedOnInterfaces = new HostedOptionKey<>(false);

@Option(help = "Testing flag: every type is considered as it participates in a typeReachable condition.")//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@
import org.graalvm.nativeimage.c.function.CFunctionPointer;
import org.graalvm.nativeimage.impl.InternalPlatform;

import com.oracle.svm.core.RuntimeAssertionsSupport;
import com.oracle.svm.core.SubstrateUtil;
import com.oracle.svm.core.Uninterruptible;
import com.oracle.svm.core.BuildPhaseProvider.AfterCompilation;
import com.oracle.svm.core.BuildPhaseProvider.AfterHostedUniverse;
import com.oracle.svm.core.BuildPhaseProvider.CompileQueueFinished;
import com.oracle.svm.core.RuntimeAssertionsSupport;
import com.oracle.svm.core.SubstrateUtil;
import com.oracle.svm.core.Uninterruptible;
import com.oracle.svm.core.annotate.Alias;
import com.oracle.svm.core.annotate.Delete;
import com.oracle.svm.core.annotate.InjectAccessors;
Expand All @@ -114,6 +114,7 @@
import com.oracle.svm.core.reflect.RuntimeMetadataDecoder.FieldDescriptor;
import com.oracle.svm.core.reflect.RuntimeMetadataDecoder.MethodDescriptor;
import com.oracle.svm.core.reflect.fieldaccessor.UnsafeFieldAccessorFactory;
import com.oracle.svm.core.reflect.serialize.SerializationRegistry;
import com.oracle.svm.core.reflect.target.Target_jdk_internal_reflect_ConstantPool;
import com.oracle.svm.core.util.LazyFinalReference;
import com.oracle.svm.core.util.VMError;
Expand Down Expand Up @@ -492,7 +493,7 @@ public void setClassInitializationInfo(ClassInitializationInfo classInitializati

@Platforms(Platform.HOSTED_ONLY.class)
public void setSharedData(int layoutEncoding, int monitorOffset, int identityHashOffset, long referenceMapIndex,
boolean isInstantiated, boolean canUnsafeInstantiateAsInstance, boolean isRegisteredForSerialization) {
boolean isInstantiated, boolean canUnsafeInstantiateAsInstance) {
assert !(!isInstantiated && canUnsafeInstantiateAsInstance);
VMError.guarantee(monitorOffset == (char) monitorOffset, "Class %s has an invalid monitor field offset. Most likely, its objects are larger than supported.", name);
VMError.guarantee(identityHashOffset == (char) identityHashOffset, "Class %s has an invalid identity hash code field offset. Most likely, its objects are larger than supported.", name);
Expand All @@ -506,8 +507,7 @@ public void setSharedData(int layoutEncoding, int monitorOffset, int identityHas
}
this.referenceMapIndex = (int) referenceMapIndex;
this.additionalFlags = NumUtil.safeToUByte(makeFlag(IS_INSTANTIATED_BIT, isInstantiated) |
makeFlag(CAN_UNSAFE_INSTANTIATE_AS_INSTANCE_BIT, canUnsafeInstantiateAsInstance) |
makeFlag(IS_REGISTERED_FOR_SERIALIZATION, isRegisteredForSerialization));
makeFlag(CAN_UNSAFE_INSTANTIATE_AS_INSTANCE_BIT, canUnsafeInstantiateAsInstance));
}

@Platforms(Platform.HOSTED_ONLY.class)
Expand Down Expand Up @@ -983,7 +983,7 @@ public boolean isLinked() {
}

public boolean isRegisteredForSerialization() {
return isFlagSet(additionalFlags, IS_REGISTERED_FOR_SERIALIZATION);
return ImageSingletons.lookup(SerializationRegistry.class).isRegisteredForSerialization(DynamicHub.toClass(this));
}

@KeepOriginal
Expand Down Expand Up @@ -1951,7 +1951,7 @@ public Object getJfrEventConfiguration() {
}

public boolean isReached() {
return classInitializationInfo.isTypeReached();
return classInitializationInfo.isTypeReached(this);
}

private static class ReflectionDataAccessors {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private static void registerLambdaForReflection(Class<?> lambdaClass) {
* lambda-class information from the capturing class.
*/
if (Serializable.class.isAssignableFrom(lambdaClass) &&
SerializationSupport.isLambdaCapturingClassRegistered(LambdaUtils.capturingClass(lambdaClass.getName()))) {
SerializationSupport.singleton().isLambdaCapturingClassRegistered(LambdaUtils.capturingClass(lambdaClass.getName()))) {
try {
Method serializeLambdaMethod = lambdaClass.getDeclaredMethod("writeReplace");
RuntimeReflection.register(serializeLambdaMethod);
Expand Down
Loading