Briging ReadyForJVMCI closer to master

This commit is contained in:
Jaroslav Tulach
2017-11-29 06:30:41 +01:00
22 changed files with 851 additions and 309 deletions

View File

@@ -24,3 +24,6 @@ subprojects {
configure(subprojects.findAll { it.name.startsWith('testdata')}) { configure(subprojects.findAll { it.name.startsWith('testdata')}) {
tasks.findByPath("artifactoryPublish")?.enabled = false tasks.findByPath("artifactoryPublish")?.enabled = false
} }
task wrapper(type: Wrapper) {
gradleVersion = '3.4.1'
}

View File

@@ -1 +1 @@
version=1.2.6.RELEASE version=1.2.9.BUILD-SNAPSHOT

Binary file not shown.

View File

@@ -1,6 +1,6 @@
#Tue Sep 03 18:56:14 CEST 2013 #Tue Mar 21 14:51:43 PDT 2017
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.7-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-3.4.1-bin.zip

74
gradlew vendored
View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env sh
############################################################################## ##############################################################################
## ##
@@ -6,12 +6,30 @@
## ##
############################################################################## ##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. # Attempt to set APP_HOME
DEFAULT_JVM_OPTS="" # Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle" APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"` APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum" MAX_FD="maximum"
@@ -30,6 +48,7 @@ die ( ) {
cygwin=false cygwin=false
msys=false msys=false
darwin=false darwin=false
nonstop=false
case "`uname`" in case "`uname`" in
CYGWIN* ) CYGWIN* )
cygwin=true cygwin=true
@@ -40,31 +59,11 @@ case "`uname`" in
MINGW* ) MINGW* )
msys=true msys=true
;; ;;
NONSTOP* )
nonstop=true
;;
esac esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM. # Determine the Java command to use to start the JVM.
@@ -90,7 +89,7 @@ location of your Java installation."
fi fi
# Increase the maximum file descriptors if we can. # Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n` MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@@ -114,6 +113,7 @@ fi
if $cygwin ; then if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"` APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath # We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
@@ -154,11 +154,19 @@ if $cygwin ; then
esac esac
fi fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules # Escape application args
function splitJvmOpts() { save ( ) {
JVM_OPTS=("$@") for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
} }
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS APP_ARGS=$(save "$@")
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" # Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

174
gradlew.bat vendored
View File

@@ -1,90 +1,84 @@
@if "%DEBUG%" == "" @echo off @if "%DEBUG%" == "" @echo off
@rem ########################################################################## @rem ##########################################################################
@rem @rem
@rem Gradle startup script for Windows @rem Gradle startup script for Windows
@rem @rem
@rem ########################################################################## @rem ##########################################################################
@rem Set local scope for the variables with windows NT shell @rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DIRNAME=%~dp0
set DEFAULT_JVM_OPTS= if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set DIRNAME=%~dp0 set APP_HOME=%DIRNAME%
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0 @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set APP_HOME=%DIRNAME% set DEFAULT_JVM_OPTS=
@rem Find java.exe @rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init if "%ERRORLEVEL%" == "0" goto init
echo. echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo. echo.
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation. echo location of your Java installation.
goto fail goto fail
:findJavaFromJavaHome :findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=% set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init if exist "%JAVA_EXE%" goto init
echo. echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo. echo.
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation. echo location of your Java installation.
goto fail goto fail
:init :init
@rem Get command-line arguments, handling Windowz variants @rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
:win9xME_args @rem Slurp the command line arguments.
@rem Slurp the command line arguments. set CMD_LINE_ARGS=
set CMD_LINE_ARGS= set _SKIP=2
set _SKIP=2
:win9xME_args_slurp
:win9xME_args_slurp if "x%~1" == "x" goto execute
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
set CMD_LINE_ARGS=%*
goto execute :execute
@rem Setup the command line
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
set CMD_LINE_ARGS=%$
@rem Execute Gradle
:execute "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
@rem Setup the command line
:end
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% :fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
:end rem the _cmd.exe /c_ return code!
@rem End local scope for the variables with windows NT shell if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
if "%ERRORLEVEL%"=="0" goto mainEnd exit /b 1
:fail :mainEnd
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of if "%OS%"=="Windows_NT" endlocal
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 :omega
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@@ -35,7 +35,7 @@ configurations {
} }
task wrapper(type: Wrapper) { task wrapper(type: Wrapper) {
gradleVersion = '1.8' gradleVersion = '3.4.1'
} }
dependencies { dependencies {

Binary file not shown.

View File

@@ -1,6 +1,6 @@
#Tue Oct 15 14:09:30 PDT 2013 #Tue Mar 21 14:51:43 PDT 2017
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-3.4.1-bin.zip

74
springloaded/gradlew vendored
View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env sh
############################################################################## ##############################################################################
## ##
@@ -6,12 +6,30 @@
## ##
############################################################################## ##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. # Attempt to set APP_HOME
DEFAULT_JVM_OPTS="" # Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle" APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"` APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum" MAX_FD="maximum"
@@ -30,6 +48,7 @@ die ( ) {
cygwin=false cygwin=false
msys=false msys=false
darwin=false darwin=false
nonstop=false
case "`uname`" in case "`uname`" in
CYGWIN* ) CYGWIN* )
cygwin=true cygwin=true
@@ -40,31 +59,11 @@ case "`uname`" in
MINGW* ) MINGW* )
msys=true msys=true
;; ;;
NONSTOP* )
nonstop=true
;;
esac esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM. # Determine the Java command to use to start the JVM.
@@ -90,7 +89,7 @@ location of your Java installation."
fi fi
# Increase the maximum file descriptors if we can. # Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n` MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@@ -114,6 +113,7 @@ fi
if $cygwin ; then if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"` APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath # We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
@@ -154,11 +154,19 @@ if $cygwin ; then
esac esac
fi fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules # Escape application args
function splitJvmOpts() { save ( ) {
JVM_OPTS=("$@") for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
} }
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS APP_ARGS=$(save "$@")
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" # Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

