private static boolean assertNoDifferentStagemonitorVersionIsDeployedOnSameJvm() {
		final String stagemonitorVersionKey = "stagemonitor.version";
		final String stagemonitorClassLoaderKey = "stagemonitor.classLoader";
		final String alreadyRegisteredVersion = System.getProperty(stagemonitorVersionKey);
		final String currentVersion = corePlugin.getVersion();
		if (alreadyRegisteredVersion != null && !currentVersion.equals(alreadyRegisteredVersion)) {
			final String msg = String.format("Detected a different version of stagemonitor on the same JVM:" +
							"already registered version: %s current version: %s. " +
							"It is not supported to have different versions of stagemonitor on the same JVM. " +
							"For more details take a look at the javadoc.",
					alreadyRegisteredVersion, currentVersion);
			healthCheckRegistry.register("Agent attachment", ImmediateResult.of(HealthCheck.Result.unhealthy(msg)));
			return false;
		}
		if (currentVersion != null) {
			System.setProperty(stagemonitorVersionKey, currentVersion);
			System.setProperty(stagemonitorClassLoaderKey, Stagemonitor.class.getClassLoader().toString());
		}
		return true;
	}
private static boolean assertNoDifferentStagemonitorVersionIsDeployedOnSameJvm ( ) { final String stagemonitorVersionKey = "stagemonitor.version" ; final String stagemonitorClassLoaderKey = "stagemonitor.classLoader" ; final String alreadyRegisteredVersion = System . getProperty ( stagemonitorVersionKey ) ; final String currentVersion = corePlugin . getVersion ( ) ; if ( alreadyRegisteredVersion != null && ! currentVersion . equals ( alreadyRegisteredVersion ) ) { final String msg = String . format ( "Detected a different version of stagemonitor on the same JVM:" + "already registered version: %s current version: %s. " + "It is not supported to have different versions of stagemonitor on the same JVM. " + "For more details take a look at the javadoc." , alreadyRegisteredVersion , currentVersion ) ; healthCheckRegistry . register ( "Agent attachment" , ImmediateResult . of ( HealthCheck . Result . unhealthy ( msg ) ) ) ; return false ; } if ( currentVersion != null ) { System . setProperty ( stagemonitorVersionKey , currentVersion ) ; System . setProperty ( stagemonitorClassLoaderKey , Stagemonitor . class . getClassLoader ( ) . toString ( ) ) ; } return true ; }
The problem with different stagemonitor versions is that a class like {@link javax.xml.ws.Binding}, which is
loaded by the bootstrap class loader can be used by multiple applications.

<p> If those applications are using different versions of stagemonitor they might expect the class to be
instrumented differently. This can lead to unexpected behaviour no matter if the classes get instrumented twice
or if double instrumentation is avoided via {@link StagemonitorByteBuddyTransformer#isPreventDuplicateTransformation()}.
</p>

<p> One remedy of this could be to make {@link StagemonitorByteBuddyTransformer} implement {@link
java.io.Serializable} and check via {@code new ObjectStreamClass(SomeByteBuddyTransformer.class).getSerialVersionUID()}
if there have been any changes to any transformer. </p>

<p> This case can occur when we are dealing with an application server where different applications are deployed
with different stagemonitor versions. </p>

<p> Another problem is when the API of {@link Dispatcher} changes as this class is injected into the bootstrap
class loader if not already done so. If another application gets deployed to the same server. </p>

<p> A solution could be to only inject the most recent {@link Dispatcher} and to make sure that changes to its
API are always backwards compatible. </p>