New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to compile on Java 8 #1738
Comments
Original comment posted by lowasser@google.com on 2014-04-24 at 04:41 PM The only way to make the same Guava compile against both Java 7 and Java 8 would be to add a version of the new Java 8 AnnotatedType interface on the bootclasspath in Java 7, because getAnnotatedBounds has AnnotatedType[] as its return type. This is not impossible, but would require noticeable changes to the way Guava is built, which we are investigating internally and externally. Labels: |
Original comment posted by cpovirk@google.com on 2014-04-24 at 05:15 PM (Louis, I assume that you're aware that we once had a crazy guava-bootstrap project around for dealing with an incompatible ExecutorService change? We could probably do the same here if we enjoy craziness :) Naturally that doesn't solve any problems with the internal build.) |
Original comment posted by lowasser@google.com on 2014-04-24 at 05:17 PM The internal build is actually addressed, and I know about guava-bootstrap. I'm mostly saying we'd have to revive it, and I don't remember the nitty-gritty about how we'd do that. I think providing the bootclasspath would make Guava build on Java 6, 7, and 8, but we don't need to build on 6 internally, so that would need testing too. |
Original comment posted by socram8888 on 2014-04-24 at 07:22 PM In Java 7, AnnotatedElement and TypeVariable are independent, but in Java 8 TypeVariable extends AnnotatedElement. Couldn't you just implement the said method, and then add change "implements TypeVariable" by "implements TypeVariable, AnnotatedElement"? I don't know if Java would let you do that, however, implementing an interface and an another interface that extends the first. |
Original comment posted by lowasser@google.com on 2014-04-24 at 07:23 PM That doesn't help. In Java 8, TypeVariable gets a new method, without a default implementation, returning AnnotatedType, a type that did not exist in Java 7. There's no way around the bootclasspath approach. |
Original comment posted by socram8888 on 2014-04-24 at 08:23 PM Sorry, I thought the new method was being inherited from the AnnotatedElement class. Another idea: wouldn't it be possible to just implement the method, without the @Override annotation? In Java 7 and 6, it would be just "ignored", while it would override the new abstract method in the interface. |
Original comment posted by lowasser@google.com on 2014-04-24 at 08:24 PM It would be possible to implement the method if the return type existed in Java 7, but it doesn't. |
Original comment posted by socram8888 on 2014-04-24 at 08:32 PM You can create just the new method without actually specifiying that it implements anything (ie without the @Override). In Java 7, this would act like any other public method, while in Java 8 it would act like an implementation of the said method in the interface. |
Original comment posted by lowasser@google.com on 2014-04-24 at 08:34 PM I'm not being clear. In Java 8, the bare minimum you'd have to write is
...with no @Override annotation. But that cannot compile in Java 7 without adding the AnnotatedType interface to the bootclasspath. |
Original comment posted by socram8888 on 2014-04-24 at 08:35 PM My bad, forgot that Java 7 SE didn't had the AnnotatedType class :/ |
Original comment posted by zbys...@in.waw.pl on 2014-06-14 at 12:04 AM |
Original comment posted by lchh555 on 2014-10-10 at 12:27 AM Has this been fixed? |
It's likely that we are not going to be able to make Guava compile on JDK8 as long as it supports a JDK < 8. |
I presume we are talking about com.google.common.reflect.Types.TypeVariableImpl. Wouldn't it be possible to use a dynamic proxy instead of that class? |
Yes, @fluentfuture @lowasser Any thoughts? The main thing we probably can't do is add |
I don't know enough about dynamic proxies to have any sense of whether they would or wouldn't help here =/ |
I am going to do a little experimentation. |
If all we want to do for the new But regardless of that, it seems that we do need to properly support getAnnotatedBounds(). We need to do the same type resolving as we do for getBounds(). Is this the only compatibility problem in Java 8? I guess if we had two or three, then the cost of hacking up patches would be high enough to be not worth it. Is it possible, for example, to tack on different source files per JDK version? For example, what if we have a ResolvedTypeVariable.8 file and ResolvedTypeVariable.old file and whatever the build rule can copy one of them as ResolvedTypeVariable.java? Going forward, versioned source file solution would work better for any other similar situations we may run into. |
I think it does depend on how many other problems we encounter. As far as I know this is the only one for now, and I don't think it justifies cooking up a special build solution just for it. I believe the only impact of throwing UnsupportedOperationException is that users can't call getAnnotatedBounds() on the TypeVariable implementations we give them from TypeResolved.resolveType. It may be that they can live with that. :-) |
In addition to getAnnotatedBounds(), there are other getAnnotated*() methods in Java 8 that could benefit from TypeToken type resolution. For example, method.getAnnotatedParameterTypes(), Class.getAnnotatedSuperclass() etc. It seems like we are in a dilemma that we either be backward compatible, or add support for JDK 8 features. Dynamic proxy seems like a short-term solution that gets us compiled (although the TypeVariable impl becomes crippled). Longer term, it seems we just need to drop support for older versions at some point, in order to be able to add more value. |
|
It's already crippled under JDK 8 internally. I guess it was done just to unblock the upgrade process. Proper implementation of getAnnotatedBounds() and support for all the other new Annotated* types can come after we are fully on JDK 8. |
It's crippled under JDK 8 externally as well. The |
Sorry I misunderstood. Are you saying that someone under JDK 8, tries to use a Guava jar compiled under JDK 7? Externally, Guava doesn't compile under JDK 8 so that's where my confusion is. |
Yep, I'm referring to what happens at runtime on JDK 8, with Guava compiled under JDK 7. |
See google/guava#1738 and https://github.com/google/guava/blob/95117a4d625a5d733da1b504affdde2a808 fd3ea/guava/src/com/google/common/reflect/Types.java#L337-L349 +review REVIEW-5566
Required for building host libraries with OpenJDK 8. Without this, trying to build with Java 8 fails with: external/guava/guava/src/com/google/common/reflect/Types.java:317: error: TypeVariableImpl is not abstract and does not override abstract method getAnnotatedBounds() in TypeVariable private static final class TypeVariableImpl<D extends GenericDeclaration> Backport of google/guava@f4aa25e See google/guava#1738 Bug: 23074347 Change-Id: I35adc64a339055e1e426af2aa3a41058f9948984
Required for building host libraries with OpenJDK 8. Without this, trying to build with Java 8 fails with: external/guava/guava/src/com/google/common/reflect/Types.java:317: error: TypeVariableImpl is not abstract and does not override abstract method getAnnotatedBounds() in TypeVariable private static final class TypeVariableImpl<D extends GenericDeclaration> Backport of google/guava@f4aa25e See google/guava#1738 Bug: 23074347 Change-Id: I35adc64a339055e1e426af2aa3a41058f9948984 Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
Required for building host libraries with OpenJDK 8. Without this, trying to build with Java 8 fails with: external/guava/guava/src/com/google/common/reflect/Types.java:317: error: TypeVariableImpl is not abstract and does not override abstract method getAnnotatedBounds() in TypeVariable private static final class TypeVariableImpl<D extends GenericDeclaration> Backport of google/guava@f4aa25e See google/guava#1738 Bug: 23074347 Change-Id: I35adc64a339055e1e426af2aa3a41058f9948984
Required for building host libraries with OpenJDK 8. Without this, trying to build with Java 8 fails with: external/guava/guava/src/com/google/common/reflect/Types.java:317: error: TypeVariableImpl is not abstract and does not override abstract method getAnnotatedBounds() in TypeVariable private static final class TypeVariableImpl<D extends GenericDeclaration> Backport of google/guava@f4aa25e See google/guava#1738 Bug: 23074347 Change-Id: I35adc64a339055e1e426af2aa3a41058f9948984 Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
Required for building host libraries with OpenJDK 8. Without this, trying to build with Java 8 fails with: external/guava/guava/src/com/google/common/reflect/Types.java:317: error: TypeVariableImpl is not abstract and does not override abstract method getAnnotatedBounds() in TypeVariable private static final class TypeVariableImpl<D extends GenericDeclaration> Backport of google/guava@f4aa25e See google/guava#1738 Bug: 23074347 Change-Id: I35adc64a339055e1e426af2aa3a41058f9948984 Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
Required for building host libraries with OpenJDK 8. Without this, trying to build with Java 8 fails with: external/guava/guava/src/com/google/common/reflect/Types.java:317: error: TypeVariableImpl is not abstract and does not override abstract method getAnnotatedBounds() in TypeVariable private static final class TypeVariableImpl<D extends GenericDeclaration> Backport of google/guava@f4aa25e See google/guava#1738 Bug: 23074347
Required for building host libraries with OpenJDK 8. Without this, trying to build with Java 8 fails with: external/guava/guava/src/com/google/common/reflect/Types.java:317: error: TypeVariableImpl is not abstract and does not override abstract method getAnnotatedBounds() in TypeVariable private static final class TypeVariableImpl<D extends GenericDeclaration> Backport of google/guava@f4aa25e See google/guava#1738 Bug: 23074347 Change-Id: I35adc64a339055e1e426af2aa3a41058f9948984 Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
Required for building host libraries with OpenJDK 8. Without this, trying to build with Java 8 fails with: external/guava/guava/src/com/google/common/reflect/Types.java:317: error: TypeVariableImpl is not abstract and does not override abstract method getAnnotatedBounds() in TypeVariable private static final class TypeVariableImpl<D extends GenericDeclaration> Backport of google/guava@f4aa25e See google/guava#1738 Bug: 23074347 Change-Id: I35adc64a339055e1e426af2aa3a41058f9948984
Required for building host libraries with OpenJDK 8. Without this, trying to build with Java 8 fails with: external/guava/guava/src/com/google/common/reflect/Types.java:317: error: TypeVariableImpl is not abstract and does not override abstract method getAnnotatedBounds() in TypeVariable private static final class TypeVariableImpl<D extends GenericDeclaration> Backport of google/guava@f4aa25e See google/guava#1738 Bug: 23074347 Change-Id: I35adc64a339055e1e426af2aa3a41058f9948984
Required for building host libraries with OpenJDK 8. Without this, trying to build with Java 8 fails with: external/guava/guava/src/com/google/common/reflect/Types.java:317: error: TypeVariableImpl is not abstract and does not override abstract method getAnnotatedBounds() in TypeVariable private static final class TypeVariableImpl<D extends GenericDeclaration> Backport of google/guava@f4aa25e See google/guava#1738 Bug: 23074347 Change-Id: I35adc64a339055e1e426af2aa3a41058f9948984
Required for building host libraries with OpenJDK 8. Without this, trying to build with Java 8 fails with: external/guava/guava/src/com/google/common/reflect/Types.java:317: error: TypeVariableImpl is not abstract and does not override abstract method getAnnotatedBounds() in TypeVariable private static final class TypeVariableImpl<D extends GenericDeclaration> Backport of google/guava@f4aa25e See google/guava#1738 Bug: 23074347 Change-Id: I35adc64a339055e1e426af2aa3a41058f9948984
Required for building host libraries with OpenJDK 8. Without this, trying to build with Java 8 fails with: external/guava/guava/src/com/google/common/reflect/Types.java:317: error: TypeVariableImpl is not abstract and does not override abstract method getAnnotatedBounds() in TypeVariable private static final class TypeVariableImpl<D extends GenericDeclaration> Backport of google/guava@f4aa25e See google/guava#1738 Bug: 23074347 Change-Id: I35adc64a339055e1e426af2aa3a41058f9948984 Signed-off-by: xyyx <xyyx@mail.ru>
Required for building host libraries with OpenJDK 8. Without this, trying to build with Java 8 fails with: external/guava/guava/src/com/google/common/reflect/Types.java:317: error: TypeVariableImpl is not abstract and does not override abstract method getAnnotatedBounds() in TypeVariable private static final class TypeVariableImpl<D extends GenericDeclaration> Backport of google/guava@f4aa25e See google/guava#1738 Bug: 23074347 Change-Id: I35adc64a339055e1e426af2aa3a41058f9948984 Conflicts: guava/src/com/google/common/reflect/Types.java
Required for building host libraries with OpenJDK 8. Without this, trying to build with Java 8 fails with: external/guava/guava/src/com/google/common/reflect/Types.java:317: error: TypeVariableImpl is not abstract and does not override abstract method getAnnotatedBounds() in TypeVariable private static final class TypeVariableImpl<D extends GenericDeclaration> Backport of google/guava@f4aa25e See google/guava#1738 Bug: 23074347 Change-Id: I35adc64a339055e1e426af2aa3a41058f9948984 Signed-off-by: Chet Kener <Cl3Kener@gmail.com>
Required for building host libraries with OpenJDK 8. Without this, trying to build with Java 8 fails with: external/guava/guava/src/com/google/common/reflect/Types.java:317: error: TypeVariableImpl is not abstract and does not override abstract method getAnnotatedBounds() in TypeVariable private static final class TypeVariableImpl<D extends GenericDeclaration> Backport of google/guava@f4aa25e See google/guava#1738 Bug: 23074347 Change-Id: I35adc64a339055e1e426af2aa3a41058f9948984
Required for building host libraries with OpenJDK 8. Without this, trying to build with Java 8 fails with: external/guava/guava/src/com/google/common/reflect/Types.java:317: error: TypeVariableImpl is not abstract and does not override abstract method getAnnotatedBounds() in TypeVariable private static final class TypeVariableImpl<D extends GenericDeclaration> Backport of google/guava@f4aa25e See google/guava#1738 Bug: 23074347 Change-Id: I35adc64a339055e1e426af2aa3a41058f9948984
Required for building host libraries with OpenJDK 8. Without this, trying to build with Java 8 fails with: external/guava/guava/src/com/google/common/reflect/Types.java:317: error: TypeVariableImpl is not abstract and does not override abstract method getAnnotatedBounds() in TypeVariable private static final class TypeVariableImpl<D extends GenericDeclaration> Backport of google/guava@f4aa25e See google/guava#1738 Bug: 23074347 Change-Id: Ie7f93255f03b8d430509739f013763fd11d1dbb9 Signed-off-by: Chet Kener <Cl3Kener@gmail.com> Signed-off-by: Paul Keith <javelinanddart@gmail.com>
Required for building host libraries with OpenJDK 8. Without this, trying to build with Java 8 fails with: external/guava/guava/src/com/google/common/reflect/Types.java:317: error: TypeVariableImpl is not abstract and does not override abstract method getAnnotatedBounds() in TypeVariable private static final class TypeVariableImpl<D extends GenericDeclaration> Backport of google/guava@f4aa25e See google/guava#1738 Bug: 23074347 Change-Id: I35adc64a339055e1e426af2aa3a41058f9948984 Signed-off-by: Raleigh Matlock <raleighman2@gmail.com>
Required for building host libraries with OpenJDK 8. Without this, trying to build with Java 8 fails with: external/guava/guava/src/com/google/common/reflect/Types.java:317: error: TypeVariableImpl is not abstract and does not override abstract method getAnnotatedBounds() in TypeVariable private static final class TypeVariableImpl<D extends GenericDeclaration> Backport of google/guava@f4aa25e See google/guava#1738 Bug: 23074347 Signed-off-by: Raleigh Matlock <raleighman2@gmail.com>
Required for building host libraries with OpenJDK 8. Without this, trying to build with Java 8 fails with: external/guava/guava/src/com/google/common/reflect/Types.java:317: error: TypeVariableImpl is not abstract and does not override abstract method getAnnotatedBounds() in TypeVariable private static final class TypeVariableImpl<D extends GenericDeclaration> Backport of google/guava@f4aa25e See google/guava#1738 Bug: 23074347 Change-Id: I35adc64a339055e1e426af2aa3a41058f9948984 Conflicts: guava/src/com/google/common/reflect/Types.java
Required for building host libraries with OpenJDK 8. Without this, trying to build with Java 8 fails with: external/guava/guava/src/com/google/common/reflect/Types.java:317: error: TypeVariableImpl is not abstract and does not override abstract method getAnnotatedBounds() in TypeVariable private static final class TypeVariableImpl<D extends GenericDeclaration> Backport of google/guava@f4aa25e See google/guava#1738 Bug: 23074347 Change-Id: I35adc64a339055e1e426af2aa3a41058f9948984
Required for building host libraries with OpenJDK 8. Without this, trying to build with Java 8 fails with: external/guava/guava/src/com/google/common/reflect/Types.java:317: error: TypeVariableImpl is not abstract and does not override abstract method getAnnotatedBounds() in TypeVariable private static final class TypeVariableImpl<D extends GenericDeclaration> Backport of google/guava@f4aa25e See google/guava#1738 Bug: 23074347 Change-Id: I35adc64a339055e1e426af2aa3a41058f9948984
Required for building host libraries with OpenJDK 8. Without this, trying to build with Java 8 fails with: external/guava/guava/src/com/google/common/reflect/Types.java:317: error: TypeVariableImpl is not abstract and does not override abstract method getAnnotatedBounds() in TypeVariable private static final class TypeVariableImpl<D extends GenericDeclaration> Backport of google/guava@f4aa25e See google/guava#1738 Bug: 23074347 Change-Id: I35adc64a339055e1e426af2aa3a41058f9948984
Required for building host libraries with OpenJDK 8. Without this, trying to build with Java 8 fails with: external/guava/guava/src/com/google/common/reflect/Types.java:317: error: TypeVariableImpl is not abstract and does not override abstract method getAnnotatedBounds() in TypeVariable private static final class TypeVariableImpl<D extends GenericDeclaration> Backport of google/guava@f4aa25e See google/guava#1738 Bug: 23074347 Change-Id: I35adc64a339055e1e426af2aa3a41058f9948984
Required for building host libraries with OpenJDK 8. Without this, trying to build with Java 8 fails with: external/guava/guava/src/com/google/common/reflect/Types.java:317: error: TypeVariableImpl is not abstract and does not override abstract method getAnnotatedBounds() in TypeVariable private static final class TypeVariableImpl<D extends GenericDeclaration> Backport of google/guava@f4aa25e See google/guava#1738 Bug: 23074347 Change-Id: I35adc64a339055e1e426af2aa3a41058f9948984
Required for building host libraries with OpenJDK 8. Without this, trying to build with Java 8 fails with: external/guava/guava/src/com/google/common/reflect/Types.java:317: error: TypeVariableImpl is not abstract and does not override abstract method getAnnotatedBounds() in TypeVariable private static final class TypeVariableImpl<D extends GenericDeclaration> Backport of google/guava@f4aa25e See google/guava#1738 Bug: 23074347 Change-Id: I35adc64a339055e1e426af2aa3a41058f9948984
Original issue created by socram8888 on 2014-04-24 at 10:38 AM
Apparently Oracle has added a new abstract method to TypeVariable (getAnnotatedBounds) which is not implemented.
The text was updated successfully, but these errors were encountered: