Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2013, 2017, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.svm.hosted;
import java.lang.annotation.Annotation;
import java.lang.reflect.Executable;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.nio.file.Path;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Deque;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import com.oracle.svm.hosted.code.CEntryPointData;
import org.graalvm.collections.Pair;
import org.graalvm.compiler.debug.DebugContext;
import org.graalvm.nativeimage.hosted.Feature;
import org.graalvm.nativeimage.hosted.Feature.DuringAnalysisAccess;
import org.graalvm.nativeimage.hosted.RuntimeReflection;
import com.oracle.graal.pointsto.BigBang;
import com.oracle.graal.pointsto.api.UnsafePartitionKind;
import com.oracle.graal.pointsto.infrastructure.SubstitutionProcessor;
import com.oracle.graal.pointsto.meta.AnalysisField;
import com.oracle.graal.pointsto.meta.AnalysisMetaAccess;
import com.oracle.graal.pointsto.meta.AnalysisMethod;
import com.oracle.graal.pointsto.meta.AnalysisType;
import com.oracle.graal.pointsto.meta.AnalysisUniverse;
import com.oracle.svm.core.LinkerInvocation;
import com.oracle.svm.core.graal.meta.RuntimeConfiguration;
import com.oracle.svm.core.hub.DynamicHub;
import com.oracle.svm.core.meta.SharedField;
import com.oracle.svm.core.meta.SharedMethod;
import com.oracle.svm.core.meta.SharedType;
import com.oracle.svm.core.meta.SubstrateObjectConstant;
import com.oracle.svm.hosted.analysis.Inflation;
import com.oracle.svm.hosted.c.NativeLibraries;
import com.oracle.svm.hosted.code.CompilationInfoSupport;
import com.oracle.svm.hosted.code.SharedRuntimeConfigurationBuilder;
import com.oracle.svm.hosted.image.AbstractBootImage;
import com.oracle.svm.hosted.image.AbstractBootImage.NativeImageKind;
import com.oracle.svm.hosted.image.NativeImageHeap;
import com.oracle.svm.hosted.meta.HostedField;
import com.oracle.svm.hosted.meta.HostedMetaAccess;
import com.oracle.svm.hosted.meta.HostedType;
import com.oracle.svm.hosted.meta.HostedUniverse;
import com.oracle.svm.hosted.option.HostedOptionProvider;
import jdk.vm.ci.meta.JavaConstant;
import jdk.vm.ci.meta.JavaKind;
import jdk.vm.ci.meta.MetaAccessProvider;
@SuppressWarnings("deprecation")
public class FeatureImpl {
public abstract static class FeatureAccessImpl implements Feature.FeatureAccess {
protected final FeatureHandler featureHandler;
protected final ImageClassLoader imageClassLoader;
protected final DebugContext debugContext;
FeatureAccessImpl(FeatureHandler featureHandler, ImageClassLoader imageClassLoader, DebugContext debugContext) {
this.featureHandler = featureHandler;
this.imageClassLoader = imageClassLoader;
this.debugContext = debugContext;
}
public ImageClassLoader getImageClassLoader() {
return imageClassLoader;
}
@Override
public Class> findClassByName(String className) {
return imageClassLoader.findClassByName(className, false);
}
public List> findSubclasses(Class baseClass) {
return imageClassLoader.findSubclasses(baseClass, false);
}
public List> findAnnotatedClasses(Class extends Annotation> annotationClass) {
return imageClassLoader.findAnnotatedClasses(annotationClass, false);
}
public List findAnnotatedMethods(Class extends Annotation> annotationClass) {
return imageClassLoader.findAnnotatedMethods(annotationClass);
}
public List findAnnotatedFields(Class extends Annotation> annotationClass) {
return imageClassLoader.findAnnotatedFields(annotationClass);
}
public FeatureHandler getFeatureHandler() {
return featureHandler;
}
public DebugContext getDebugContext() {
return debugContext;
}
}
public static class IsInConfigurationAccessImpl extends FeatureAccessImpl implements Feature.IsInConfigurationAccess {
IsInConfigurationAccessImpl(FeatureHandler featureHandler, ImageClassLoader imageClassLoader, DebugContext debugContext) {
super(featureHandler, imageClassLoader, debugContext);
}
}
public static class AfterRegistrationAccessImpl extends FeatureAccessImpl implements Feature.AfterRegistrationAccess {
private final MetaAccessProvider metaAccess;
private Pair mainEntryPoint;
AfterRegistrationAccessImpl(FeatureHandler featureHandler, ImageClassLoader imageClassLoader, MetaAccessProvider metaAccess, Pair mainEntryPoint,
DebugContext debugContext) {
super(featureHandler, imageClassLoader, debugContext);
this.metaAccess = metaAccess;
this.mainEntryPoint = mainEntryPoint;
}
public MetaAccessProvider getMetaAccess() {
return metaAccess;
}
public void setMainEntryPoint(Pair mainEntryPoint) {
this.mainEntryPoint = mainEntryPoint;
}
public Pair getMainEntryPoint() {
return mainEntryPoint;
}
}
abstract static class AnalysisAccessBase extends FeatureAccessImpl {
protected final Inflation bb;
AnalysisAccessBase(FeatureHandler featureHandler, ImageClassLoader imageClassLoader, Inflation bb, DebugContext debugContext) {
super(featureHandler, imageClassLoader, debugContext);
this.bb = bb;
}
public BigBang getBigBang() {
return bb;
}
public AnalysisUniverse getUniverse() {
return bb.getUniverse();
}
public AnalysisMetaAccess getMetaAccess() {
return bb.getMetaAccess();
}
public boolean isReachable(Class> clazz) {
return isReachable(getMetaAccess().lookupJavaType(clazz));
}
public boolean isReachable(AnalysisType type) {
return type.isInTypeCheck() || type.isInstantiated();
}
public boolean isReachable(Field field) {
return isReachable(getMetaAccess().lookupJavaField(field));
}
public boolean isReachable(AnalysisField field) {
return field.isAccessed();
}
public boolean isReachable(Executable method) {
return isReachable(getMetaAccess().lookupJavaMethod(method));
}
public boolean isReachable(AnalysisMethod method) {
return method.isImplementationInvoked();
}
}
public static class DuringSetupAccessImpl extends AnalysisAccessBase implements Feature.DuringSetupAccess {
DuringSetupAccessImpl(FeatureHandler featureHandler, ImageClassLoader imageClassLoader, Inflation bb, DebugContext debugContext) {
super(featureHandler, imageClassLoader, bb, debugContext);
}
@Override
public void registerObjectReplacer(Function