Skip to content

Commit

Permalink
Automerge master into ibm_sdk 2017-10-25-18:00:23
Browse files Browse the repository at this point in the history
  • Loading branch information
j9build committed Oct 25, 2017
2 parents 03788a5 + fd93197 commit 98c1ffc
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 73 deletions.
187 changes: 139 additions & 48 deletions runtime/j9vm/jvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ static J9StringBuffer * j9binBuffer = NULL;
static J9StringBuffer * jrebinBuffer = NULL;
static J9StringBuffer * j9libBuffer = NULL;
static J9StringBuffer * j9libvmBuffer = NULL;
static J9StringBuffer * j9Buffer = NULL;
static BOOLEAN jvmInSubdir=TRUE;

#if !CALL_BUNDLED_FUNCTIONS_DIRECTLY
Expand Down Expand Up @@ -337,10 +338,11 @@ static void freeGlobals(void)

free(j9libvmBuffer);
j9libvmBuffer = NULL;

free(j9Buffer);
j9Buffer = NULL;
}



static J9StringBuffer* jvmBufferEnsure(J9StringBuffer* buffer, UDATA len) {

if (buffer == NULL) {
Expand Down Expand Up @@ -521,6 +523,8 @@ preloadLibraries(void)

j9libBuffer = jvmBufferCat(NULL, jvmBufferData(jrebinBuffer));
truncatePath(jvmBufferData(j9libBuffer));
j9Buffer = jvmBufferCat(NULL, jvmBufferData(j9libBuffer));
truncatePath(jvmBufferData(j9Buffer));
j9libBuffer = jvmBufferCat(j9libBuffer, DIR_SEPARATOR_STR "lib");

j9libvmBuffer = jvmBufferCat(NULL, jvmBufferData(j9libBuffer));
Expand All @@ -534,7 +538,8 @@ preloadLibraries(void)
DBG_MSG(("jrebinBuffer = <%s>\n", jvmBufferData(jrebinBuffer)));
DBG_MSG(("j9libBuffer = <%s>\n", jvmBufferData(j9libBuffer)));
DBG_MSG(("j9libvmBuffer = <%s>\n", jvmBufferData(j9libvmBuffer)));

DBG_MSG(("j9Buffer = <%s>\n", jvmBufferData(j9Buffer)));

#if !CALL_BUNDLED_FUNCTIONS_DIRECTLY
vmDLL = (HINSTANCE) preloadLibrary(vmDllName, TRUE);
preloadLibrary(J9_HOOKABLE_DLL_NAME, TRUE);
Expand Down Expand Up @@ -924,11 +929,14 @@ preloadLibraries(void)
truncatePath(jvmBufferData(j9libBuffer));
#endif /* J9VM_JAVA9_BUILD < 150 */
j9libvmBuffer = jvmBufferCat(NULL, jvmBufferData(j9binBuffer));
j9Buffer = jvmBufferCat(NULL, jvmBufferData(jrebinBuffer));
truncatePath(jvmBufferData(j9Buffer));

DBG_MSG(("j9binBuffer = <%s>\n", jvmBufferData(j9binBuffer)));
DBG_MSG(("jrebinBuffer = <%s>\n", jvmBufferData(jrebinBuffer)));
DBG_MSG(("j9libBuffer = <%s>\n", jvmBufferData(j9libBuffer)));
DBG_MSG(("j9libvmBuffer = <%s>\n", jvmBufferData(j9libvmBuffer)));
DBG_MSG(("j9Buffer = <%s>\n", jvmBufferData(j9Buffer)));

addToLibpath(jvmBufferData(jrebinBuffer), TRUE);

Expand Down Expand Up @@ -1218,73 +1226,156 @@ decodeSetting(const char* key, const char* value, VersionSetting* settings, IDAT
}

/**
* Loads the classlib.properties file and initialize the bootstrap
* classpath based on data found there.
* @param vm
* @param cursor
* @return TRUE on success, FALSE otherwise.
* Attempt loading 'classlib.properties' file, and get Java version info.
* If the file is found, 'version' and 'shape' values are retrieved
* and decoded as J2SE_xx and J2SE_SHAPE_xx accordingly.
* 'J2SE_xx | J2SE_SHAPE_xx' is returned;
* Otherwise, 0 is returned.
*
* @return 'J2SE_xx | J2SE_SHAPE_xx' decoded from 'version' and 'shape' values in 'classlib.properties';
* or 0 if otherwise.
*/
static UDATA
getVersionFromClasslibPropertiesFile(void)
{
if (-1 != jvmSEVersion) {
return jvmSEVersion;
} else {
PORT_ACCESS_FROM_PORT(&j9portLibrary);
J9StringBuffer * propsPathBuffer = NULL;
j9props_file_t classlibProps;
const char* shape;
const char* version;
UDATA decoded, finalVersion = 0;

propsPathBuffer = jvmBufferCat(propsPathBuffer, jvmBufferData(j9libBuffer));
propsPathBuffer = jvmBufferCat(propsPathBuffer, DIR_SEPARATOR_STR "classlib.properties");

classlibProps = props_file_open(PORTLIB, jvmBufferData(propsPathBuffer), NULL, 0);

free(propsPathBuffer);
propsPathBuffer = NULL;

if (NULL == classlibProps) {
#ifdef DEBUG
printf("Could not open %s\n", classlibProps);
#endif
return J2SE_LATEST|J2SE_SHAPE_LATEST;
}

shape = props_file_get(classlibProps, "shape");
PORT_ACCESS_FROM_PORT(&j9portLibrary);
J9StringBuffer *propsPathBuffer = NULL;
j9props_file_t propsFile = NULL;
UDATA finalVersion = 0;

propsPathBuffer = jvmBufferCat(propsPathBuffer, jvmBufferData(j9libBuffer));
propsPathBuffer = jvmBufferCat(propsPathBuffer, DIR_SEPARATOR_STR "classlib.properties");
propsFile = props_file_open(PORTLIB, jvmBufferData(propsPathBuffer), NULL, 0);
free(propsPathBuffer);
propsPathBuffer = NULL;

if (NULL != propsFile) {
const char *shape = NULL;
const char *version = NULL;
UDATA decoded = 0;

shape = props_file_get(propsFile, "shape");
if (NULL == shape) {
#ifdef DEBUG
printf("No 'shape' property in %s\n", classlibProps);
#endif
#ifdef DEBUG
printf("No 'shape' property in %s\n", propsFile);
#endif
goto bail;
}

version = props_file_get(classlibProps, "version");
version = props_file_get(propsFile, "version");
if (NULL == version) {
#ifdef DEBUG
printf("No 'version' property in %s\n", classlibProps);
#endif
#ifdef DEBUG
printf("No 'version' property in %s\n", propsFile);
#endif
goto bail;
}

decoded = decodeSetting("shape", shape, SHAPE_SETTINGS, NUM_SHAPE_SETTINGS);
if (decoded == 0) {
if (0 == decoded) {
goto bail;
}
finalVersion |= decoded;

decoded = decodeSetting("version", version, VERSION_SETTINGS, NUM_VERSION_SETTINGS);
if (decoded == 0) {
if (0 == decoded) {
goto bail;
}
finalVersion |= decoded;

bail:
props_file_close(classlibProps);
bail:
props_file_close(propsFile);
} else {
#ifdef DEBUG
printf("Could not open %s\n", propsFile);
#endif
}

return finalVersion;
}

/**
* 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_SUN';
* "9" --- Java 9, 'J2SE_19 | J2SE_SHAPE_B165';
* "10" --- Java 18.3, 'J2SE_2018_3 | J2SE_SHAPE_B1803';
* Others --- Latest Java, 'J2SE_LATEST | J2SE_SHAPE_LATEST'.
* Note: 'release' file contains JAVA_VERSION="10" for Java 18.3 at this moment.
* Otherwise, 0 is returned.
*
* @return 'J2SE_18 | J2SE_SHAPE_SUN', 'J2SE_19 | J2SE_SHAPE_B165',
* 'J2SE_2018_3 | J2SE_SHAPE_B1803', 'J2SE_LATEST | J2SE_SHAPE_LATEST'
* according to the 'JAVA_VERSION' value found in 'release';
* or 0 if otherwise.
*/
static UDATA
getVersionFromReleaseFile(void)
{
PORT_ACCESS_FROM_PORT(&j9portLibrary);
J9StringBuffer *propsPathBuffer = NULL;
j9props_file_t propsFile = NULL;
UDATA finalVersion = 0;

propsPathBuffer = jvmBufferCat(propsPathBuffer, jvmBufferData(j9Buffer));
propsPathBuffer = jvmBufferCat(propsPathBuffer, DIR_SEPARATOR_STR "release");
propsFile = props_file_open(PORTLIB, jvmBufferData(propsPathBuffer), NULL, 0);
free(propsPathBuffer);
propsPathBuffer = NULL;
if (NULL != propsFile) {
const char *version = props_file_get(propsFile, "JAVA_VERSION");
if (NULL != version) {
#define JAVA_VERSION_8 "\"1.8.0" /* its usual format is "1.8.0_xxx" */
if (!strncmp(version, JAVA_VERSION_8, sizeof(JAVA_VERSION_8) - 1)) {
#undef JAVA_VERSION_8
finalVersion = J2SE_18 | J2SE_SHAPE_SUN;
} else if (!strcmp(version, "\"9\"")) {
finalVersion = J2SE_19 | J2SE_SHAPE_B165;
} else if (!strcmp(version, "\"10\"")) {
finalVersion = J2SE_2018_3 | J2SE_SHAPE_B1803;
} else {
/* Assume latest Java version and shape */
finalVersion = J2SE_LATEST | J2SE_SHAPE_LATEST;
}
} else {
#ifdef DEBUG
printf("No 'JAVA_VERSION' property in %s\n", propsFile);
#endif
}
props_file_close(propsFile);
} else {
#ifdef DEBUG
printf("Could not open %s\n", propsFile);
#endif
}

return finalVersion;
}

/**
* Get Java version of running JVM
* Attempt getting the Java version info from 'classlib.properties' first,
* if not successful, try 'release' file next,
* if still no version info found, 'J2SE_LATEST | J2SE_SHAPE_LATEST' is returned
*
* @return 'J2SE_xx | J2SE_SHAPE_xx' decoded from 'classlib.properties' or 'release',
* or 'J2SE_LATEST | J2SE_SHAPE_LATEST'.
*/
static UDATA
getVersionFromPropertiesFile(void)
{
if (-1 == jvmSEVersion) {
UDATA finalVersion = 0;

finalVersion = getVersionFromClasslibPropertiesFile();
if (0 == finalVersion) {
finalVersion = getVersionFromReleaseFile();
if (0 == finalVersion) {
return J2SE_LATEST | J2SE_SHAPE_LATEST;
}
}
jvmSEVersion = finalVersion;
return finalVersion;
}
return jvmSEVersion;
}

typedef struct J9SpecialArguments {
Expand Down Expand Up @@ -1786,7 +1877,7 @@ jint JNICALL JNI_CreateJavaVM(JavaVM **pvm, void **penv, void *vm_args) {
/* Register the J9 memory categories with the port library */
j9portLibrary.omrPortLibrary.port_control(&j9portLibrary.omrPortLibrary, J9PORT_CTLDATA_MEM_CATEGORIES_SET, (UDATA)&j9MasterMemCategorySet);

j2seVersion = getVersionFromClasslibPropertiesFile();
j2seVersion = getVersionFromPropertiesFile();
if (J2SE_17 > j2seVersion) {
fprintf(stderr, "Invalid version 0x%" J9PRIz "x detected in classlib.properties!\n", j2seVersion);
result = JNI_ERR;
Expand Down Expand Up @@ -5051,7 +5142,7 @@ jint JNICALL
JVM_GetInterfaceVersion(void)
{
jint result = 4;
UDATA j2seVersion = getVersionFromClasslibPropertiesFile();
UDATA j2seVersion = getVersionFromPropertiesFile();

if ((j2seVersion & J2SE_SERVICE_RELEASE_MASK) >= J2SE_19) {
result = 5;
Expand Down
4 changes: 3 additions & 1 deletion runtime/makelib/mkconstants.mk.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
</#list>

# Define the Java Version we are compiling
# This VERSION_MAJOR variable will be overridden by command line option
# when there is one such as VERSION_MAJOR=xx.
VERSION_MAJOR:=9
export VERSION_MAJOR

# Define a default target of the root directoy for all targets.
# Define a default target of the root directory for all targets.
ifndef UMA_TARGET_PATH
UMA_TARGET_PATH=$(UMA_PATH_TO_ROOT)
endif
Expand Down
45 changes: 21 additions & 24 deletions runtime/oti/j2sever.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,23 @@
* note: J2SE_15 needed for shared classes cache introspection but not supported by JVM.
*/
/*
* Note: J2SE_LATEST has to be updated to highest Java version supported by VM
* This allows JVM operates with latest version when classlib.properties doesn't present.
* Additional note:
* J2SE_LATEST will be kept as J2SE_19 while Java 18.3 raw build is being built.
* When a separate Java 18.3 binary is required, a #ifdef flag will be introduced to define
* J2SE_LATEST to different values accordingly such as following:
* #if J9VM_JAVA9_BUILD > 9
* #define J2SE_LATEST J2SE_1803
* #else
* #define J2SE_LATEST J2SE_19
* #endif
* Note: J2SE_LATEST is the highest Java version supported by VM for a JCL level.
* This allows JVM operates with latest version when neither classlib.properties
* nor release file presents.
*/
#define J2SE_15 0x1500
#define J2SE_16 0x1600
#define J2SE_17 0x1700
#define J2SE_18 0x1800
#define J2SE_19 0x1900
#define J2SE_LATEST J2SE_19
#define J2SE_2018_3 0xB700 /* 0xB7 is 183 which refers to Java 18.3 */
#if JAVA_SPEC_VERSION == 8
#define J2SE_LATEST J2SE_18
#elif JAVA_SPEC_VERSION == 9
#define J2SE_LATEST J2SE_19
#else
#define J2SE_LATEST J2SE_2018_3
#endif

/**
* Masks for extracting major and full versions.
Expand All @@ -59,19 +58,17 @@
* J2SE_SHAPE_RAW = Pure Oracle code without any IBM modifications
*/
/*
* Note: J2SE_SHAPE_LATEST has to be updated to highest JCL level supported by VM
* This allows JVM operates with latest level when classlib.properties doesn't present.
* Additional note:
* J2SE_SHAPE_LATEST will be kept as J2SE_SHAPE_B165 while Java 18.3 raw build is being built.
* When a separate Java 18.3 binary is required, a #ifdef flag will be introduced to define
* J2SE_SHAPE_B165 to different values accordingly such as following:
* #if J9VM_JAVA9_BUILD > 9
* #define J2SE_SHAPE_LATEST J2SE_SHAPE_B1803
* #else
* #define J2SE_SHAPE_LATEST J2SE_SHAPE_B165
* #endif
* Note: J2SE_SHAPE_LATEST is the highest JCL level supported by VM for a JCL level.
* This allows JVM operates with latest level when neither classlib.properties
* nor release file presents.
*/
#define J2SE_SHAPE_LATEST J2SE_SHAPE_B165
#if JAVA_SPEC_VERSION == 8
#define J2SE_SHAPE_LATEST J2SE_SHAPE_SUN
#elif JAVA_SPEC_VERSION == 9
#define J2SE_SHAPE_LATEST J2SE_SHAPE_B165
#else
#define J2SE_SHAPE_LATEST J2SE_SHAPE_B1803
#endif
#define J2SE_SHAPE_SUN 0x10000
#define J2SE_SHAPE_B136 0x40000
#define J2SE_SHAPE_B148 0x50000
Expand Down

0 comments on commit 98c1ffc

Please sign in to comment.