View File

@@ -1,90 +1,84 @@
@if "%DEBUG%" == "" @echo off @if "%DEBUG%" == "" @echo off
@rem ########################################################################## @rem ##########################################################################
@rem @rem
@rem Gradle startup script for Windows @rem Gradle startup script for Windows
@rem @rem
@rem ########################################################################## @rem ##########################################################################
@rem Set local scope for the variables with windows NT shell @rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DIRNAME=%~dp0
set DEFAULT_JVM_OPTS= if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set DIRNAME=%~dp0 set APP_HOME=%DIRNAME%
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0 @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set APP_HOME=%DIRNAME% set DEFAULT_JVM_OPTS=
@rem Find java.exe @rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init if "%ERRORLEVEL%" == "0" goto init
echo. echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo. echo.
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation. echo location of your Java installation.
goto fail goto fail
:findJavaFromJavaHome :findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=% set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init if exist "%JAVA_EXE%" goto init
echo. echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo. echo.
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation. echo location of your Java installation.
goto fail goto fail
:init :init
@rem Get command-line arguments, handling Windowz variants @rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
:win9xME_args @rem Slurp the command line arguments.
@rem Slurp the command line arguments. set CMD_LINE_ARGS=
set CMD_LINE_ARGS= set _SKIP=2
set _SKIP=2
:win9xME_args_slurp
:win9xME_args_slurp if "x%~1" == "x" goto execute
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
set CMD_LINE_ARGS=%*
goto execute :execute
@rem Setup the command line
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
set CMD_LINE_ARGS=%$
@rem Execute Gradle
:execute "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
@rem Setup the command line
:end
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% :fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
:end rem the _cmd.exe /c_ return code!
@rem End local scope for the variables with windows NT shell if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
if "%ERRORLEVEL%"=="0" goto mainEnd exit /b 1
:fail :mainEnd
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of if "%OS%"=="Windows_NT" endlocal
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 :omega
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@@ -1045,6 +1045,11 @@ public class MethodInvokerRewriter {
throw new IllegalStateException("Unable to find classId for " + slashedclassname throw new IllegalStateException("Unable to find classId for " + slashedclassname
+ " referenced from invokedynamic in " + this.methodname + "()"); + " referenced from invokedynamic in " + this.methodname + "()");
} }
if(typeRegistry.getReloadableType(classId) == null) {
// can't rewrite non-reloading type
super.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
return;
}
// Initially only rewriting use of INVOKEDYNAMIC to support Lambda execution // Initially only rewriting use of INVOKEDYNAMIC to support Lambda execution
// TODO support the more general invokedynamic usage // TODO support the more general invokedynamic usage

View File

