Skip to content

Commit

Permalink
Merge branch '2.17'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Feb 16, 2024
2 parents be3c753 + 6111543 commit c1d35c6
Show file tree
Hide file tree
Showing 9 changed files with 223 additions and 138 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
groups:
github-actions:
patterns:
- "*"
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ jobs:
strategy:
fail-fast: false
matrix:
java_version: ['8', '11', '17']
java_version: ['8', '11', '17', '21']
os: ['ubuntu-20.04']
env:
JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
steps:
- uses: actions/checkout@v4.1.0
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
with:
distribution: 'temurin'
java-version: ${{ matrix.java_version }}
Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:
run: ./mvnw -B -q -ff -ntp test
- name: Publish code coverage
if: github.event_name != 'pull_request' && matrix.java_version == '8'
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@e0b68c6749509c5f83f984dd99a76a1c1a231044 # v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./target/site/jacoco/jacoco.xml
Expand Down
38 changes: 31 additions & 7 deletions jr-objects/src/main/java/tools/jackson/jr/ob/impl/JSONWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,24 @@ public void writeProperty(String propName, Object value, int type) throws Jackso
writeBigIntegerProperty(propName, (BigInteger) value);
return;
case SER_NUMBER_FLOAT: // fall through
case SER_NUMBER_FLOAT_WRAPPER:
writeFloatProperty(propName, ((Float) value).floatValue());
return;
case SER_NUMBER_DOUBLE:
writeDoubleProperty(propName, ((Number) value).doubleValue());
case SER_NUMBER_DOUBLE_WRAPPER:
writeDoubleProperty(propName, ((Double) value).doubleValue());
return;
case SER_NUMBER_BYTE: // fall through
case SER_NUMBER_SHORT: // fall through
case SER_NUMBER_INTEGER:
writeIntProperty(propName, ((Number) value).intValue());
return;
case SER_NUMBER_INTEGER:
case SER_NUMBER_INTEGER_WRAPPER:
writeIntProperty(propName, ((Integer) value).intValue());
return;
case SER_NUMBER_LONG:
writeLongProperty(propName, ((Number) value).longValue());
case SER_NUMBER_LONG_WRAPPER:
writeLongProperty(propName, ((Long) value).longValue());
return;

// Scalar types:
Expand Down Expand Up @@ -333,16 +341,24 @@ protected void _writeValue(Object value, int type) throws JacksonException
// Number types:

case SER_NUMBER_FLOAT: // fall through
case SER_NUMBER_FLOAT_WRAPPER: // fall through
writeFloatValue(((Float) value).floatValue());
return;
case SER_NUMBER_DOUBLE:
writeDoubleValue(((Number) value).doubleValue());
case SER_NUMBER_DOUBLE_WRAPPER:
writeDoubleValue(((Double) value).doubleValue());
return;
case SER_NUMBER_BYTE: // fall through
case SER_NUMBER_SHORT: // fall through
case SER_NUMBER_INTEGER:
writeIntValue(((Number) value).intValue());
return;
case SER_NUMBER_INTEGER:
case SER_NUMBER_INTEGER_WRAPPER:
writeIntValue(((Integer) value).intValue());
return;
case SER_NUMBER_LONG:
writeLongValue(((Number) value).longValue());
case SER_NUMBER_LONG_WRAPPER:
writeLongValue(((Long) value).longValue());
return;
case SER_NUMBER_BIG_DECIMAL:
writeBigDecimalValue((BigDecimal) value);
Expand Down Expand Up @@ -609,7 +625,15 @@ protected void writeBigIntegerProperty(String propName, BigInteger v) throws Jac
protected void writeLongProperty(String propName, long v) throws JacksonException {
_generator.writeNumberProperty(propName, v);
}


protected void writeFloatValue(float v) throws JacksonException {
_generator.writeNumber(v);
}

protected void writeFloatProperty(String fieldName, float v) throws JacksonException {
_generator.writeNumberProperty(fieldName, v);
}

