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.
AspectJ tools most notably contains the AspectJ compiler (AJC). AJC applies aspects to Java classes during
compilation, fully replacing Javac for plain Java classes and also compiling native AspectJ or annotation-based
@AspectJ syntax. Furthermore, AJC can weave aspects into existing class files in a post-compile binary weaving step.
This library is a superset of AspectJ weaver and hence also of AspectJ runtime.
/*******************************************************************************
* Copyright (c) 2003, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
* Hannes Wellmann - Bug 577497 - Support version-specific entries in dev-classPath file
*******************************************************************************/
package org.eclipse.osgi.internal.framework;
import static org.osgi.framework.Constants.FRAMEWORK_LANGUAGE;
import static org.osgi.framework.Constants.FRAMEWORK_OS_NAME;
import static org.osgi.framework.Constants.FRAMEWORK_OS_VERSION;
import static org.osgi.framework.Constants.FRAMEWORK_PROCESSOR;
import static org.osgi.framework.Constants.FRAMEWORK_STORAGE_CLEAN;
import static org.osgi.framework.Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT;
import static org.osgi.framework.Constants.FRAMEWORK_UUID;
import static org.osgi.framework.Constants.FRAMEWORK_VENDOR;
import static org.osgi.framework.Constants.SUPPORTS_FRAMEWORK_EXTENSION;
import static org.osgi.framework.Constants.SUPPORTS_FRAMEWORK_FRAGMENT;
import static org.osgi.framework.Constants.SUPPORTS_FRAMEWORK_REQUIREBUNDLE;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.JarURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.CodeSource;
import java.security.ProtectionDomain;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Properties;
import java.util.StringTokenizer;
import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.core.runtime.internal.adaptor.ConsoleManager;
import org.eclipse.osgi.framework.log.FrameworkLogEntry;
import org.eclipse.osgi.internal.container.InternalUtils;
import org.eclipse.osgi.internal.debug.Debug;
import org.eclipse.osgi.internal.debug.FrameworkDebugOptions;
import org.eclipse.osgi.internal.hookregistry.HookRegistry;
import org.eclipse.osgi.internal.location.EquinoxLocations;
import org.eclipse.osgi.internal.location.LocationHelper;
import org.eclipse.osgi.internal.log.EquinoxLogServices;
import org.eclipse.osgi.internal.messages.Msg;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.osgi.service.debug.DebugOptions;
import org.eclipse.osgi.service.environment.Constants;
import org.eclipse.osgi.service.environment.EnvironmentInfo;
import org.eclipse.osgi.util.ManifestElement;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.Version;
import org.osgi.framework.wiring.BundleRevision;
/**
* Internal class.
*/
public class EquinoxConfiguration implements EnvironmentInfo {
private static final String CONFIG_FILE = "config.ini"; //$NON-NLS-1$
// While we recognize the SunOS operating system, we change
// this internally to be Solaris.
private static final String INTERNAL_OS_SUNOS = "SunOS"; //$NON-NLS-1$
private static final String INTERNAL_OS_LINUX = "Linux"; //$NON-NLS-1$
private static final String INTERNAL_OS_MACOSX = "Mac OS"; //$NON-NLS-1$
private static final String INTERNAL_OS_AIX = "AIX"; //$NON-NLS-1$
private static final String INTERNAL_OS_HPUX = "HP-UX"; //$NON-NLS-1$
private static final String INTERNAL_OS_QNX = "QNX"; //$NON-NLS-1$
private static final String INTERNAL_OS_OS400 = "OS/400"; //$NON-NLS-1$
private static final String INTERNAL_OS_OS390 = "OS/390"; //$NON-NLS-1$
private static final String INTERNAL_OS_ZOS = "z/OS"; //$NON-NLS-1$
private static final String INTERNAL_OS_FREEBSD = "FreeBSD"; //$NON-NLS-1$
// While we recognize the i386 architecture, we change
// this internally to be x86.
private static final String INTERNAL_ARCH_I386 = "i386"; //$NON-NLS-1$
// While we recognize the amd64 architecture, we change
// this internally to be x86_64.
private static final String INTERNAL_AMD64 = "amd64"; //$NON-NLS-1$
public static final String VARIABLE_DELIM_STRING = "$"; //$NON-NLS-1$
public static final char VARIABLE_DELIM_CHAR = '$';
private static final String DEV_FILE_ENTRY_VERSION_SEPARATOR = ";"; //$NON-NLS-1$
private final ConfigValues configValues;
private final Debug debug;
private final DebugOptions debugOptions;
private final HookRegistry hookRegistry;
private final AliasMapper aliasMapper = new AliasMapper();
private final EquinoxLocations equinoxLocations;
private volatile String[] allArgs;
private volatile String[] frameworkArgs;
private volatile String[] appArgs;
// dev mode fields
private final boolean inDevelopmentMode;
private final File devLocation;
private final Object devMonitor = new Object();
private String[] devDefaultClasspath;
private Map devProperties = null;
// timestamp for the dev.properties file
private long devLastModified = 0;
public final boolean contextBootDelegation;
public final boolean compatibilityBootDelegation;
public final boolean compatibilityLazyTriggerOnFailLoad;
public final List LIB_EXTENSIONS;
public final List ECLIPSE_LIB_VARIANTS;
public final boolean COPY_NATIVES;
public final List ECLIPSE_NL_JAR_VARIANTS;
public final boolean DEFINE_PACKAGE_ATTRIBUTES;
public final boolean BUNDLE_SET_TCCL;
public final int BSN_VERSION;
public static final int BSN_VERSION_SINGLE = 1;
public static final int BSN_VERSION_MULTIPLE = 2;
public static final int BSN_VERSION_MANAGED = 3;
public final boolean throwErrorOnFailedStart;
public final boolean CLASS_CERTIFICATE;
public final boolean PARALLEL_CAPABLE;
private final Map exceptions = new LinkedHashMap<>(0);
// JVM os.arch property name
public static final String PROP_JVM_OS_ARCH = "os.arch"; //$NON-NLS-1$
// JVM os.name property name
public static final String PROP_JVM_OS_NAME = "os.name"; //$NON-NLS-1$
// JVM os.version property name
public static final String PROP_JVM_OS_VERSION = "os.version"; //$NON-NLS-1$
public static final String PROP_JVM_SPEC_VERSION = "java.specification.version"; //$NON-NLS-1$
public static final String PROP_JVM_SPEC_NAME = "java.specification.name"; //$NON-NLS-1$
public static final String PROP_SETPERMS_CMD = "osgi.filepermissions.command"; //$NON-NLS-1$
public static final String PROP_DEBUG = "osgi.debug"; //$NON-NLS-1$
public static final String PROP_DEBUG_VERBOSE = "osgi.debug.verbose"; //$NON-NLS-1$
public static final String PROP_DEV = "osgi.dev"; //$NON-NLS-1$
public static final String PROP_CLEAN = "osgi.clean"; //$NON-NLS-1$
public static final String PROP_USE_SYSTEM_PROPERTIES = "osgi.framework.useSystemProperties"; //$NON-NLS-1$
public static final String PROP_FRAMEWORK = "osgi.framework"; //$NON-NLS-1$
public static final String ECLIPSE_FRAMEWORK_VENDOR = "Eclipse"; //$NON-NLS-1$
public static final String PROP_OSGI_JAVA_PROFILE = "osgi.java.profile"; //$NON-NLS-1$
public static final String PROP_OSGI_JAVA_PROFILE_NAME = "osgi.java.profile.name"; //$NON-NLS-1$
// OSGi java profile bootdelegation; used to indicate how the org.osgi.framework.bootdelegation
// property defined in the java profile should be processed, (ingnore, override, none). default is ignore
public static final String PROP_OSGI_JAVA_PROFILE_BOOTDELEGATION = "osgi.java.profile.bootdelegation"; //$NON-NLS-1$
// indicates that the org.osgi.framework.bootdelegation in the java profile should be ingored
public static final String PROP_OSGI_BOOTDELEGATION_IGNORE = "ignore"; //$NON-NLS-1$
// indicates that the org.osgi.framework.bootdelegation in the java profile should override the system property
public static final String PROP_OSGI_BOOTDELEGATION_OVERRIDE = "override"; //$NON-NLS-1$
// indicates that the org.osgi.framework.bootdelegation in the java profile AND the system properties should be ignored
public static final String PROP_OSGI_BOOTDELEGATION_NONE = "none"; //$NON-NLS-1$
public static final String PROP_CONTEXT_BOOTDELEGATION = "osgi.context.bootdelegation"; //$NON-NLS-1$
public static final String PROP_COMPATIBILITY_BOOTDELEGATION = "osgi.compatibility.bootdelegation"; //$NON-NLS-1$
public static final String PROP_DS_DELAYED_KEEPINSTANCES = "ds.delayed.keepInstances"; //$NON-NLS-1$
public static final String PROP_COMPATIBILITY_ERROR_FAILED_START = "osgi.compatibility.errorOnFailedStart"; //$NON-NLS-1$
public static final String PROP_COMPATIBILITY_START_LAZY = "osgi.compatibility.eagerStart.LazyActivation"; //$NON-NLS-1$
public static final String PROP_COMPATIBILITY_START_LAZY_ON_FAIL_CLASSLOAD = "osgi.compatibility.trigger.lazyActivation.onFailedClassLoad"; //$NON-NLS-1$
public static final String PROP_OSGI_OS = "osgi.os"; //$NON-NLS-1$
public static final String PROP_OSGI_WS = "osgi.ws"; //$NON-NLS-1$
public static final String PROP_OSGI_ARCH = "osgi.arch"; //$NON-NLS-1$
public static final String PROP_OSGI_NL = "osgi.nl"; //$NON-NLS-1$
public static final String PROP_OSGI_NL_USER = "osgi.nl.user"; //$NON-NLS-1$
public static final String PROP_ROOT_LOCALE = "equinox.root.locale"; //$NON-NLS-1$
public static final String PROP_PARENT_CLASSLOADER = "osgi.parentClassloader"; //$NON-NLS-1$
// A parent classloader type that specifies the framework classlaoder
public static final String PARENT_CLASSLOADER_FWK = "fwk"; //$NON-NLS-1$
// System property used to set the context classloader parent classloader type (ccl is the default)
public static final String PROP_CONTEXTCLASSLOADER_PARENT = "osgi.contextClassLoaderParent"; //$NON-NLS-1$
public static final String CONTEXTCLASSLOADER_PARENT_APP = "app"; //$NON-NLS-1$
public static final String CONTEXTCLASSLOADER_PARENT_EXT = "ext"; //$NON-NLS-1$
public static final String CONTEXTCLASSLOADER_PARENT_BOOT = "boot"; //$NON-NLS-1$
public static final String CONTEXTCLASSLOADER_PARENT_FWK = "fwk"; //$NON-NLS-1$
public static final String PROP_FRAMEWORK_LIBRARY_EXTENSIONS = "osgi.framework.library.extensions"; //$NON-NLS-1$
public static final String PROP_COPY_NATIVES = "osgi.classloader.copy.natives"; //$NON-NLS-1$
public static final String PROP_DEFINE_PACKAGES = "osgi.classloader.define.packages"; //$NON-NLS-1$
public static final String PROP_BUNDLE_SETTCCL = "eclipse.bundle.setTCCL"; //$NON-NLS-1$
public static final String PROP_EQUINOX_SECURITY = "eclipse.security"; //$NON-NLS-1$
public static final String PROP_FILE_LIMIT = "osgi.bundlefile.limit"; //$NON-NLS-1$
public final static String PROP_CLASS_CERTIFICATE_SUPPORT = "osgi.support.class.certificate"; //$NON-NLS-1$
public final static String PROP_CLASS_LOADER_TYPE = "osgi.classloader.type"; //$NON-NLS-1$
public final static String CLASS_LOADER_TYPE_PARALLEL = "parallel"; //$NON-NLS-1$
public static final String PROP_FORCED_RESTART = "osgi.forcedRestart"; //$NON-NLS-1$
public static final String PROP_IGNORE_USER_CONFIGURATION = "eclipse.ignoreUserConfiguration"; //$NON-NLS-1$
public static final String PROPERTY_STRICT_BUNDLE_ENTRY_PATH = "osgi.strictBundleEntryPath";//$NON-NLS-1$
public static final String PROP_CHECK_CONFIGURATION = "osgi.checkConfiguration"; //$NON-NLS-1$
private final boolean inCheckConfigurationMode;
public static final String DEFAULT_STATE_SAVE_DELAY_INTERVAL = "30000"; //$NON-NLS-1$
public static final String PROP_STATE_SAVE_DELAY_INTERVAL = "eclipse.stateSaveDelayInterval"; //$NON-NLS-1$
public static final String PROP_MODULE_LOCK_TIMEOUT = "osgi.module.lock.timeout"; //$NON-NLS-1$
public static final String PROP_MODULE_AUTO_START_ON_RESOLVE = "osgi.module.auto.start.on.resolve"; //$NON-NLS-1$
public static final String PROP_ALLOW_RESTRICTED_PROVIDES = "osgi.equinox.allow.restricted.provides"; //$NON-NLS-1$
public static final String PROP_LOG_HISTORY_MAX = "equinox.log.history.max"; //$NON-NLS-1$
public static final String PROP_LOG_CAPTURE_ENTRY_LOCATION = "equinox.log.capture.entry.location"; //$NON-NLS-1$
@Deprecated
public static final String PROP_RESOLVER_THREAD_COUNT = "equinox.resolver.thead.count"; //$NON-NLS-1$
public static final String PROP_EQUINOX_RESOLVER_THREAD_COUNT = "equinox.resolver.thread.count"; //$NON-NLS-1$
public static final String PROP_EQUINOX_START_LEVEL_THREAD_COUNT = "equinox.start.level.thread.count"; //$NON-NLS-1$
public static final String PROP_EQUINOX_START_LEVEL_RESTRICT_PARALLEL = "equinox.start.level.restrict.parallel"; //$NON-NLS-1$
public static final String PROP_RESOLVER_REVISION_BATCH_SIZE = "equinox.resolver.revision.batch.size"; //$NON-NLS-1$
public static final String PROP_RESOLVER_BATCH_TIMEOUT = "equinox.resolver.batch.timeout"; //$NON-NLS-1$
public static final String PROP_SYSTEM_PROVIDE_HEADER = "equinox.system.provide.header"; //$NON-NLS-1$
public static final String SYSTEM_PROVIDE_HEADER_ORIGINAL = "original"; //$NON-NLS-1$
public static final String SYSTEM_PROVIDE_HEADER_SYSTEM = "system"; //$NON-NLS-1$
public static final String SYSTEM_PROVIDE_HEADER_SYSTEM_EXTRA = "system.extra"; //$NON-NLS-1$
public static final String PROP_DEFAULT_SUFFIX = ".default"; //$NON-NLS-1$
public static final Collection PROP_WITH_ECLIPSE_STARTER_DEFAULTS = Collections.unmodifiableList(Arrays.asList(PROP_COMPATIBILITY_BOOTDELEGATION, PROP_DS_DELAYED_KEEPINSTANCES));
public static final String PROP_INIT_UUID = "equinox.init.uuid"; //$NON-NLS-1$
public static final String PROP_ACTIVE_THREAD_TYPE = "osgi.framework.activeThreadType"; //$NON-NLS-1$
public static final String ACTIVE_THREAD_TYPE_NORMAL = "normal"; //$NON-NLS-1$
public static final String PROP_GOSH_ARGS = "gosh.args"; //$NON-NLS-1$
public static final String PROP_SECURE_UUID = "equinox.uuid.secure"; //$NON-NLS-1$
public final static String SIGNED_BUNDLE_SUPPORT = "osgi.support.signature.verify"; //$NON-NLS-1$
public final static String SIGNED_CONTENT_SUPPORT = "osgi.signedcontent.support"; //$NON-NLS-1$
public static final int SIGNED_CONTENT_VERIFY_CERTIFICATE = 0x01;
public static final int SIGNED_CONTENT_VERIFY_TRUST = 0x02;
public static final int SIGNED_CONTENT_VERIFY_RUNTIME = 0x04;
public static final int SIGNED_CONTENT_VERIFY_ALL = SIGNED_CONTENT_VERIFY_CERTIFICATE | SIGNED_CONTENT_VERIFY_TRUST
| SIGNED_CONTENT_VERIFY_RUNTIME;
private final static String SIGNED_CONTENT_SUPPORT_CERTIFICATE = "certificate"; //$NON-NLS-1$
private final static String SIGNED_CONTENT_SUPPORT_TRUST = "trust"; //$NON-NLS-1$
private final static String SIGNED_CONTENT_SUPPORT_RUNTIME = "runtime"; //$NON-NLS-1$
private final static String SIGNED_CONTENT_SUPPORT_ALL = "all"; //$NON-NLS-1$
private final static String SIGNED_CONTENT_SUPPORT_TRUE = "true"; //$NON-NLS-1$
public final int supportSignedBundles;
public final boolean runtimeVerifySignedBundles;
public static final class ConfigValues {
/**
* Value of {@link #localConfig} properties that should be considered
* null and for which access should not fall back to
* {@link System#getProperty(String)}.
* The instance must be compared by identity (==, not equals) and must not
* be leaked outside this class.
*/
private final static String NULL_CONFIG = new String("org.eclipse.equinox.configuration.null.value"); //$NON-NLS-1$
private final static Collection populateInitConfig = Arrays.asList(PROP_OSGI_ARCH, PROP_OSGI_OS, PROP_OSGI_WS, PROP_OSGI_NL, FRAMEWORK_OS_NAME, FRAMEWORK_OS_VERSION, FRAMEWORK_PROCESSOR, FRAMEWORK_LANGUAGE);
private final boolean useSystemProperties;
private final Map initialConfig;
private final Properties localConfig;
private final Map exceptions;
public ConfigValues(Map initialConfiguration, Map exceptions) {
this.exceptions = exceptions;
this.initialConfig = initialConfiguration == null ? new HashMap<>(0) : new HashMap<>(initialConfiguration);
Object useSystemPropsValue = initialConfig.get(PROP_USE_SYSTEM_PROPERTIES);
this.useSystemProperties = useSystemPropsValue == null ? false : Boolean.parseBoolean(useSystemPropsValue.toString());
Properties tempConfiguration = useSystemProperties ? EquinoxContainer.secureAction.getProperties() : new Properties();
// do this the hard way to handle null values
for (Map.Entry initialEntry : this.initialConfig.entrySet()) {
if (initialEntry.getValue() == null) {
if (useSystemProperties) {
tempConfiguration.remove(initialEntry.getKey());
} else {
tempConfiguration.put(initialEntry.getKey(), NULL_CONFIG);
}
} else {
tempConfiguration.put(initialEntry.getKey(), initialEntry.getValue());
}
}
localConfig = useSystemProperties ? null : tempConfiguration;
}
void loadConfigIni(URL configIni) {
if (configIni != null) {
mergeConfiguration(loadProperties(configIni));
}
}
void finalizeValues() {
// populate initConfig after loading the configIni
for (String initialKey : populateInitConfig) {
String value = getConfiguration(initialKey);
if (value != null) {
this.initialConfig.put(initialKey, value);
}
}
// look for special case EclipseStarter defaults
for (String keyWithEclipseStarterDefault : PROP_WITH_ECLIPSE_STARTER_DEFAULTS) {
String currentValue = getConfiguration(keyWithEclipseStarterDefault);
if (currentValue == null) {
String defaultValue = getConfiguration(keyWithEclipseStarterDefault + PROP_DEFAULT_SUFFIX);
if (defaultValue != null) {
setConfiguration(keyWithEclipseStarterDefault, defaultValue);
}
}
}
// set other defaults
if (FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT.equals(getConfiguration(FRAMEWORK_STORAGE_CLEAN))) {
setConfiguration(PROP_CLEAN, "true"); //$NON-NLS-1$
}
if (getConfiguration(PROP_STATE_SAVE_DELAY_INTERVAL) == null)
// Property not specified. Use the default.
setConfiguration(PROP_STATE_SAVE_DELAY_INTERVAL, DEFAULT_STATE_SAVE_DELAY_INTERVAL);
try {
// Verify type compatibility.
Long.parseLong(getConfiguration(PROP_STATE_SAVE_DELAY_INTERVAL));
} catch (NumberFormatException e) {
exceptions.put(e, FrameworkLogEntry.ERROR);
// The specified value is not type compatible. Use the default.
setConfiguration(PROP_STATE_SAVE_DELAY_INTERVAL, DEFAULT_STATE_SAVE_DELAY_INTERVAL);
}
if (getConfiguration(PROP_GOSH_ARGS) == null) {
String consoleProp = getConfiguration(ConsoleManager.PROP_CONSOLE);
consoleProp = consoleProp == null ? null : consoleProp.trim();
if (consoleProp == null || consoleProp.length() > 0) {
// no -console was specified or it has specified none or a port for telnet;
// need to make sure the gogo shell does not create an interactive console on standard in/out
setConfiguration(PROP_GOSH_ARGS, "--nointeractive"); //$NON-NLS-1$
} else {
// Need to make sure we don't shutdown the framework if no console is around (bug 362412)
setConfiguration(PROP_GOSH_ARGS, "--noshutdown"); //$NON-NLS-1$
}
}
}
private void mergeConfiguration(Properties source) {
for (Enumeration e = source.keys(); e.hasMoreElements();) {
String key = (String) e.nextElement();
String value = source.getProperty(key);
if (getConfiguration(key) == null) {
setProperty(key, value);
initialConfig.put(key, value);
} else {
initialConfig.put(key, getConfiguration(key));
}
}
}
private Properties loadProperties(URL location) {
Properties result = new Properties();
if (location == null)
return result;
try {
try (InputStream in = LocationHelper.getStream(location)) {
result.load(in);
}
} catch (FileNotFoundException e) {
// TODO probably should log, but the common case for non-eclipse
// environments would be to not have a config.ini ...
} catch (IOException e) {
// We'll just use the defaults for everything but log the exception on reading
exceptions.put(e, FrameworkLogEntry.WARNING);
}
return substituteVars(result);
}
private Properties substituteVars(Properties result) {
if (result == null) {
//nothing todo.
return null;
}
for (Enumeration