@@ -166,8 +166,9 @@ public class ReloadableType {
this.typeRegistry = typeRegistry; this.typeRegistry = typeRegistry;
this.dottedtypename = dottedtypename; this.dottedtypename = dottedtypename;
this.slashedtypename = dottedtypename.replace('.', '/'); this.slashedtypename = dottedtypename.replace('.', '/');
this.typedescriptor = (typeDescriptor != null ? typeDescriptor : typeRegistry.getExtractor().extract( this.typedescriptor = (typeDescriptor != null ? typeDescriptor
initialBytes, true)); : typeRegistry.getExtractor().extract(
initialBytes, true));
this.interfaceBytes = InterfaceExtractor.extract(initialBytes, typeRegistry, this.typedescriptor); this.interfaceBytes = InterfaceExtractor.extract(initialBytes, typeRegistry, this.typedescriptor);
this.bytesInitial = initialBytes; this.bytesInitial = initialBytes;
rewriteCallSitesAndDefine(); rewriteCallSitesAndDefine();
@@ -544,12 +545,17 @@ public class ReloadableType {
private void reloadProxiesIfNecessary(String versionsuffix) { private void reloadProxiesIfNecessary(String versionsuffix) {
ReloadableType proxy = typeRegistry.cglibProxies.get(this.slashedtypename); ReloadableType proxy = typeRegistry.cglibProxies.get(this.slashedtypename);
if (proxy != null) { if (proxy != null) {
if (GlobalConfiguration.isRuntimeLogging && log.isLoggable(Level.INFO)) {
log.log(Level.INFO, "Attempting reload of cglib proxy for type " + this.slashedtypename);
}
Object[] strategyAndGeneratorPair = CglibPluginCapturing.clazzToGeneratorStrategyAndClassGeneratorMap.get( Object[] strategyAndGeneratorPair = CglibPluginCapturing.clazzToGeneratorStrategyAndClassGeneratorMap.get(
getClazz()); getClazz());
if (strategyAndGeneratorPair == null) { if (strategyAndGeneratorPair == null) {
if (log.isLoggable(Level.SEVERE)) { if (log.isLoggable(Level.SEVERE)) {
log.severe( log.severe(
"Unable to find regeneration methods for cglib proxies - proxies will be out of date for this type"); "Unable to find regeneration methods for cglib proxies - proxies will be out of date for type: "
+ getClazz());
} }
return; return;
} }
@@ -567,6 +573,9 @@ public class ReloadableType {
} }
found.setAccessible(true); found.setAccessible(true);
byte[] bs = (byte[]) found.invoke(a, b); byte[] bs = (byte[]) found.invoke(a, b);
if (GlobalConfiguration.isRuntimeLogging && log.isLoggable(Level.INFO)) {
log.log(Level.INFO, "Proxy regenerate successful for " + this.slashedtypename);
}
proxy.loadNewVersion(versionsuffix, bs); proxy.loadNewVersion(versionsuffix, bs);
proxy.runStaticInitializer(); proxy.runStaticInitializer();
} }
@@ -596,6 +605,9 @@ public class ReloadableType {
} }
} }
byte[] bs = (byte[]) found.invoke(a, b); byte[] bs = (byte[]) found.invoke(a, b);
if (GlobalConfiguration.isRuntimeLogging && log.isLoggable(Level.INFO)) {
log.log(Level.INFO, "Proxy (fastclass) regenerate successful for " + this.slashedtypename);
}
proxy.loadNewVersion(versionsuffix, bs); proxy.loadNewVersion(versionsuffix, bs);
proxy.runStaticInitializer(); proxy.runStaticInitializer();
} }
@@ -612,10 +624,8 @@ public class ReloadableType {
if (relevantProxies != null) { if (relevantProxies != null) {
for (ReloadableType relevantProxy : relevantProxies) { for (ReloadableType relevantProxy : relevantProxies) {
Class<?>[] interfacesImplementedByProxy = relevantProxy.getClazz().getInterfaces(); Class<?>[] interfacesImplementedByProxy = relevantProxy.getClazz().getInterfaces();
// check slashedname correct // TODO confirm slashedname correct
// @SuppressWarnings("restriction") byte[] newProxyBytes = Utils.generateProxyClass(relevantProxy.getSlashedName(),
byte[] newProxyBytes = sun.misc.ProxyGenerator.generateProxyClass(
relevantProxy.getSlashedName(),
interfacesImplementedByProxy); interfacesImplementedByProxy);
relevantProxy.loadNewVersion(versionsuffix, newProxyBytes, true); relevantProxy.loadNewVersion(versionsuffix, newProxyBytes, true);
} }

View File

@@ -44,6 +44,7 @@ import org.objectweb.asm.tree.AnnotationNode;
import org.objectweb.asm.tree.FieldNode; import org.objectweb.asm.tree.FieldNode;
import org.springsource.loaded.Utils.ReturnType.Kind; import org.springsource.loaded.Utils.ReturnType.Kind;
import sun.misc.ProxyGenerator;
// TODO debugging tests - how is the experience? rewriting of field accesses will really // TODO debugging tests - how is the experience? rewriting of field accesses will really
// affect field navigation in the debugger // affect field navigation in the debugger
@@ -1935,4 +1936,38 @@ public class Utils implements Opcodes, Constants {
cr.accept(v, 0); cr.accept(v, 0);
return v.classname; return v.classname;
} }
private static boolean checkedForNewProxyGenerateMethod = false;
private static Method newProxyGenerateMethod;
public static byte[] generateProxyClass(String slashedName, Class<?>[] interfacesImplementedByProxy) {
if (!checkedForNewProxyGenerateMethod) {
checkedForNewProxyGenerateMethod = true;
try {
newProxyGenerateMethod = ProxyGenerator.class.getDeclaredMethod("generateProxyClass", String.class,
Class[].class, Integer.TYPE);
}
catch (NoSuchMethodException nsme) {
// That's fine, we are early Java8 or before
}
}
if (newProxyGenerateMethod != null) {
try {
newProxyGenerateMethod.setAccessible(true);
byte[] bytes = (byte[]) newProxyGenerateMethod.invoke(null, slashedName, interfacesImplementedByProxy,
(Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL));
return bytes;
}
catch (Exception e) {
// Unexpected
throw new RuntimeException("Unexpected exception calling proxy generator ", e);
}
}
else {
return sun.misc.ProxyGenerator.generateProxyClass(
slashedName,
interfacesImplementedByProxy);
}
}
} }

View File

@@ -19,23 +19,28 @@ package org.springsource.loaded.agent;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter; import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.MethodVisitor;
import org.springsource.loaded.Constants; import org.springsource.loaded.Constants;
import org.springsource.loaded.GlobalConfiguration;
/** /**
* This bytecode rewriter intercepts calls to generate made in the CGLIB framework and allows us to record what * This bytecode rewriter intercepts calls to generate made in the CGLIB framework and allows us to record what
* generator is called to create the proxy for some type. The same generator can then be driven again if the type is * generator is called to create the proxy for some type. The same generator can then be driven again if the type is
* reloaded. * reloaded.
* *
* @author Andy Clement * @author Andy Clement
* @since 0.8.3 * @since 0.8.3
*/ */
public class CglibPluginCapturing extends ClassVisitor implements Constants { public class CglibPluginCapturing extends ClassVisitor implements Constants {
private static Logger log = Logger.getLogger(CglibPluginCapturing.class.getName());
public static Map<Class<?>, Object[]> clazzToGeneratorStrategyAndClassGeneratorMap = new HashMap<Class<?>, Object[]>(); public static Map<Class<?>, Object[]> clazzToGeneratorStrategyAndClassGeneratorMap = new HashMap<Class<?>, Object[]>();
public static Map<Class<?>, Object[]> clazzToGeneratorStrategyAndFastClassGeneratorMap = new HashMap<Class<?>, Object[]>(); public static Map<Class<?>, Object[]> clazzToGeneratorStrategyAndFastClassGeneratorMap = new HashMap<Class<?>, Object[]>();
@@ -68,11 +73,22 @@ public class CglibPluginCapturing extends ClassVisitor implements Constants {
return ((ClassWriter) cv).toByteArray(); return ((ClassWriter) cv).toByteArray();
} }
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
if (name.equals("create")) { if (name.equals("create")) {
if (GlobalConfiguration.isRuntimeLogging && log.isLoggable(Level.INFO)) {
log.info("intercepting create method");
}
MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions); MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
return new CreateMethodInterceptor(mv); return new CreateMethodInterceptor(mv);
} }
else if (name.equals("generate")) {
if (GlobalConfiguration.isRuntimeLogging && log.isLoggable(Level.INFO)) {
log.info("intercepting generate method");
}
MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
return new GenerateMethodInterceptor(mv);
}
else { else {
return super.visitMethod(access, name, desc, signature, exceptions); return super.visitMethod(access, name, desc, signature, exceptions);
} }
@@ -98,6 +114,9 @@ public class CglibPluginCapturing extends ClassVisitor implements Constants {
final boolean itf) { final boolean itf) {
super.visitMethodInsn(opcode, owner, name, desc, itf); super.visitMethodInsn(opcode, owner, name, desc, itf);
if (name.equals("generate")) { if (name.equals("generate")) {
if (GlobalConfiguration.isRuntimeLogging && log.isLoggable(Level.INFO)) {
log.info("intercepting call to generate in create method");
}
// Code that calls generate: // Code that calls generate:
// ALOAD 0 // ALOAD 0
// GETFIELD net/sf/cglib/core/AbstractClassGenerator.strategy : Lnet/sf/cglib/core/GeneratorStrategy; // GETFIELD net/sf/cglib/core/AbstractClassGenerator.strategy : Lnet/sf/cglib/core/GeneratorStrategy;
@@ -108,22 +127,46 @@ public class CglibPluginCapturing extends ClassVisitor implements Constants {
"L" + prefix + "/cglib/core/GeneratorStrategy;"); "L" + prefix + "/cglib/core/GeneratorStrategy;");
mv.visitVarInsn(ALOAD, 0); // AbstractClassGenerator instance mv.visitVarInsn(ALOAD, 0); // AbstractClassGenerator instance
mv.visitMethodInsn(INVOKESTATIC, "org/springsource/loaded/agent/CglibPluginCapturing", "record", mv.visitMethodInsn(INVOKESTATIC, "org/springsource/loaded/agent/CglibPluginCapturing", "record",
"(Ljava/lang/Object;Ljava/lang/Object;)V", false);//Lnet/sf/cglib/core/GeneratorStrategy;Lnet/sf/cglib/core/AbstractClassGenerator);"); "(Ljava/lang/Object;Ljava/lang/Object;)V", false);//Lnet/sf/cglib/core/GeneratorStrategy;Lnet/sf/cglib/core/AbstractClassGenerator);");
} }
} }
} }
class GenerateMethodInterceptor extends MethodVisitor implements Constants {
public GenerateMethodInterceptor(MethodVisitor mv) {
super(ASM5, mv);
}
@Override
public void visitCode() {
mv.visitVarInsn(ALOAD, 0); // AbstractClassGenerator instance
mv.visitFieldInsn(GETFIELD, prefix + "/cglib/core/AbstractClassGenerator", "strategy",
"L" + prefix + "/cglib/core/GeneratorStrategy;");
mv.visitVarInsn(ALOAD, 0); // AbstractClassGenerator instance
mv.visitMethodInsn(INVOKESTATIC, "org/springsource/loaded/agent/CglibPluginCapturing", "record",
"(Ljava/lang/Object;Ljava/lang/Object;)V", false);//Lnet/sf/cglib/core/GeneratorStrategy;Lnet/sf/cglib/core/AbstractClassGenerator);");
}
}
/** /**
* The classloader for class artifacts is used to load the generated classes for call sites. We need to rewrite * The classloader for class artifacts is used to load the generated classes for call sites. We need to rewrite
* these classes because they may be either calling something that disappears on a later reload (so need to fail * these classes because they may be either calling something that disappears on a later reload (so need to fail
* appropriately) or calling something that isnt there on the first load - in this latter case they are changed to * appropriately) or calling something that isnt there on the first load - in this latter case they are changed to
* route the dynamic executor method. * route the dynamic executor method.
* *
* @param a the GeneratorStrategy being used * @param a the GeneratorStrategy being used
* @param b the AbstractClassGenerator * @param b the AbstractClassGenerator
*/ */
public static void record(Object a, Object b) { public static void record(Object a, Object b) {
// if (GlobalConfiguration.isRuntimeLogging && log.isLoggable(Level.INFO)) {
// log.info("recording invocation of generate with " + (a == null ? "null" : a.getClass().getName()) + " b="
// + (b == null ? "null" : b.getClass().getName()));
// }
// a is a Lnet/sf/cglib/core/GeneratorStrategy; // a is a Lnet/sf/cglib/core/GeneratorStrategy;
// b is a Lnet/sf/cglib/core/AbstractClassGenerator (or specifically net/sf/cglib/reflect/FastClass$Generator) // b is a Lnet/sf/cglib/core/AbstractClassGenerator (or specifically net/sf/cglib/reflect/FastClass$Generator)
// a is something like 'UndeclaredThrowableStrategy' // a is something like 'UndeclaredThrowableStrategy'
@@ -134,7 +177,9 @@ public class CglibPluginCapturing extends ClassVisitor implements Constants {
Field f = b.getClass().getDeclaredField("superclass"); Field f = b.getClass().getDeclaredField("superclass");
f.setAccessible(true); f.setAccessible(true);
Class<?> clazz = (Class<?>) f.get(b); Class<?> clazz = (Class<?>) f.get(b);
// System.out.println("Recording pair " + clazz.getName() + " > " + b); if (GlobalConfiguration.isRuntimeLogging && log.isLoggable(Level.INFO)) {
log.info("recording pair " + clazz.getName() + " > " + b);
}
clazzToGeneratorStrategyAndClassGeneratorMap.put(clazz, new Object[] { a, b }); clazzToGeneratorStrategyAndClassGeneratorMap.put(clazz, new Object[] { a, b });
} }
catch (Throwable re) { catch (Throwable re) {
@@ -146,7 +191,9 @@ public class CglibPluginCapturing extends ClassVisitor implements Constants {
Field f = b.getClass().getDeclaredField("type"); Field f = b.getClass().getDeclaredField("type");
f.setAccessible(true); f.setAccessible(true);
Class<?> clazz = (Class<?>) f.get(b); Class<?> clazz = (Class<?>) f.get(b);
// System.out.println("Recording pair (fastclass) " + clazz.getName() + " > " + b); if (GlobalConfiguration.isRuntimeLogging && log.isLoggable(Level.INFO)) {
log.info("recording pair (fastclass) " + clazz.getName() + " > " + b);
}
clazzToGeneratorStrategyAndFastClassGeneratorMap.put(clazz, new Object[] { a, b }); clazzToGeneratorStrategyAndFastClassGeneratorMap.put(clazz, new Object[] { a, b });
} }
catch (Throwable re) { catch (Throwable re) {

View File

@@ -110,8 +110,8 @@ public class SpringPlugin implements LoadtimeInstrumentationPlugin, ReloadEventP
public byte[] modify(String slashedClassName, ClassLoader classLoader, byte[] bytes) { public byte[] modify(String slashedClassName, ClassLoader classLoader, byte[] bytes) {
if (GlobalConfiguration.isRuntimeLogging && log.isLoggable(Level.INFO)) { if ((GlobalConfiguration.isRuntimeLogging && log.isLoggable(Level.INFO)) || debug) {
log.info("loadtime modifying " + slashedClassName); log.info("SPRING_PLUGIN: loadtime modifying " + slashedClassName);
} }
if (slashedClassName.equals("org/springframework/web/servlet/mvc/annotation/AnnotationMethodHandlerAdapter")) { if (slashedClassName.equals("org/springframework/web/servlet/mvc/annotation/AnnotationMethodHandlerAdapter")) {
return bytesWithInstanceCreationCaptured(bytes, THIS_CLASS, return bytesWithInstanceCreationCaptured(bytes, THIS_CLASS,
@@ -140,6 +140,9 @@ public class SpringPlugin implements LoadtimeInstrumentationPlugin, ReloadEventP
} }
public static void recordRequestMappingHandlerMappingInstance(Object obj) { public static void recordRequestMappingHandlerMappingInstance(Object obj) {
if (debug) {
System.out.println("SPRING_PLUGIN: Recording request mapping handler mapping instance..." + obj);
}
requestMappingHandlerMappingInstances.add(obj); requestMappingHandlerMappingInstances.add(obj);
} }
@@ -163,7 +166,7 @@ public class SpringPlugin implements LoadtimeInstrumentationPlugin, ReloadEventP
// called by the modified code // called by the modified code
public static void recordDefaultAnnotationHandlerMappingInstance(Object obj) { public static void recordDefaultAnnotationHandlerMappingInstance(Object obj) {
if (debug) { if (debug) {
System.out.println("Recording new instance of DefaultAnnotationHandlerMappingInstance"); System.out.println("SPRING_PLUGIN: Recording new instance of DefaultAnnotationHandlerMappingInstance");
} }
defaultAnnotationHandlerMappingInstances.add(obj); defaultAnnotationHandlerMappingInstances.add(obj);
} }
@@ -188,7 +191,7 @@ public class SpringPlugin implements LoadtimeInstrumentationPlugin, ReloadEventP
return; return;
} }
if (debug) { if (debug) {
System.out.println("ParameterNamesCache: Clearing parameter name discoverer caches"); System.out.println("SPRING_PLUGIN: ParameterNamesCache: Clearing parameter name discoverer caches");
} }
if (parameterNamesCacheField == null) { if (parameterNamesCacheField == null) {
try { try {
@@ -207,7 +210,8 @@ public class SpringPlugin implements LoadtimeInstrumentationPlugin, ReloadEventP
Object o = parameterNamesCache.remove(clazz); Object o = parameterNamesCache.remove(clazz);
if (debug) { if (debug) {
System.out.println( System.out.println(
"ParameterNamesCache: Removed " + clazz.getName() + " from cache?" + (o != null)); "SPRING_PLUGIN: ParameterNamesCache: Removed " + clazz.getName() + " from cache?"
+ (o != null));
} }
} }
catch (IllegalAccessException e) { catch (IllegalAccessException e) {
@@ -230,7 +234,7 @@ public class SpringPlugin implements LoadtimeInstrumentationPlugin, ReloadEventP
Method removeMethod = Map.class.getDeclaredMethod("remove", Object.class); Method removeMethod = Map.class.getDeclaredMethod("remove", Object.class);
Object ret = removeMethod.invoke(map, clazz); Object ret = removeMethod.invoke(map, clazz);
if (GlobalConfiguration.debugplugins) { if (GlobalConfiguration.debugplugins) {
System.err.println("SpringPlugin: clearing methodResolverCache for " + clazz.getName()); System.err.println("SPRING_PLUGIN: clearing methodResolverCache for " + clazz.getName());
} }
if (GlobalConfiguration.isRuntimeLogging && log.isLoggable(Level.INFO)) { if (GlobalConfiguration.isRuntimeLogging && log.isLoggable(Level.INFO)) {
log.info("cleared a cache entry? " + (ret != null)); log.info("cleared a cache entry? " + (ret != null));
@@ -342,7 +346,8 @@ public class SpringPlugin implements LoadtimeInstrumentationPlugin, ReloadEventP
// protected void detectHandlers() throws BeansException { is defined on AbstractDetectingUrlHandlerMapping // protected void detectHandlers() throws BeansException { is defined on AbstractDetectingUrlHandlerMapping
for (Object o : defaultAnnotationHandlerMappingInstances) { for (Object o : defaultAnnotationHandlerMappingInstances) {
if (debug) { if (debug) {
System.out.println("Invoking detectHandlers on instance of DefaultAnnotationHandlerMappingInstance"); System.out.println(
"SPRING_PLUGIN: Invoking detectHandlers on instance of DefaultAnnotationHandlerMappingInstance");
} }
try { try {
Class<?> clazz_AbstractDetectingUrlHandlerMapping = o.getClass().getSuperclass(); Class<?> clazz_AbstractDetectingUrlHandlerMapping = o.getClass().getSuperclass();
@@ -360,50 +365,140 @@ public class SpringPlugin implements LoadtimeInstrumentationPlugin, ReloadEventP
} }
} }
@SuppressWarnings("rawtypes")
private void reinvokeInitHandlerMethods() { private void reinvokeInitHandlerMethods() {
// org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping (super AbstractHandlerMethodMapping) - call protected void initHandlerMethods() on it. // org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping (super AbstractHandlerMethodMapping) - call protected void initHandlerMethods() on it.
for (Object o : requestMappingHandlerMappingInstances) { for (Object o : requestMappingHandlerMappingInstances) {
if (debug) { if (debug) {
System.out.println("Invoking initHandlerMethods on instance of RequestMappingHandlerMapping"); System.out.println(
"SPRING_PLUGIN: Invoking initHandlerMethods on instance of RequestMappingHandlerMapping");
} }
Class<?> clazz_AbstractHandlerMethodMapping = null;
try { try {
Class<?> clazz_AbstractHandlerMethodMapping = o.getClass().getSuperclass().getSuperclass(); clazz_AbstractHandlerMethodMapping = o.getClass().getSuperclass().getSuperclass();
// private final Map<T, HandlerMethod> handlerMethods = new LinkedHashMap<T, HandlerMethod>();
Field field_handlerMethods = clazz_AbstractHandlerMethodMapping.getDeclaredField("handlerMethods");
field_handlerMethods.setAccessible(true);
Map m = (Map) field_handlerMethods.get(o);
m.clear();
Field field_urlMap = clazz_AbstractHandlerMethodMapping.getDeclaredField("urlMap");
field_urlMap.setAccessible(true);
m = (Map) field_urlMap.get(o);
m.clear();
Method method_initHandlerMethods = clazz_AbstractHandlerMethodMapping.getDeclaredMethod(
"initHandlerMethods");
method_initHandlerMethods.setAccessible(true);
method_initHandlerMethods.invoke(o);
}
catch (NoSuchFieldException nsfe) {
if (debug) {
if (nsfe.getMessage().equals("handlerMethods")) {
System.out.println(
"problem resetting request mapping handlers - unable to find field 'handlerMethods' on type 'AbstractHandlerMethodMapping' - you probably are not on Spring 3.1");
}
else {
System.out.println("problem resetting request mapping handlers - NoSuchFieldException: "
+ nsfe.getMessage());
}
}
} }
catch (Exception e) { catch (Exception e) {
if (debug) {
System.out.println("SPRING_PLUGIN: Unable to get to AbstractHandlerMethodMapping from RMHM");
}
if (GlobalConfiguration.debugplugins) { if (GlobalConfiguration.debugplugins) {
e.printStackTrace(); e.printStackTrace();
} }
} }
if (clazz_AbstractHandlerMethodMapping != null) {
try {
// private final Map<T, HandlerMethod> handlerMethods = new LinkedHashMap<T, HandlerMethod>();
Field field_handlerMethods = clazz_AbstractHandlerMethodMapping.getDeclaredField("handlerMethods");
field_handlerMethods.setAccessible(true);
Map m = (Map) field_handlerMethods.get(o);
m.clear();
}
catch (NoSuchFieldException e) {
if (debug) {
System.out.println("SPRING_PLUGIN: Unable to find handlerMethods field to clear");
}
}
catch (Exception e) {
if (GlobalConfiguration.debugplugins) {
e.printStackTrace();
}
}
try {
Field field_urlMap = clazz_AbstractHandlerMethodMapping.getDeclaredField("urlMap");
field_urlMap.setAccessible(true);
Map m = (Map) field_urlMap.get(o);
m.clear();
}
catch (NoSuchFieldException e) {
if (debug) {
System.out.println("SPRING_PLUGIN: Unable to find urlMap field to clear");
}
}
catch (Exception e) {
if (GlobalConfiguration.debugplugins) {
e.printStackTrace();
}
}
clearMappingRegistry(o, clazz_AbstractHandlerMethodMapping);
try {
Method method_initHandlerMethods = clazz_AbstractHandlerMethodMapping.getDeclaredMethod(
"initHandlerMethods");
method_initHandlerMethods.setAccessible(true);
method_initHandlerMethods.invoke(o);
}
catch (Exception e) {
if (GlobalConfiguration.debugplugins || debug) {
e.printStackTrace();
}
}
}
}
}
// More recent Springs use a MappingRegistry - clear it out if we can get at it, otherwise on re-driving
// the initHandlerMethods below we will get an error about already existing mappings
private void clearMappingRegistry(Object o, Class<?> clazz_AbstractHandlerMethodMapping) {
if (debug) {
System.out.println("SPRING_PLUGIN: clearing out mapping registry...");
}
Object mappingRegistryInstance = null;
try {
Field field_mappingRegistry = clazz_AbstractHandlerMethodMapping.getDeclaredField("mappingRegistry");
field_mappingRegistry.setAccessible(true);
mappingRegistryInstance = field_mappingRegistry.get(o);
}
catch (NoSuchFieldException e) {
if (debug) {
System.out.println(
"SPRING_PLUGIN: Unable to get mappingRegistry field on AbstractHandlerMethodMapping");
}
}
catch (IllegalAccessException e) {
if (GlobalConfiguration.debugplugins || debug) {
System.out.println(
"SPRING_PLUGIN: Problem accessing mappingRegistry field on AbstractHandlerMethodMapping: ");
e.printStackTrace(System.out);
}
}
if (mappingRegistryInstance == null) {
return;
}
Class mappingRegistryClass = mappingRegistryInstance.getClass();
clearMapField(mappingRegistryClass, mappingRegistryInstance, "registry");
clearMapField(mappingRegistryClass, mappingRegistryInstance, "mappingLookup");
clearMapField(mappingRegistryClass, mappingRegistryInstance, "urlLookup");
clearMapField(mappingRegistryClass, mappingRegistryInstance, "nameLookup");
clearMapField(mappingRegistryClass, mappingRegistryInstance, "corsLookup");
if (debug) {
System.out.println("SPRING_PLUGIN: ... cleared out the mapping registry contents");
}
}
private void clearMapField(Class clazz, Object instance, String name) {
try {
Field field = clazz.getDeclaredField(name);
field.setAccessible(true);
Map m = (Map) field.get(instance);
m.clear();
}
catch (NoSuchFieldException e) {
if (debug) {
System.out.println("SPRING_PLUGIN: Unable to find field '" + name + "' to clear");
}
}
catch (Exception e) {
if (GlobalConfiguration.debugplugins || debug) {
e.printStackTrace();
}
} }
} }

View File

@@ -53,7 +53,7 @@ import org.springsource.loaded.TypeRegistry;
import org.springsource.loaded.Utils; import org.springsource.loaded.Utils;
import org.springsource.loaded.infra.UsedByGeneratedCode; import org.springsource.loaded.infra.UsedByGeneratedCode;
import org.springsource.loaded.jvm.JVM; import org.springsource.loaded.jvm.JVM;
import org.springsource.loaded.support.ConcurrentWeakIdentityHashMap;
/** /**
* The reflective interceptor is called to rewrite any reflective calls that are found in the bytecode. Intercepting the * The reflective interceptor is called to rewrite any reflective calls that are found in the bytecode. Intercepting the
@@ -84,7 +84,8 @@ public class ReflectiveInterceptor {
classToRType = Collections.synchronizedMap(new WeakHashMap<Class<?>, WeakReference<ReloadableType>>()); classToRType = Collections.synchronizedMap(new WeakHashMap<Class<?>, WeakReference<ReloadableType>>());
} }
else { else {
classToRType = new WeakHashMap<Class<?>, WeakReference<ReloadableType>>(); classToRType = new ConcurrentWeakIdentityHashMap<Class<?>, WeakReference<ReloadableType>>();
// classToRType = new WeakHashMap<Class<?>, WeakReference<ReloadableType>>();
} }
} }
@@ -650,7 +651,7 @@ public class ReflectiveInterceptor {
*/ */
private static Field asSetableField(Field field, Object target, Class<?> valueType, Object value, private static Field asSetableField(Field field, Object target, Class<?> valueType, Object value,
boolean makeAccessibleCopy) boolean makeAccessibleCopy)
throws IllegalAccessException { throws IllegalAccessException {
// Must do the checks exactly in the same order as JVM if we want identical error messages. // Must do the checks exactly in the same order as JVM if we want identical error messages.
// JVM doesn't do this, since it cannot happen without reloading, we do it first of all. // JVM doesn't do this, since it cannot happen without reloading, we do it first of all.
@@ -1054,7 +1055,7 @@ public class ReflectiveInterceptor {
c = jlClassGetDeclaredConstructor(clazz); c = jlClassGetDeclaredConstructor(clazz);
} }
catch (NoSuchMethodException e) { catch (NoSuchMethodException e) {
e.printStackTrace(); // e.printStackTrace();
throw Exceptions.instantiation(clazz); throw Exceptions.instantiation(clazz);
} }
c = asAccessibleConstructor(c, true); c = asAccessibleConstructor(c, true);

View File

@@ -0,0 +1,271 @@
/*
* Copyright 2016 zhanhb.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springsource.loaded.support;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.util.AbstractMap;
import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import java.lang.NullPointerException;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
*
* @author zhanhb
* @param <K>
* @param <V>
*/
public class ConcurrentWeakIdentityHashMap<K, V> extends AbstractMap<K, V>
implements ConcurrentMap<K, V> {
private final ConcurrentMap<Key<K>, V> map;
private final ReferenceQueue<K> queue = new ReferenceQueue<K>();
private transient Set<Map.Entry<K, V>> es;
public ConcurrentWeakIdentityHashMap(int initialCapacity) {
this.map = new ConcurrentHashMap<Key<K>, V>(initialCapacity);
}
@SuppressWarnings("CollectionWithoutInitialCapacity")
public ConcurrentWeakIdentityHashMap() {
this.map = new ConcurrentHashMap<Key<K>, V>();
}
@Override
public V get(Object key) {
purgeKeys();
return map.get(new Key<Object>(key, null));
}
@Override
public V put(K key, V value) {
purgeKeys();
return map.put(new Key<K>(key, queue), value);
}
@Override
public int size() {
purgeKeys();
return map.size();
}
@SuppressWarnings({"NestedAssignment", "element-type-mismatch"})
private void purgeKeys() {
Reference<? extends K> reference;
while ((reference = queue.poll()) != null) {
map.remove(reference);
}
}
@Override
@SuppressWarnings("NestedAssignment")
public Set<Map.Entry<K, V>> entrySet() {
Set<Map.Entry<K, V>> entrySet;
return ((entrySet = this.es) == null) ? es = new EntrySet() : entrySet;
}
@Override
public V putIfAbsent(K key, V value) {
purgeKeys();
return map.putIfAbsent(new Key<K>(key, queue), value);
}
@Override
public V remove(Object key) {
return map.remove(new Key<Object>(key, null));
}
@Override
public boolean remove(Object key, Object value) {
purgeKeys();
return map.remove(new Key<Object>(key, null), value);
}
@Override
public boolean replace(K key, V oldValue, V newValue) {
purgeKeys();
return map.replace(new Key<K>(key, null), oldValue, newValue);
}
@Override
public V replace(K key, V value) {
purgeKeys();
return map.replace(new Key<K>(key, null), value);
}
@Override
public boolean containsKey(Object key) {
purgeKeys();
return map.containsKey(new Key<Object>(key, null));
}
@Override
@SuppressWarnings("empty-statement")
public void clear() {
while (queue.poll() != null);
map.clear();
}
@Override
public boolean containsValue(Object value) {
purgeKeys();
return map.containsValue(value);
}
private static class Key<T> extends WeakReference<T> {
private final int hash;
Key(T t, ReferenceQueue<T> queue) {
super(t, queue);
if(t == null) {
throw new NullPointerException();
} else {
hash = System.identityHashCode(t);
}
}
@Override
public boolean equals(Object obj) {
return this == obj || obj instanceof Key && ((Key<?>) obj).get() == get();
}
@Override
public int hashCode() {
return hash;
}
}
private class Iter implements Iterator<Map.Entry<K, V>> {
private final Iterator<Map.Entry<Key<K>, V>> it;
private Map.Entry<K, V> nextValue;
Iter(Iterator<Map.Entry<Key<K>, V>> it) {
this.it = it;
}
@Override
public boolean hasNext() {
if (nextValue != null) {
return true;
}
while (it.hasNext()) {
Map.Entry<Key<K>, V> entry = it.next();
K key = entry.getKey().get();
if (key != null) {
nextValue = new Entry(key, entry.getValue());
return true;
} else {
it.remove();
}
}
return false;
}
@Override
public Map.Entry<K, V> next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
Map.Entry<K, V> entry = nextValue;
nextValue = null;
return entry;
}
@Override
public void remove() {
it.remove();
nextValue = null;
}
}
private class EntrySet extends AbstractSet<Map.Entry<K, V>> {
@Override
public Iterator<Map.Entry<K, V>> iterator() {
return new Iter(map.entrySet().iterator());
}
@Override
public int size() {
return ConcurrentWeakIdentityHashMap.this.size();
}
@Override
public void clear() {
ConcurrentWeakIdentityHashMap.this.clear();
}
@Override
@SuppressWarnings("element-type-mismatch")
public boolean contains(Object o) {
if (!(o instanceof Map.Entry)) {
return false;
}
Map.Entry<?, ?> e = (Map.Entry<?, ?>) o;
return ConcurrentWeakIdentityHashMap.this.get(e.getKey()) == e.getValue();
}
@Override
public boolean remove(Object o) {
if (!(o instanceof Map.Entry)) {
return false;
}
Map.Entry<?, ?> e = (Map.Entry<?, ?>) o;
return ConcurrentWeakIdentityHashMap.this.remove(e.getKey(), e.getValue());
}
}
private class Entry extends AbstractMap.SimpleEntry<K, V> {
private static final long serialVersionUID = 1L;
Entry(K key, V value) {
super(key, value);
}
@Override
public V setValue(V value) {
ConcurrentWeakIdentityHashMap.this.put(getKey(), value);
return super.setValue(value);
}
@Override
public boolean equals(Object obj) {
if (obj instanceof Map.Entry) {
Map.Entry<?, ?> e = (Map.Entry<?, ?>) obj;
return getKey() == e.getKey() && getValue() == e.getValue();
}
return false;
}
@Override
public int hashCode() {
return System.identityHashCode(getKey())
^ System.identityHashCode(getValue());
}
}
}

View File

@@ -150,8 +150,8 @@ public class Java8 {
if (null == ownerRType || !ownerRType.hasBeenReloaded()) { if (null == ownerRType || !ownerRType.hasBeenReloaded()) {
// target containing the reference/lambdaMethod has not been reloaded, no need to get over // target containing the reference/lambdaMethod has not been reloaded, no need to get over
// complicated. // complicated.
Class<?> ownerClazz = ownerRType.getClazz(); Class<?> clazz = callerLoader.loadClass(owner.replace("/", "."));
implMethod = caller.findVirtual(ownerClazz, name, implMethodType); implMethod = caller.findVirtual(clazz, name, implMethodType);
} }
else { else {
MethodMember targetReferenceMethodMember = ownerRType.getCurrentMethod(name, descriptor); MethodMember targetReferenceMethodMember = ownerRType.getCurrentMethod(name, descriptor);

View File

@@ -23,6 +23,7 @@ import java.io.FileInputStream;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.springsource.loaded.ConstantPoolScanner; import org.springsource.loaded.ConstantPoolScanner;
import org.springsource.loaded.ConstantPoolScanner.References; import org.springsource.loaded.ConstantPoolScanner.References;
@@ -55,6 +56,7 @@ public class ConstantPoolScannerTests {
} }
@Ignore
@Test @Test
public void foo() throws Exception { public void foo() throws Exception {

View File

@@ -68,6 +68,26 @@ public class Java8Tests extends SpringLoadedTests {
// TODO should assert something but the issue is that the JVM crashes... // TODO should assert something but the issue is that the JVM crashes...
} }
@Test
public void issue173() throws Exception {
String t = "bugs.Issue173";
TypeRegistry typeRegistry = getTypeRegistry(t);
byte[] sc = loadBytesForClass(t);
ReloadableType rtype = typeRegistry.addType(t, sc);
Class<?> clazz = rtype.getClazz();
@SuppressWarnings("unused")
Result r = runUnguarded(clazz, "run");
r = runUnguarded(clazz, "run");
rtype.loadNewVersion("002", rtype.bytesInitial);
r = runUnguarded(clazz, "run");
assertEquals("https://www.redacted.com/path", r.returnValue);
}
@Test @Test
public void callBasicType() throws Exception { public void callBasicType() throws Exception {
String t = "basic.FirstClass"; String t = "basic.FirstClass";

View File

@@ -0,0 +1,49 @@
package bugs;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
public class Issue173 {
public static void main(String[] args) {
System.out.println(run());
}
public static String run() {
return url("path").toString();
}
public static URI url(Object... args) {
try {
/* flattening the paths */
final List<String> paths = Arrays
.stream(args)
.flatMap(arg -> {
if (arg instanceof Collection) {
return ((Collection<Object>) arg).stream();
} else if (arg instanceof Object[]) {
return Arrays.stream((Object[]) arg);
}
return Arrays.stream(new Object[]{
arg
});
})
.map(Object::toString)
.map(String::toLowerCase)
.collect(Collectors.toList());
Path path = Paths.get("/", paths.toArray(new String[0]));
URI uri = new URI("https", "www.redacted.com", path.toString(), null);
return uri;
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
}