Skip to content

Commit

Permalink
Merge pull request #2128 from Proximyst/issue-2127
Browse files Browse the repository at this point in the history
fix(generator): return latest supported SourceVersion instead of 8
  • Loading branch information
hgschmie committed Oct 5, 2022
2 parents a6d0e74 + b329053 commit c048190
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Unreleased

- `jdbi3-generator` will now support any Java 8+ version without generating compile-time warnings (#2128)
- AbstractArgumentFactory also need to check for supertypes when the generic argument is not a class (fixes #2026)

# 3.33.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
Expand All @@ -53,11 +52,22 @@
import org.jdbi.v3.sqlobject.internal.SqlObjectInitData.InContextInvoker;

@SupportedAnnotationTypes("org.jdbi.v3.sqlobject.GenerateSqlObject")
@SupportedSourceVersion(SourceVersion.RELEASE_8)
public class GenerateSqlObjectProcessor extends AbstractProcessor {
private static final Set<ElementKind> ACCEPTABLE = EnumSet.of(ElementKind.CLASS, ElementKind.INTERFACE);
private long counter = 0;

@Override
public SourceVersion getSupportedSourceVersion() {
// We should be able to output generated code for any supported releases >= 8.
// Considering the bytecode we output for the artifact (i.e. the processor, not the
// generated code) is always Java 8 or newer as of writing, this will not be an issue.
//
// We return the latest supported version for javac instead of the lowest version we expect
// to support, because javac will print warnings in that case. This breaks -Werror builds
// on versions higher than this is made to support (i.e. Java 9+ as of writing).
return SourceVersion.latestSupported();
}

@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if (annotations.isEmpty()) {
Expand Down

0 comments on commit c048190

Please sign in to comment.