aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.classpath2
-rw-r--r--.settings/org.eclipse.jdt.core.prefs31
-rw-r--r--.settings/org.eclipse.jdt.launching.prefs3
-rw-r--r--buildScripts/compile.ant.xml2
-rw-r--r--src/core/lombok/core/Agent.java108
-rw-r--r--src/installer/lombok/installer/IdeLocation.java4
-rw-r--r--src/installer/lombok/installer/Installer.java1
-rw-r--r--src/installer/lombok/installer/eclipse/STSFinder.java3
8 files changed, 132 insertions, 22 deletions
diff --git a/.classpath b/.classpath
index 5b18e629..953e7d9a 100644
--- a/.classpath
+++ b/.classpath
@@ -8,7 +8,7 @@
<classpathentry kind="src" path="experimental/src"/>
<classpathentry kind="src" path="test/delombok/src"/>
<classpathentry kind="src" path="test/core/src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="lib" path="deps/lombok/eclipse/org.eclipse.jdt.core_3.5.0.v_963.jar"/>
<classpathentry kind="lib" path="deps/lombok/eclipse/org.eclipse.jdt.ui_3.5.1.r351_v20090821-0800.jar"/>
<classpathentry kind="lib" path="deps/lombok/eclipse/org.eclipse.core.runtime_3.5.0.v20090525.jar"/>
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
index 807a9a51..aab1b6fa 100644
--- a/.settings/org.eclipse.jdt.core.prefs
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -1,5 +1,13 @@
-#Sun Oct 18 14:45:17 CEST 2009
+#Sat Dec 12 14:05:24 CET 2009
eclipse.preferences.version=1
+org.eclipse.jdt.core.builder.cleanOutputFolder=clean
+org.eclipse.jdt.core.builder.duplicateResourceTask=warning
+org.eclipse.jdt.core.builder.invalidClasspath=abort
+org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder=ignore
+org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch
+org.eclipse.jdt.core.circularClasspath=error
+org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
+org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
@@ -7,6 +15,8 @@ org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.doc.comment.support=enabled
+org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
@@ -23,15 +33,27 @@ org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=ignore
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
+org.eclipse.jdt.core.compiler.problem.invalidJavadoc=ignore
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=disabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public
org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
+org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag
+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
@@ -73,3 +95,8 @@ org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.processAnnotations=enabled
org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled
+org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,HIGH,NORMAL
+org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME,XXX
+org.eclipse.jdt.core.incompatibleJDKLevel=ignore
+org.eclipse.jdt.core.incompleteClasspath=warning
diff --git a/.settings/org.eclipse.jdt.launching.prefs b/.settings/org.eclipse.jdt.launching.prefs
new file mode 100644
index 00000000..9d56586e
--- /dev/null
+++ b/.settings/org.eclipse.jdt.launching.prefs
@@ -0,0 +1,3 @@
+#Sat Dec 12 13:38:59 CET 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=warning
diff --git a/buildScripts/compile.ant.xml b/buildScripts/compile.ant.xml
index 1cc6933c..726cfcb4 100644
--- a/buildScripts/compile.ant.xml
+++ b/buildScripts/compile.ant.xml
@@ -116,6 +116,7 @@ lombok code including the various agents.
<exclude name="lombok/javac/**" />
<classpath refid="deps.path" />
<classpath refid="libs.path" />
+ <compilerarg value="-Xlint:unchecked" />
</javac>
<javac debug="on" destdir="build/lombok" target="1.6" source="1.6">
<src path="src/core" />
@@ -127,6 +128,7 @@ lombok code including the various agents.
<classpath location="build/lombok" />
<classpath refid="deps.path" />
<classpath refid="libs.path" />
+ <compilerarg value="-Xlint:unchecked" />
</javac>
<copy todir="build/lombok">
<fileset dir="src/installer">
diff --git a/src/core/lombok/core/Agent.java b/src/core/lombok/core/Agent.java
index 2ba6bb20..6f93478a 100644
--- a/src/core/lombok/core/Agent.java
+++ b/src/core/lombok/core/Agent.java
@@ -21,42 +21,118 @@
*/
package lombok.core;
+import java.lang.instrument.ClassFileTransformer;
+import java.lang.instrument.IllegalClassFormatException;
import java.lang.instrument.Instrumentation;
+import java.security.ProtectionDomain;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import javax.swing.JOptionPane;
+import javax.swing.SwingUtilities;
+
public abstract class Agent {
protected abstract void runAgent(String agentArgs, Instrumentation instrumentation, boolean injected) throws Exception;
- public static void agentmain(String agentArgs, Instrumentation instrumentation) throws Exception {
+ public static void agentmain(String agentArgs, Instrumentation instrumentation) throws Throwable {
runAgents(agentArgs, instrumentation, true);
}
- public static void premain(String agentArgs, Instrumentation instrumentation) throws Exception {
+ public static void premain(String agentArgs, Instrumentation instrumentation) throws Throwable {
runAgents(agentArgs, instrumentation, false);
}
- private static final List<String> AGENT_NAMES = Collections.unmodifiableList(Arrays.asList(
- "lombok.netbeans.agent.NetbeansPatcher",
- "lombok.eclipse.agent.EclipsePatcher"
- ));
+ private static final List<AgentInfo> AGENTS = Collections.unmodifiableList(Arrays.asList(
+ new NetbeansPatcherInfo(),
+ new EclipsePatcherInfo()
+ ));
- private static void runAgents(String agentArgs, Instrumentation instrumentation, boolean injected) throws Exception {
- for (String agentName : AGENT_NAMES) {
+ private static void runAgents(String agentArgs, Instrumentation instrumentation, boolean injected) throws Throwable {
+ for (AgentInfo info : AGENTS) {
try {
- Class<?> agentClass = Class.forName(agentName);
+ Class<?> agentClass = Class.forName(info.className());
Agent agent = (Agent) agentClass.newInstance();
agent.runAgent(agentArgs, instrumentation, injected);
- } catch (ClassNotFoundException e) {
+ } catch (Throwable t) {
+ info.problem(t, instrumentation);
+ }
+ }
+ }
+
+ private static abstract class AgentInfo {
+ abstract String className();
+
+ /**
+ * Called if an exception occurs while loading the agent represented by this AgentInfo object.
+ *
+ * @param t The throwable.
+ * @param instrumentation In case you want to take an alternative action.
+ */
+ void problem(Throwable t, Instrumentation instrumentation) throws Throwable {
+ if (t instanceof ClassNotFoundException) {
//That's okay - this lombok evidently is a version with support for something stripped out.
- } catch (ClassCastException e) {
- throw new InternalError("Lombok bug. Class: " + agentName + " is not an implementation of lombok.core.Agent");
- } catch (IllegalAccessException e) {
- throw new InternalError("Lombok bug. Class: " + agentName + " is not public");
- } catch (InstantiationException e) {
- throw new InternalError("Lombok bug. Class: " + agentName + " is not concrete or has no public no-args constructor");
+ return;
}
+
+ if (t instanceof ClassCastException) {
+ throw new InternalError("Lombok bug. Class: " + className() + " is not an implementation of lombok.core.Agent");
+ }
+
+ if (t instanceof IllegalAccessError) {
+ throw new InternalError("Lombok bug. Class: " + className() + " is not public");
+ }
+
+ if (t instanceof InstantiationException) {
+ throw new InternalError("Lombok bug. Class: " + className() + " is not concrete or has no public no-args constructor");
+ }
+
+ throw t;
+ }
+ }
+
+ private static class NetbeansPatcherInfo extends AgentInfo {
+ @Override String className() {
+ return "lombok.netbeans.agent.NetbeansPatcher";
+ }
+
+ @Override void problem(Throwable in, Instrumentation instrumentation) throws Throwable {
+ try {
+ super.problem(in, instrumentation);
+ } catch (InternalError ie) {
+ throw ie;
+ } catch (Throwable t) {
+ final String error;
+
+ if (t instanceof UnsupportedClassVersionError) {
+ error = "Lombok only works on netbeans if you start netbeans using a 1.6 or higher JVM.\n" +
+ "Change your platform's default JVM, or edit etc/netbeans.conf\n" +
+ "and explicitly tell netbeans your 1.6 JVM's location.";
+ } else {
+ error = "Lombok disabled due to error: " + t;
+ }
+
+ instrumentation.addTransformer(new ClassFileTransformer() {
+ @Override public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException {
+ if ("org/netbeans/modules/java/source/parsing/JavacParser".equals(className)) {
+ //If that class gets loaded, this is definitely a netbeans(-esque) environment, and thus we SHOULD tell the user that lombok is not in fact loaded.
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override public void run() {
+ JOptionPane.showMessageDialog(null, error, "Lombok Disabled", JOptionPane.ERROR_MESSAGE);
+ }
+ });
+ }
+
+ return null;
+ }
+ });
+ }
+ }
+ }
+
+ private static class EclipsePatcherInfo extends AgentInfo {
+ @Override String className() {
+ return "lombok.eclipse.agent.EclipsePatcher";
}
}
}
diff --git a/src/installer/lombok/installer/IdeLocation.java b/src/installer/lombok/installer/IdeLocation.java
index e23a0033..f23eef01 100644
--- a/src/installer/lombok/installer/IdeLocation.java
+++ b/src/installer/lombok/installer/IdeLocation.java
@@ -48,6 +48,10 @@ public abstract class IdeLocation {
return new File(LiveInjector.findPathJar(IdeFinder.class));
}
+ @Override public String toString() {
+ return getName();
+ }
+
/**
* Returns a full path to the provided file.
* Returns the canonical path, unless that is not available, in which cae it returns the absolute path.
diff --git a/src/installer/lombok/installer/Installer.java b/src/installer/lombok/installer/Installer.java
index 9ed9e93a..7700cd90 100644
--- a/src/installer/lombok/installer/Installer.java
+++ b/src/installer/lombok/installer/Installer.java
@@ -240,7 +240,6 @@ public class Installer {
IdeLocation loc = tryAllProviders(rawPath);
if (loc != null) locations.add(loc);
else problems.add(new CorruptedIdeLocationException("Can't find any IDE at: " + rawPath, null, null));
- locations.add(tryAllProviders(rawPath));
} catch (CorruptedIdeLocationException e) {
problems.add(e);
}
diff --git a/src/installer/lombok/installer/eclipse/STSFinder.java b/src/installer/lombok/installer/eclipse/STSFinder.java
index 47abb186..15e0404d 100644
--- a/src/installer/lombok/installer/eclipse/STSFinder.java
+++ b/src/installer/lombok/installer/eclipse/STSFinder.java
@@ -57,8 +57,7 @@ public class STSFinder extends EclipseFinder {
}
@Override protected List<String> getSourceDirsOnWindows() {
-// return Arrays.asList("\\", "\\springsource", "\\Program Files", "\\Program Files\\springsource", System.getProperty("user.home", "."), System.getProperty("user.home", ".") + "\\springsource");
- return Arrays.asList();
+ return Arrays.asList("\\", "\\springsource", "\\Program Files", "\\Program Files\\springsource", System.getProperty("user.home", "."), System.getProperty("user.home", ".") + "\\springsource");
}
@Override protected List<String> getSourceDirsOnMac() {