This repository has been archived by the owner on Oct 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 101
Get vanilla tests passing in Java 9 #210
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Sat May 07 11:46:53 BST 2016 | ||
#Mon Nov 14 21:56:03 GMT 2016 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-3.2-bin.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/main/java/org/inferred/freebuilder/processor/util/feature/JavaxPackage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package org.inferred.freebuilder.processor.util.feature; | ||
|
||
import com.google.common.base.Optional; | ||
|
||
import org.inferred.freebuilder.processor.util.QualifiedName; | ||
import org.inferred.freebuilder.processor.util.SourceBuilder; | ||
|
||
import javax.annotation.processing.ProcessingEnvironment; | ||
import javax.lang.model.util.Elements; | ||
|
||
/** | ||
* Types in the javax package, if available. Defaults to {@link #AVAILABLE} in tests. | ||
*/ | ||
public enum JavaxPackage implements Feature<JavaxPackage> { | ||
|
||
AVAILABLE("javax"), UNAVAILABLE("No javax"); | ||
|
||
/** | ||
* Constant to pass to {@link SourceBuilder#feature(FeatureType)} to get the current status of | ||
* {@link JavaxPackage}. | ||
*/ | ||
public static final FeatureType<JavaxPackage> JAVAX = | ||
new FeatureType<JavaxPackage>() { | ||
|
||
@Override | ||
protected JavaxPackage testDefault() { | ||
return AVAILABLE; | ||
} | ||
|
||
@Override | ||
protected JavaxPackage forEnvironment(ProcessingEnvironment env) { | ||
return hasType(env.getElementUtils(), GENERATED) ? AVAILABLE : UNAVAILABLE; | ||
} | ||
}; | ||
|
||
private static final QualifiedName GENERATED = QualifiedName.of("javax.annotation", "Generated"); | ||
|
||
private final String humanReadableFormat; | ||
|
||
JavaxPackage(String humanReadableFormat) { | ||
this.humanReadableFormat = humanReadableFormat; | ||
} | ||
|
||
/** | ||
* Parameterized type for {@code java.util.function.Consumer<T>}, if available. | ||
*/ | ||
public Optional<QualifiedName> generated() { | ||
return ifAvailable(GENERATED); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return humanReadableFormat; | ||
} | ||
|
||
private static boolean hasType(Elements elements, QualifiedName type) { | ||
return elements.getTypeElement(type.toString()) != null; | ||
} | ||
|
||
private <T> Optional<T> ifAvailable(T value) { | ||
return (this == AVAILABLE) ? Optional.of(value) : Optional.<T>absent(); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should probably have a test that the Generated annotation doesn't show up in JDK9. Or, is that way more work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Impossible, really—we don't run unit tests in JDK 9.