protected void writeDoubleValue(double v) throws JacksonException {
_generator.writeNumber(v);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public Object readNext(JSONReader reader, JsonParser p) throws JacksonException
// cases default to "standard" handling which does range checks etc

case SER_NUMBER_INTEGER:
case SER_NUMBER_INTEGER_WRAPPER:
{
int i = p.nextIntValue(-2);
if (i != -2) {
Expand All @@ -68,6 +69,7 @@ public Object readNext(JSONReader reader, JsonParser p) throws JacksonException
}

case SER_NUMBER_LONG:
case SER_NUMBER_LONG_WRAPPER:
{
long l = p.nextLongValue(-2L);
if (l != -2L) {
Expand Down Expand Up @@ -115,8 +117,16 @@ public Object read(JSONReader reader, JsonParser p) throws JacksonException

// Number types:

case SER_NUMBER_FLOAT: // fall through
case SER_NUMBER_FLOAT_WRAPPER:
if (p.hasToken(JsonToken.VALUE_NULL)) {
return null;
}
case SER_NUMBER_FLOAT:
return Float.valueOf((float) p.getValueAsDouble());
case SER_NUMBER_DOUBLE_WRAPPER:
if (p.hasToken(JsonToken.VALUE_NULL)) {
return null;
}
case SER_NUMBER_DOUBLE:
return p.getValueAsDouble();

Expand All @@ -125,8 +135,16 @@ public Object read(JSONReader reader, JsonParser p) throws JacksonException

case SER_NUMBER_SHORT: // fall through
return (short) p.getValueAsInt();
case SER_NUMBER_INTEGER_WRAPPER:
if (p.hasToken(JsonToken.VALUE_NULL)) {
return null;
}
case SER_NUMBER_INTEGER:
return p.getValueAsInt();
case SER_NUMBER_LONG_WRAPPER:
if (p.hasToken(JsonToken.VALUE_NULL)) {
return null;
}
case SER_NUMBER_LONG:
return p.getValueAsLong();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,41 +85,45 @@ public abstract class ValueLocatorBase
public final static int SER_NUMBER_SHORT = 15;

public final static int SER_NUMBER_INTEGER = 16;
public final static int SER_NUMBER_INTEGER_WRAPPER = 17;

public final static int SER_NUMBER_LONG = 17;
public final static int SER_NUMBER_LONG = 18;
public final static int SER_NUMBER_LONG_WRAPPER = 19;

public final static int SER_NUMBER_FLOAT = 18;
public final static int SER_NUMBER_FLOAT = 20;
public final static int SER_NUMBER_FLOAT_WRAPPER = 21;

public final static int SER_NUMBER_DOUBLE = 19;
public final static int SER_NUMBER_DOUBLE = 22;
public final static int SER_NUMBER_DOUBLE_WRAPPER = 23;

public final static int SER_NUMBER_BIG_INTEGER = 20;
public final static int SER_NUMBER_BIG_INTEGER = 24;

public final static int SER_NUMBER_BIG_DECIMAL = 21;
public final static int SER_NUMBER_BIG_DECIMAL = 25;

// // // Other specific scalar types

public final static int SER_BOOLEAN = 22;
public final static int SER_BOOLEAN_WRAPPER = 23;
public final static int SER_CHAR = 24;
public final static int SER_BOOLEAN = 26;
public final static int SER_BOOLEAN_WRAPPER = 27;
public final static int SER_CHAR = 28;

public final static int SER_ENUM = 25;
public final static int SER_ENUM = 29;

public final static int SER_DATE = 26;
public final static int SER_CALENDAR = 27;
public final static int SER_DATE = 30;
public final static int SER_CALENDAR = 31;

public final static int SER_CLASS = 28;
public final static int SER_FILE = 29;
public final static int SER_UUID = 30;
public final static int SER_URL = 31;
public final static int SER_URI = 32;
public final static int SER_CLASS = 32;
public final static int SER_FILE = 33;
public final static int SER_UUID = 34;
public final static int SER_URL = 35;
public final static int SER_URI = 36;

// // // Iterate-able types

/**
* Anything that implements {@link java.lang.Iterable}, but not
* {@link java.util.Collection}.
*/
public final static int SER_ITERABLE = 33;
public final static int SER_ITERABLE = 37;

/*
/**********************************************************************
Expand Down Expand Up @@ -178,16 +182,16 @@ protected int _findSimpleType(Class<?> raw, boolean forSer)
return SER_BOOLEAN_WRAPPER;
}
if (Number.class.isAssignableFrom(raw)) {
if (raw == Integer.class) return SER_NUMBER_INTEGER;
if (raw == Long.class) return SER_NUMBER_LONG;
if (raw == Byte.class) return SER_NUMBER_BYTE;
if (raw == Short.class) return SER_NUMBER_SHORT;
if (raw == Double.class) return SER_NUMBER_DOUBLE;
if (raw == Float.class) return SER_NUMBER_FLOAT;
if (raw == Integer.class) return SER_NUMBER_INTEGER_WRAPPER;
if (raw == Long.class) return SER_NUMBER_LONG_WRAPPER;
if (raw == Double.class) return SER_NUMBER_DOUBLE_WRAPPER;
if (raw == Float.class) return SER_NUMBER_FLOAT_WRAPPER;
if (raw == BigDecimal.class) return SER_NUMBER_BIG_DECIMAL;
if (raw == BigInteger.class) {
return SER_NUMBER_BIG_INTEGER;
}
if (raw == Byte.class) return SER_NUMBER_BYTE;
if (raw == Short.class) return SER_NUMBER_SHORT;
// What numeric type is this? Could consider "string-like" but...
return SER_UNKNOWN;
}
Expand Down

This file was deleted.

Loading

0 comments on commit c1d35c6

Please sign in to comment.