Skip to content
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

Closed
gissuebot opened this issue Oct 31, 2014 · 43 comments
Closed

Unable to compile on Java 8 #1738

gissuebot opened this issue Oct 31, 2014 · 43 comments

Comments

@gissuebot
Copy link

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.

@gissuebot
Copy link
Author

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: Type-Dev, Package-Reflect

@gissuebot
Copy link
Author

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.)

@gissuebot
Copy link
Author

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.

@gissuebot
Copy link
Author

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.

@gissuebot
Copy link
Author

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.

@gissuebot
Copy link
Author

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.

@gissuebot
Copy link
Author

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.

@gissuebot
Copy link
Author

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.

@gissuebot
Copy link
Author

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

AnnotatedType[] getAnnotatedBounds() {
  return null;
}

...with no @Override annotation. But that cannot compile in Java 7 without adding the AnnotatedType interface to the bootclasspath.

@gissuebot
Copy link
Author

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 :/

@gissuebot
Copy link
Author

gissuebot commented Nov 1, 2014

@gissuebot
Copy link
Author

Original comment posted by lchh555 on 2014-10-10 at 12:27 AM


Has this been fixed?
I still have this problem with Java8 for guava-18.0-SNAPSHOT.

@cgdecker
Copy link
Member

cgdecker commented Dec 2, 2014

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.

@eamonnmcmanus
Copy link
Member

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?

@cgdecker
Copy link
Member

cgdecker commented Dec 2, 2014

Yes, TypeVariableImpl is the issue.

@fluentfuture @lowasser Any thoughts? The main thing we probably can't do is add AnnotatedType to the bootclasspath for the compilation.

@lowasser
Copy link
Contributor

lowasser commented Dec 2, 2014

I don't know enough about dynamic proxies to have any sense of whether they would or wouldn't help here =/

@eamonnmcmanus
Copy link
Member

I am going to do a little experimentation.

@fluentfuture
Copy link

If all we want to do for the new getAnnotatedBounds() is to throw UnsupportedOperationException or to return null, then dynamic proxy can solve it easily. There is still some ugliness involved with it, because unlike AbstractWrapper, you cannot use an abstract class to get type safety, it would have to be full duck typing.

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.

@eamonnmcmanus
Copy link
Member

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. :-)

@fluentfuture
Copy link

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.

@cgdecker
Copy link
Member

cgdecker commented Dec 3, 2014

TypeVariableImpl is already crippled under JDK 8, right? Currently you'd get NoSuchMethodError or something when you call getAnnotatedBounds() on it. I also don't know that there's any way to provide any reasonable implementation of it (besides returning null or throwing UOE) while targeting a JDK <8. Given that, I don't expect whatever we do here to be any more than a band-aid to allow compilation on JDK 8. Whether being able to compile on JDK 8 is worth the effort, I don't know.

@fluentfuture
Copy link

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.

@cgdecker
Copy link
Member

cgdecker commented Dec 3, 2014

It's crippled under JDK 8 externally as well. The getAnnotatedBounds() method just doesn't exist if someone who's running under JDK 8 tries to call it. I'm just saying that adding an implementation that throws UOE doesn't make it any more crippled than it is now.

@fluentfuture
Copy link

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.

@cgdecker
Copy link
Member

cgdecker commented Dec 3, 2014

Yep, I'm referring to what happens at runtime on JDK 8, with Guava compiled under JDK 7.

@cgdecker cgdecker added this to the 19.0 milestone Dec 19, 2014
lptr added a commit to gradle/gradle that referenced this issue Aug 14, 2015
MartinRo pushed a commit to TeamExodus/external_guava that referenced this issue Oct 17, 2015
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
Cl3Kener pushed a commit to UBERMALLOW/external_guava that referenced this issue Oct 28, 2015
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>
B--B pushed a commit to AOSP-JF-MM/platform_external_guava that referenced this issue Nov 7, 2015
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
jgcaaprom pushed a commit to jgcaaprom/android_external_guava that referenced this issue Nov 19, 2015
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>
NL-BlackDragon pushed a commit to VRToxin-AOSP/android_external_guava that referenced this issue Dec 1, 2015
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>
r-matlock pushed a commit to TurboROM-Legacy/external_guava that referenced this issue Jan 27, 2016
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
jgcaaprom pushed a commit to jgcaaprom/android_external_guava that referenced this issue Jan 27, 2016
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>
USA-RedDragon pushed a commit to DesolationRebase/external_guava that referenced this issue Mar 10, 2016
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
cm-gerrit pushed a commit to CyanogenMod/android_external_guava that referenced this issue Apr 5, 2016
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
USA-RedDragon pushed a commit to DesolationRebase/external_guava that referenced this issue Apr 12, 2016
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
cannondalev2000 pushed a commit to cannondalev2000/external_guava that referenced this issue Apr 15, 2016
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
xyyx pushed a commit to nitrogen-project-mm/android_external_guava that referenced this issue May 4, 2016
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>
ghost pushed a commit to RaindropOS/platform_external_guava that referenced this issue May 6, 2016
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
fusionjack pushed a commit to SlimSaber/android_external_guava that referenced this issue May 9, 2016
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>
ghost pushed a commit to DysfunctionalROMs/external_guava that referenced this issue May 10, 2016
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
mydongistiny pushed a commit to BenzoRoms/external_guava that referenced this issue May 24, 2016
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
CandyShop pushed a commit to CandyRoms/external_guava that referenced this issue May 25, 2016
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>
r-matlock pushed a commit to TurboROM-Legacy/external_guava that referenced this issue Jun 6, 2016
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>
r-matlock pushed a commit to TurboROM-Legacy/external_guava that referenced this issue Jun 19, 2016
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>
ghost pushed a commit to Type-1a/platform_external_guava that referenced this issue Jun 23, 2016
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
srisurya95 pushed a commit to AOSP-RRO/platform_external_guava that referenced this issue Aug 17, 2016
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
MWisBest pushed a commit to MWisBest/android_external_guava that referenced this issue Aug 19, 2016
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
airend pushed a commit to airend/android_external_guava that referenced this issue Aug 20, 2016
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
Adarsh-MR pushed a commit to Citrus-CAF/external_guava that referenced this issue Sep 8, 2016
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
andi34 pushed a commit to android-security/android_external_guava that referenced this issue Sep 17, 2016
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
SlimAdmin pushed a commit to SlimRoms/android_external_guava that referenced this issue Jan 14, 2017
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants