Skip to content

Commit

Permalink
Merge pull request #4626 from keithc-ca/shapes
Browse files Browse the repository at this point in the history
Remove dead code for obsolete Java 9 'shapes'
  • Loading branch information
pshipton authored Feb 6, 2019
2 parents 0cff4ec + c4ff462 commit 49370cc
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 195 deletions.
38 changes: 6 additions & 32 deletions runtime/j9vm/java11vmi.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015, 2018 IBM Corp. and others
* Copyright (c) 2015, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -98,7 +98,6 @@ static UDATA hashTableAtPut(J9HashTable * table, void * value, BOOLEAN collision
static void throwExceptionHelper(J9VMThread * currentThread, UDATA errCode);
static void freePackage(J9VMThread * currentThread, J9Package * j9package);
static J9ClassLoader * getModuleObjectClassLoader(J9VMThread * currentThread, j9object_t moduleObject);
static j9object_t getModuleObjectName(J9VMThread * currentThread, j9object_t moduleObject);
static J9Module * createModule(J9VMThread * currentThread, j9object_t moduleObject, J9ClassLoader * classLoader, j9object_t moduleName);
static J9Module * getJ9Module(J9VMThread * currentThread, jobject module);
static BOOLEAN isModuleNameValid(j9object_t moduleName);
Expand Down Expand Up @@ -256,12 +255,7 @@ createPackage(J9VMThread * currentThread, J9Module * fromModule, j9object_t pack
static J9ClassLoader *
getModuleObjectClassLoader(J9VMThread * currentThread, j9object_t moduleObject)
{
j9object_t classLoader = NULL;
if(J2SE_SHAPE(currentThread->javaVM) < J2SE_SHAPE_B165) {
classLoader = J9VMJAVALANGREFLECTMODULE_LOADER(currentThread, moduleObject);
} else {
classLoader = J9VMJAVALANGMODULE_LOADER(currentThread, moduleObject);
}
j9object_t classLoader = J9VMJAVALANGMODULE_LOADER(currentThread, moduleObject);
if (NULL == classLoader) {
return currentThread->javaVM->systemClassLoader;
} else {
Expand All @@ -274,19 +268,6 @@ getModuleObjectClassLoader(J9VMThread * currentThread, j9object_t moduleObject)
}
}

/** @note It assumes moduleObject is guaranteed not to be NULL
* @return Java String containing module name.
*/
static j9object_t
getModuleObjectName(J9VMThread * currentThread, j9object_t moduleObject)
{
if(J2SE_SHAPE(currentThread->javaVM) < J2SE_SHAPE_B165) {
return J9VMJAVALANGREFLECTMODULE_NAME(currentThread, moduleObject);
} else {
return J9VMJAVALANGMODULE_NAME(currentThread, moduleObject);
}
}

/** @throws OutOfMemory exception if memory cannot be allocated */
static J9Module *
createModule(J9VMThread * currentThread, j9object_t moduleObject, J9ClassLoader * classLoader, j9object_t moduleName)
Expand Down Expand Up @@ -941,7 +922,7 @@ JVM_DefineModule(JNIEnv * env, jobject module, jstring version, jstring location
j9object_t modObj = J9_JNI_UNWRAP_REFERENCE(module);

J9ClassLoader * const classLoader = getModuleObjectClassLoader(currentThread, modObj);
j9object_t moduleName = getModuleObjectName(currentThread, modObj);
j9object_t moduleName = J9VMJAVALANGMODULE_NAME(currentThread, modObj);

#if J9VM_JAVA9_BUILD >= 156
if ((classLoader != vm->systemClassLoader) && (classLoader != vm->platformClassLoader)) {
Expand Down Expand Up @@ -1561,17 +1542,10 @@ JVM_SetBootLoaderUnnamedModule(JNIEnv *env, jobject module) {
j9object_t modObj = J9_JNI_UNWRAP_REFERENCE(module);
J9ClassLoader *systemClassLoader = vm->systemClassLoader;
J9Class *instanceClazz = J9OBJECT_CLAZZ(currentThread, modObj);
J9Class *moduleClass = NULL;
if (J2SE_SHAPE(vm) < J2SE_SHAPE_B165) {
moduleClass = vmFuncs->internalFindKnownClass(currentThread,
J9VMCONSTANTPOOL_JAVALANGREFLECTMODULE,
J9_FINDKNOWNCLASS_FLAG_INITIALIZE);
} else {
moduleClass = vmFuncs->internalFindKnownClass(currentThread,
J9VMCONSTANTPOOL_JAVALANGMODULE,
J9_FINDKNOWNCLASS_FLAG_INITIALIZE);
}
if (!currentThread->currentException) {
J9Class *moduleClass = vmFuncs->internalFindKnownClass(currentThread,
J9VMCONSTANTPOOL_JAVALANGMODULE,
J9_FINDKNOWNCLASS_FLAG_INITIALIZE);
if (!isModuleUnnamed(currentThread, modObj)) {
vmFuncs->setCurrentExceptionUTF(currentThread, J9VMCONSTANTPOOL_JAVALANGILLEGALARGUMENTEXCEPTION, "named module was supplied");
} else if (!isSameOrSuperClassOf(moduleClass, instanceClazz)) {
Expand Down
41 changes: 15 additions & 26 deletions runtime/j9vm/jvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1287,56 +1287,42 @@ jio_vsnprintf(char * str, int n, const char * format, va_list args)
}

typedef struct VersionSetting {
char* key;
const char* key;
UDATA value;
} VersionSetting;


/**
* Table to map textual props file entries to numeric constants.
* The 'b' levels are sorted in ascending order, and camparison of the shape value from classlib.properties
* with the keys starts from last entry in this table, the lower and closest key to the the shape value is returned.
* For example, a shape value 'b140' will match to 'b136' and J2SE_SHAPE_B136 is returned;
* If a shape value specified such as b72 is less than smallest existing key (i.e. b135), an error is printed.
*
* !!! Note about "b135" ==> J2SE_SHAPE_B136 !!!
* For historic reason, J2SE_SHAPE_B136 was introduced when actual build level 135 was used.
* Mapping b135 to J2SE_SHAPE_B136 (changed from previous b136) allows both shape b135 & b136 working
* and avoid naming change from J2SE_SHAPE_B136 to J2SE_SHAPE_B135.
* This will be removed when a new stable JCL build level is determined and b135 is obsolete.
*
* Note: shapes "sun" and "sun_openjdk" here are for accommodation of such values within Java 8 classlib.properties.
* Both shapes are mapped to J2SE_SHAPE_OPENJDK to indicate a Java 8 SDK.
*/
VersionSetting SHAPE_SETTINGS[] = {
static const VersionSetting SHAPE_SETTINGS[] = {
{"sun", J2SE_SHAPE_OPENJDK},
{"sun_openjdk", J2SE_SHAPE_OPENJDK},
{"raw", J2SE_SHAPE_RAW},
{"rawplusj9", J2SE_SHAPE_RAWPLUSJ9},
{"b135", J2SE_SHAPE_B136},
{"b148", J2SE_SHAPE_B148},
{"b165", J2SE_SHAPE_B165},
{"b1000", J2SE_SHAPE_V10},
};
#define NUM_SHAPE_SETTINGS (sizeof(SHAPE_SETTINGS) / sizeof(VersionSetting))

/**
* Table to map textual props file entries to numeric constants.
*/
VersionSetting VERSION_SETTINGS[] = {
static const VersionSetting VERSION_SETTINGS[] = {
{"1.8", J2SE_18},
{"1.9", J2SE_19}
};
#define NUM_VERSION_SETTINGS (sizeof(VERSION_SETTINGS) / sizeof(VersionSetting))


static UDATA
decodeSetting(const char* key, const char* value, VersionSetting* settings, IDATA numSettings)
decodeSetting(const char* key, const char* value, const VersionSetting* settings, IDATA numSettings)
{
IDATA index = 0;

for (index = 0; index < numSettings; index++) {
VersionSetting *setting = &settings[index];
const VersionSetting *setting = &settings[index];
if (!strcmp(value, setting->key)) {
return setting->value;
}
Expand All @@ -1350,7 +1336,7 @@ decodeSetting(const char* key, const char* value, VersionSetting* settings, IDAT
int levelValue = atoi((const char*)(value + 1));
if (levelValue > 0) {
for (index = numSettings - 1; index >= 0; index--) {
VersionSetting *setting = &settings[index];
const VersionSetting *setting = &settings[index];
if ('b' == *setting->key) {
int keyNbr = atoi((const char*)(setting->key + 1));
if (keyNbr > 0) {
Expand All @@ -1371,7 +1357,7 @@ decodeSetting(const char* key, const char* value, VersionSetting* settings, IDAT
#if defined(DEBUG)
printf("Valid choices are: ");
for (index=0; index < numSettings; index++) {
VersionSetting* setting = &settings[index];
const VersionSetting* setting = &settings[index];
printf("%s", setting->key);
if (index != numSettings-1)
printf(", ");
Expand Down Expand Up @@ -1453,16 +1439,19 @@ getVersionFromClasslibPropertiesFile(void)
* Attempt loading 'release' file, and get Java version info.
* If the file is found, 'JAVA_VERSION' value is retrieved and decoded as following:
* "1.8.0_xxx" --- Java 8, 'J2SE_18 | J2SE_SHAPE_OPENJDK';
* "9[.x.x]" --- Java 9, 'J2SE_19 | J2SE_SHAPE_B165';
* "9[.x.x]" --- Java 9, 'J2SE_19 | J2SE_SHAPE_V9';
* "10[.x.x]" --- Java 10, 'J2SE_V10 | J2SE_SHAPE_V10';
* "11[.x.x]" --- Java 11, 'J2SE_V11 | J2SE_SHAPE_V11';
* "12[.x.x]" --- Java 12, 'J2SE_V12 | J2SE_SHAPE_V12';
* Others --- Latest Java, 'J2SE_LATEST | J2SE_SHAPE_LATEST'.
* Otherwise, 0 is returned.
*
* @return 'J2SE_18 | J2SE_SHAPE_OPENJDK', 'J2SE_19 | J2SE_SHAPE_B165',
* 'J2SE_V10 | J2SE_SHAPE_V10', 'J2SE_V11 | J2SE_SHAPE_V11',
* 'J2SE_V12 | J2SE_SHAPE_V12', 'J2SE_LATEST | J2SE_SHAPE_LATEST'
* @return 'J2SE_18 | J2SE_SHAPE_OPENJDK',
* 'J2SE_19 | J2SE_SHAPE_V9',
* 'J2SE_V10 | J2SE_SHAPE_V10',
* 'J2SE_V11 | J2SE_SHAPE_V11',
* 'J2SE_V12 | J2SE_SHAPE_V12',
* 'J2SE_LATEST | J2SE_SHAPE_LATEST'
* according to the 'JAVA_VERSION' value found in 'release';
* or 0 if otherwise.
*/
Expand All @@ -1489,7 +1478,7 @@ getVersionFromReleaseFile(void)
#define JAVA_VERSION_9 "\"9" /* its usual format is "9[.x.x]" */
} else if (!strncmp(version, JAVA_VERSION_9, sizeof(JAVA_VERSION_9) - 1)) {
#undef JAVA_VERSION_9
finalVersion = J2SE_19 | J2SE_SHAPE_B165;
finalVersion = J2SE_19 | J2SE_SHAPE_V9;
#define JAVA_VERSION_10 "\"10" /* its usual format is "10[.x.x]" */
} else if (!strncmp(version, JAVA_VERSION_10, sizeof(JAVA_VERSION_10) - 1)) {
#undef JAVA_VERSION_10
Expand Down
12 changes: 3 additions & 9 deletions runtime/jcl/common/jclcinit.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1998, 2018 IBM Corp. and others
* Copyright (c) 1998, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -596,14 +596,8 @@ initializeRequiredClasses(J9VMThread *vmThread, char* dllName)
vmFuncs->internalAcquireVMAccess(vmThread);

/* request an extra slot in java/lang/Module which we will use to connect native data to the Module object */
if(J2SE_SHAPE(vm) < J2SE_SHAPE_B165) {
if (0 != vmFuncs->addHiddenInstanceField(vm, "java/lang/reflect/Module", "modulePointer", "J", &vm->modulePointerOffset)) {
return 1;
}
} else {
if (0 != vmFuncs->addHiddenInstanceField(vm, "java/lang/Module", "modulePointer", "J", &vm->modulePointerOffset)) {
return 1;
}
if (0 != vmFuncs->addHiddenInstanceField(vm, "java/lang/Module", "modulePointer", "J", &vm->modulePointerOffset)) {
return 1;
}

vmThread->privateFlags |= J9_PRIVATE_FLAGS_REPORT_ERROR_LOADING_CLASS;
Expand Down
4 changes: 2 additions & 2 deletions runtime/jcl/common/system.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1998, 2018 IBM Corp. and others
* Copyright (c) 1998, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -521,7 +521,7 @@ Java_java_lang_System_startSNMPAgent(JNIEnv *env, jclass jlClass)
jclass smAClass = NULL;
jmethodID startAgent = NULL;

if ((J2SE_VERSION(vm) >= J2SE_19) && (J2SE_SHAPE(vm) >= J2SE_SHAPE_B165)) {
if (J2SE_VERSION(vm) >= J2SE_19) {
smAClass = (*env)->FindClass(env, "jdk/internal/agent/Agent");
} else {
smAClass = (*env)->FindClass(env, "sun/management/Agent");
Expand Down
Loading

0 comments on commit 49370cc

Please sign in to comment.