mirror of https://github.com/apache/lucene.git
LUCENE-10185: pass --release 11 to ECJ linter, fix JDK 17 build (#393)
* LUCENE-10185: pass --release 11 to ECJ linter, fix JDK 17 build Otherwise, new java releases such as JDK 18, JDK 19, ... may have even more new deprecations, the build shouldn't fail in such cases. Remove -source/-target now that we pass --release Fix casting so ECJ understands it and creates correct call signature (UweSays: "It's ok. I know why it happens, but it's a bug in ECJ. The type safety is checked by the invokeexact") Co-authored-by: Uwe Schindler <uschindler@apache.org>
This commit is contained in:
parent
c4c3c3270e
commit
f8d431ae44
|
@ -63,8 +63,7 @@ allprojects {
|
||||||
args += [ "-d", "none" ]
|
args += [ "-d", "none" ]
|
||||||
|
|
||||||
// Compilation environment.
|
// Compilation environment.
|
||||||
args += [ "-source", project.java.sourceCompatibility ]
|
args += [ "--release", project.java.targetCompatibility ]
|
||||||
args += [ "-target", project.java.targetCompatibility ]
|
|
||||||
args += [ "-encoding", "UTF-8"]
|
args += [ "-encoding", "UTF-8"]
|
||||||
args += [ "-proc:none" ]
|
args += [ "-proc:none" ]
|
||||||
args += [ "-nowarn" ]
|
args += [ "-nowarn" ]
|
||||||
|
|
|
@ -149,9 +149,13 @@ public abstract class AttributeFactory {
|
||||||
final MethodHandle constr = findAttributeImplCtor(clazz);
|
final MethodHandle constr = findAttributeImplCtor(clazz);
|
||||||
return new StaticImplementationAttributeFactory<A>(delegate, clazz) {
|
return new StaticImplementationAttributeFactory<A>(delegate, clazz) {
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
protected A createInstance() {
|
protected A createInstance() {
|
||||||
try {
|
try {
|
||||||
return (A) constr.invokeExact();
|
// be explicit with casting, so javac compiles correct call to polymorphic signature:
|
||||||
|
final AttributeImpl impl = (AttributeImpl) constr.invokeExact();
|
||||||
|
// now cast to generic type:
|
||||||
|
return (A) impl;
|
||||||
} catch (Error | RuntimeException e) {
|
} catch (Error | RuntimeException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
|
Loading…
Reference in New Issue