From d61c3d429c586dd1161d159c134a065d3838d7bc Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 25 Feb 2019 14:19:29 +0100 Subject: [PATCH] Improve Javadoc and exception message for LTW classes --- .../weaving/DefaultContextLoadTimeWeaver.java | 13 +++++++------ .../InstrumentationLoadTimeWeaver.java | 18 ++++++++++-------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/weaving/DefaultContextLoadTimeWeaver.java b/spring-context/src/main/java/org/springframework/context/weaving/DefaultContextLoadTimeWeaver.java index 0b093d8147..8e89521752 100644 --- a/spring-context/src/main/java/org/springframework/context/weaving/DefaultContextLoadTimeWeaver.java +++ b/spring-context/src/main/java/org/springframework/context/weaving/DefaultContextLoadTimeWeaver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,12 +39,13 @@ import org.springframework.util.Assert; * Default {@link LoadTimeWeaver} bean for use in an application context, * decorating an automatically detected internal {@code LoadTimeWeaver}. * - *

Typically registered for the default bean name - * "{@code loadTimeWeaver}"; the most convenient way to achieve this is - * Spring's {@code } XML tag. + *

Typically registered for the default bean name "{@code loadTimeWeaver}"; + * the most convenient way to achieve this is Spring's + * {@code } XML tag or {@code @EnableLoadTimeWeaving} + * on a {@code @Configuration} class. * *

This class implements a runtime environment check for obtaining the - * appropriate weaver implementation: As of Spring Framework 5.0, it detects + * appropriate weaver implementation. As of Spring Framework 5.0, it detects * Oracle WebLogic 10+, GlassFish 4+, Tomcat 8+, WildFly 8+, IBM WebSphere 8.5+, * {@link InstrumentationSavingAgent Spring's VM agent}, and any {@link ClassLoader} * supported by Spring's {@link ReflectiveLoadTimeWeaver} (such as Liberty's). @@ -95,7 +96,7 @@ public class DefaultContextLoadTimeWeaver implements LoadTimeWeaver, BeanClassLo } catch (IllegalStateException ex) { throw new IllegalStateException(ex.getMessage() + " Specify a custom LoadTimeWeaver or start your " + - "Java virtual machine with Spring's agent: -javaagent:org.springframework.instrument.jar"); + "Java virtual machine with Spring's agent: -javaagent:spring-instrument-{version}.jar"); } } } diff --git a/spring-context/src/main/java/org/springframework/instrument/classloading/InstrumentationLoadTimeWeaver.java b/spring-context/src/main/java/org/springframework/instrument/classloading/InstrumentationLoadTimeWeaver.java index 2dd21015d6..3ed5601b7f 100644 --- a/spring-context/src/main/java/org/springframework/instrument/classloading/InstrumentationLoadTimeWeaver.java +++ b/spring-context/src/main/java/org/springframework/instrument/classloading/InstrumentationLoadTimeWeaver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,16 +31,18 @@ import org.springframework.util.ClassUtils; /** * {@link LoadTimeWeaver} relying on VM {@link Instrumentation}. * - *

Start the JVM specifying the Java agent to be used, like as follows: + *

Start the JVM specifying the Java agent to be used — for example, as + * follows where spring-instrument-{version}.jar is a JAR file + * containing the {@link InstrumentationSavingAgent} class shipped with Spring + * and where {version} is the release version of the Spring + * Framework (e.g., {@code 5.1.5.RELEASE}). * - *

-javaagent:path/to/org.springframework.instrument.jar + *

-javaagent:path/to/spring-instrument-{version}.jar * - *

where {@code org.springframework.instrument.jar} is a JAR file containing - * the {@link InstrumentationSavingAgent} class, as shipped with Spring. + *

In Eclipse, for example, add something similar to the following to the + * JVM arguments for the Eclipse "Run configuration": * - *

In Eclipse, for example, set the "Run configuration"'s JVM args to be of the form: - * - *

-javaagent:${project_loc}/lib/org.springframework.instrument.jar + *

-javaagent:${project_loc}/lib/spring-instrument-{version}.jar * * @author Rod Johnson * @author Juergen Hoeller