[jOOQ/jOOQ#8900] Make jOOQ compatible with Java 6
- Mostly surround pieces of code with [java-8] preprocessor tags - Added ExceptionTools#sneakyThrow() which is used in MiniJAXB
This commit is contained in:
parent
0309bffc11
commit
f8a6dfacf1
@ -105,7 +105,7 @@ public class DDLDatabase extends H2Database {
|
||||
String encoding = getProperties().getProperty("encoding", "UTF-8");
|
||||
String sort = getProperties().getProperty("sort", "semantic").toLowerCase();
|
||||
String unqualifiedSchema = getProperties().getProperty("unqualifiedSchema", "none").toLowerCase();
|
||||
String defaultNameCase = getProperties().getProperty("defaultNameCase", "as_is").toUpperCase();
|
||||
final String defaultNameCase = getProperties().getProperty("defaultNameCase", "as_is").toUpperCase();
|
||||
boolean parseIgnoreComments = !"false".equalsIgnoreCase(getProperties().getProperty("parseIgnoreComments"));
|
||||
String parseIgnoreCommentStart = getProperties().getProperty("parseIgnoreCommentStart", defaultSettings.getParseIgnoreCommentStart());
|
||||
String parseIgnoreCommentStop = getProperties().getProperty("parseIgnoreCommentStop", defaultSettings.getParseIgnoreCommentStop());
|
||||
|
||||
@ -143,6 +143,7 @@ public abstract class AbstractTypedElementDefinition<T extends Definition>
|
||||
|
||||
public static final DataType<?> getDataType(Database db, String t, int p, int s) {
|
||||
|
||||
|
||||
// [#8493] Synthetic SQLDataType aliases used by the code generator only
|
||||
if ("OFFSETDATETIME".equalsIgnoreCase(t))
|
||||
return SQLDataType.OFFSETDATETIME.precision(p);
|
||||
@ -154,7 +155,9 @@ public abstract class AbstractTypedElementDefinition<T extends Definition>
|
||||
return SQLDataType.LOCALDATETIME.precision(p);
|
||||
else if ("LOCALTIME".equalsIgnoreCase(t))
|
||||
return SQLDataType.LOCALTIME.precision(p);
|
||||
else if (db.getForceIntegerTypesOnZeroScaleDecimals())
|
||||
else
|
||||
|
||||
if (db.getForceIntegerTypesOnZeroScaleDecimals())
|
||||
return DefaultDataType.getDataType(db.getDialect(), t, p, s);
|
||||
|
||||
DataType<?> result = DefaultDataType.getDataType(db.getDialect(), t);
|
||||
|
||||
@ -309,6 +309,7 @@ public class Routines extends TableImpl<Record> {
|
||||
*/
|
||||
public final TableField<Record, String> AS_LOCATOR = createField("as_locator", org.jooq.impl.SQLDataType.VARCHAR(3), this, "");
|
||||
|
||||
|
||||
/**
|
||||
* The column <code>information_schema.routines.created</code>.
|
||||
*/
|
||||
@ -319,6 +320,7 @@ public class Routines extends TableImpl<Record> {
|
||||
*/
|
||||
public final TableField<Record, OffsetDateTime> LAST_ALTERED = createField("last_altered", org.jooq.impl.SQLDataType.TIMESTAMPWITHTIMEZONE, this, "");
|
||||
|
||||
|
||||
/**
|
||||
* The column <code>information_schema.routines.new_savepoint_level</code>.
|
||||
*/
|
||||
|
||||
@ -230,7 +230,8 @@ public class XMLDatabase extends AbstractDatabase {
|
||||
info = MiniJAXB.append(info, MiniJAXB.unmarshal(content, InformationSchema.class));
|
||||
}
|
||||
else
|
||||
throw t;
|
||||
// required due to Java 6
|
||||
ExceptionTools.sneakyThrow(t);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -113,7 +113,10 @@ public class MiniJAXB {
|
||||
return;
|
||||
}
|
||||
catch (Throwable t) {
|
||||
if (ExceptionTools.getCause(t, ClassNotFoundException.class) != null ||
|
||||
if (t instanceof Error) {
|
||||
ExceptionTools.sneakyThrow(t);
|
||||
}
|
||||
else if (ExceptionTools.getCause(t, ClassNotFoundException.class) != null ||
|
||||
ExceptionTools.getCause(t, Error.class) != null) {
|
||||
jaxbAvailable = false;
|
||||
log.debug("JAXB is not available from the classpath / module path");
|
||||
@ -121,7 +124,7 @@ public class MiniJAXB {
|
||||
else {
|
||||
jaxbAvailable = true;
|
||||
log.debug("JAXB is available from the classpath / module path");
|
||||
throw t;
|
||||
throw new ConfigurationException("Error while reading xml", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -171,6 +174,9 @@ public class MiniJAXB {
|
||||
return result;
|
||||
}
|
||||
catch (Throwable t) {
|
||||
if (t instanceof Error) {
|
||||
ExceptionTools.sneakyThrow(t);
|
||||
}
|
||||
if (ExceptionTools.getCause(t, ClassNotFoundException.class) != null ||
|
||||
ExceptionTools.getCause(t, Error.class) != null) {
|
||||
jaxbAvailable = false;
|
||||
|
||||
@ -74,5 +74,20 @@ public final class ExceptionTools {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sneaky throw any type of Throwable.
|
||||
*/
|
||||
public static void sneakyThrow(Throwable throwable) {
|
||||
ExceptionTools.<RuntimeException> sneakyThrow0(throwable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sneaky throw any type of Throwable.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <E extends Throwable> void sneakyThrow0(Throwable throwable) throws E {
|
||||
throw (E) throwable;
|
||||
}
|
||||
|
||||
private ExceptionTools() {}
|
||||
}
|
||||
|
||||
@ -94,9 +94,11 @@ abstract class AbstractResourceManagingScope extends AbstractScope implements Re
|
||||
return closeable;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final <R extends AutoCloseable> R autoClose(R closeable) {
|
||||
DefaultExecuteContext.register(closeable);
|
||||
return closeable;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -169,7 +169,9 @@ public class DefaultConfiguration implements Configuration {
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
|
||||
null,
|
||||
|
||||
dialect,
|
||||
SettingsTools.defaultSettings(),
|
||||
null
|
||||
|
||||
@ -258,8 +258,8 @@ class Function<T> extends AbstractField<T> implements
|
||||
}
|
||||
else if (term == PRODUCT) {
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
Field<Integer> f = (Field) DSL.field("{0}", arguments.get(0));
|
||||
Field<Integer> negatives = DSL.when(f.lt(zero()), inline(-1));
|
||||
final Field<Integer> f = (Field) DSL.field("{0}", arguments.get(0));
|
||||
final Field<Integer> negatives = DSL.when(f.lt(zero()), inline(-1));
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
Field<BigDecimal> negativesSum = new CustomField<BigDecimal>("sum", NUMERIC) {
|
||||
|
||||
@ -125,13 +125,11 @@ public final class YearToSecond extends Number implements Interval, Comparable<Y
|
||||
return duration == null ? null : valueOf(duration.toMillis());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final Duration toDuration() {
|
||||
return yearToMonth.toDuration().plus(dayToSecond.toDuration());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Transform a {@link Period} into a {@link YearToSecond} interval.
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user