aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2014-05-08 00:39:31 +0200
committerReinier Zwitserloot <reinier@zwitserloot.com>2014-05-08 00:39:59 +0200
commit7f85149f3959335f1be3e75f3695e00fb1cd3594 (patch)
tree1bf2a9c9affa84e4e5bfa18a631ac5e2bd1c9528 /src/core/lombok/javac
parent65d89f077e10820ebbfe48af99c38c60472a8eb9 (diff)
downloadlombok-7f85149f3959335f1be3e75f3695e00fb1cd3594.tar.gz
lombok-7f85149f3959335f1be3e75f3695e00fb1cd3594.tar.bz2
lombok-7f85149f3959335f1be3e75f3695e00fb1cd3594.zip
bugfix: our new trick to try and disable target typing by making the LHS of a 'val' statement be of an unknown type instead of j.l.Object works for Javac8, but breaks Javac6! We now detect this and pick the right strategy based on whether or not the compiler supports target typing.
Diffstat (limited to 'src/core/lombok/javac')
-rw-r--r--src/core/lombok/javac/JavacResolution.java17
-rw-r--r--src/core/lombok/javac/handlers/HandleVal.java6
2 files changed, 10 insertions, 13 deletions
diff --git a/src/core/lombok/javac/JavacResolution.java b/src/core/lombok/javac/JavacResolution.java
index 5631e62c..ec455b18 100644
--- a/src/core/lombok/javac/JavacResolution.java
+++ b/src/core/lombok/javac/JavacResolution.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011-2013 The Project Lombok Authors.
+ * Copyright (C) 2011-2014 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -94,17 +94,6 @@ public class JavacResolution {
@Override public void visitClassDef(JCClassDecl tree) {
if (copyAt != null) return;
- // The commented out stuff requires reflection tricks to avoid leaving lint unset which causes NPEs during attrib. So, we use the other one, much less code.
-// env = enter.classEnv((JCClassDecl) tree, env);
-// try {
-// Field f = env.info.getClass().getDeclaredField("lint");
-// f.setAccessible(true);
-// Constructor<?> c = Lint.class.getDeclaredConstructor(Lint.class);
-// c.setAccessible(true);
-// f.set(env.info, c.newInstance(lint));
-// } catch (Exception e) {
-// throw Lombok.sneakyThrow(e);
-// }
env = enter.getClassEnv(tree.sym);
}
@@ -358,4 +347,8 @@ public class JavacResolution {
throw new TypeNotConvertibleException("Nulltype");
}
}
+
+ public static boolean platformHasTargetTyping() {
+ return Javac.getJavaCompilerVersion() >= 8;
+ }
}
diff --git a/src/core/lombok/javac/handlers/HandleVal.java b/src/core/lombok/javac/handlers/HandleVal.java
index eb3a2f46..0230e1b0 100644
--- a/src/core/lombok/javac/handlers/HandleVal.java
+++ b/src/core/lombok/javac/handlers/HandleVal.java
@@ -91,7 +91,11 @@ public class HandleVal extends JavacASTAdapter {
local.mods.annotations = local.mods.annotations == null ? List.of(valAnnotation) : local.mods.annotations.append(valAnnotation);
}
- local.vartype = localNode.getAst().getTreeMaker().Ident(localNode.getAst().toName("___Lombok_VAL_Attrib__"));
+ if (JavacResolution.platformHasTargetTyping()) {
+ local.vartype = localNode.getAst().getTreeMaker().Ident(localNode.getAst().toName("___Lombok_VAL_Attrib__"));
+ } else {
+ local.vartype = JavacResolution.createJavaLangObject(localNode.getAst());
+ }
Type type;
try {