Skip to content

Commit

Permalink
Further work on #1385: try moving test classes to different package (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder authored Jan 13, 2025
1 parent cde1db5 commit 7a9cad8
Show file tree
Hide file tree
Showing 226 changed files with 1,130 additions and 535 deletions.
16 changes: 16 additions & 0 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// FastDoubleParser shaded but JPMS still requires it to compile?
requires static ch.randelshofer.fastdoubleparser;

// Exports for regular dependencies
exports tools.jackson.core;
exports tools.jackson.core.async;
exports tools.jackson.core.base;
Expand All @@ -16,6 +17,21 @@
exports tools.jackson.core.type;
exports tools.jackson.core.util;

// But opens only for unit test suite; as well as some extra exports
opens tools.jackson.core to tools.jackson.core.test;
opens tools.jackson.core.async to tools.jackson.core.test;
opens tools.jackson.core.base to tools.jackson.core.test;
opens tools.jackson.core.exc to tools.jackson.core.test;
opens tools.jackson.core.filter to tools.jackson.core.test;
opens tools.jackson.core.io to tools.jackson.core.test;
exports tools.jackson.core.io.schubfach to tools.jackson.core.test;
opens tools.jackson.core.json to tools.jackson.core.test;
opens tools.jackson.core.json.async to tools.jackson.core.test;
opens tools.jackson.core.sym to tools.jackson.core.test;
opens tools.jackson.core.tree to tools.jackson.core.test;
opens tools.jackson.core.type to tools.jackson.core.test;
opens tools.jackson.core.util to tools.jackson.core.test;

provides tools.jackson.core.TokenStreamFactory with
tools.jackson.core.json.JsonFactory;
}
14 changes: 7 additions & 7 deletions src/main/java/tools/jackson/core/io/JsonStringEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Reason is that conversion method results are expected to be cached so that
* these methods will not be hot spots during normal operation.
*/
public final class JsonStringEncoder
public class JsonStringEncoder
{
/*
/**********************************************************************
Expand All @@ -34,10 +34,10 @@ public final class JsonStringEncoder
// to estimate ok initial encoding buffer, switch to segmented for
// possible (but rare) big content

final static int MIN_CHAR_BUFFER_SIZE = 16;
final static int MAX_CHAR_BUFFER_SIZE = 32000; // use segments beyond
final static int MIN_BYTE_BUFFER_SIZE = 24;
final static int MAX_BYTE_BUFFER_SIZE = 32000; // use segments beyond
public final static int MIN_CHAR_BUFFER_SIZE = 16;
public final static int MAX_CHAR_BUFFER_SIZE = 32000; // use segments beyond
public final static int MIN_BYTE_BUFFER_SIZE = 24;
public final static int MAX_BYTE_BUFFER_SIZE = 32000; // use segments beyond

/*
/**********************************************************************
Expand Down Expand Up @@ -452,7 +452,7 @@ private static void _illegal(int c) {
}

// non-private for unit test access
static int _initialCharBufSize(int strLen) {
public static int _initialCharBufSize(int strLen) {
// char->char won't expand but we need to give some room for escaping
// like 1/8 (12.5% expansion) but cap addition to something modest
final int estimated = Math.max(MIN_CHAR_BUFFER_SIZE,
Expand All @@ -461,7 +461,7 @@ static int _initialCharBufSize(int strLen) {
}

// non-private for unit test access
static int _initialByteBufSize(int strLen) {
public static int _initialByteBufSize(int strLen) {
// char->byte for UTF-8 can expand size by x3 itself, and escaping
// more... but let's use lower factor of 1.5
final int doubled = Math.max(MIN_BYTE_BUFFER_SIZE, strLen + 6 + (strLen>>1));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tools/jackson/core/io/NumberOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public static int outputLong(long v, byte[] b, int off)
*
* @since 2.17
*/
static int divBy1000(int number) {
public static int divBy1000(int number) {
return (int) (number * 274_877_907L >>> 38);
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/tools/jackson/core/io/UTF8Writer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

public final class UTF8Writer extends Writer
{
final static int SURR1_FIRST = 0xD800;
final static int SURR1_LAST = 0xDBFF;
final static int SURR2_FIRST = 0xDC00;
final static int SURR2_LAST = 0xDFFF;
public final static int SURR1_FIRST = 0xD800;
public final static int SURR1_LAST = 0xDBFF;
public final static int SURR2_FIRST = 0xDC00;
public final static int SURR2_LAST = 0xDFFF;

/**
* @since 2.17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,32 +57,32 @@ final public class DoubleToDecimal {
// Sources with the license are here: https://github.com/c4f7fcce9cb06515/Schubfach/blob/3c92d3c9b1fead540616c918cdfef432bca53dfa/todec/src/math/FloatToDecimal.java

// The precision in bits.
static final int P = 53;
public static final int P = 53;

// Exponent width in bits.
private static final int W = (Double.SIZE - 1) - (P - 1);

// Minimum value of the exponent: -(2^(W-1)) - P + 3.
static final int Q_MIN = (-1 << W - 1) - P + 3;
public static final int Q_MIN = (-1 << W - 1) - P + 3;

// Maximum value of the exponent: 2^(W-1) - P.
static final int Q_MAX = (1 << W - 1) - P;
public static final int Q_MAX = (1 << W - 1) - P;

// 10^(E_MIN - 1) <= MIN_VALUE < 10^E_MIN
static final int E_MIN = -323;
public static final int E_MIN = -323;

// 10^(E_MAX - 1) <= MAX_VALUE < 10^E_MAX
static final int E_MAX = 309;
public static final int E_MAX = 309;

// Threshold to detect tiny values, as in section 8.1.1 of [1]
static final long C_TINY = 3;
public static final long C_TINY = 3;

// The minimum and maximum k, as in section 8 of [1]
static final int K_MIN = -324;
static final int K_MAX = 292;
public static final int K_MIN = -324;
public static final int K_MAX = 292;

// H is as in section 8 of [1].
static final int H = 17;
public static final int H = 17;

// Minimum value of the significand of a normal value: 2^(P-1).
private static final long C_MIN = 1L << P - 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,32 +56,32 @@ final public class FloatToDecimal {
// Sources with the license are here: https://github.com/c4f7fcce9cb06515/Schubfach/blob/3c92d3c9b1fead540616c918cdfef432bca53dfa/todec/src/math/FloatToDecimal.java

// The precision in bits.
static final int P = 24;
public static final int P = 24;

// Exponent width in bits.
private static final int W = (Float.SIZE - 1) - (P - 1);

// Minimum value of the exponent: -(2^(W-1)) - P + 3.
static final int Q_MIN = (-1 << W - 1) - P + 3;
public static final int Q_MIN = (-1 << W - 1) - P + 3;

// Maximum value of the exponent: 2^(W-1) - P.
static final int Q_MAX = (1 << W - 1) - P;
public static final int Q_MAX = (1 << W - 1) - P;

// 10^(E_MIN - 1) <= MIN_VALUE < 10^E_MIN
static final int E_MIN = -44;
public static final int E_MIN = -44;

// 10^(E_MAX - 1) <= MAX_VALUE < 10^E_MAX
static final int E_MAX = 39;
public static final int E_MAX = 39;

// Threshold to detect tiny values, as in section 8.1.1 of [1]
static final int C_TINY = 8;
public static final int C_TINY = 8;

// The minimum and maximum k, as in section 8 of [1]
static final int K_MIN = -45;
static final int K_MAX = 31;
public static final int K_MIN = -45;
public static final int K_MAX = 31;

// H is as in section 8 of [1].
static final int H = 9;
public static final int H = 9;

// Minimum value of the significand of a normal value: 2^(P-1).
private static final int C_MIN = 1 << P - 1;
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/tools/jackson/core/io/schubfach/MathUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*
* @author Raffaello Giulietti
*/
final class MathUtils {
public final class MathUtils { // public only for testing (but not exposed by Module)
/*
For full details about this code see the following reference:
Expand All @@ -44,11 +44,11 @@ The boundaries for k in g0(int) and g1(int).
K_MIN must be DoubleToDecimal.K_MIN or less.
K_MAX must be DoubleToDecimal.K_MAX or more.
*/
static final int K_MIN = -324;
static final int K_MAX = 292;
public static final int K_MIN = -324;
public static final int K_MAX = 292;

// Must be DoubleToDecimal.H or more
static final int H = 17;
public static final int H = 17;

// C_10 = floor(log10(2) * 2^Q_10), A_10 = floor(log10(3/4) * 2^Q_10)
private static final int Q_10 = 41;
Expand Down Expand Up @@ -91,7 +91,7 @@ private MathUtils() {
* 0 &le; {@code e} &le; {@link #H}.
* @return 10<sup>{@code e}</sup>.
*/
static long pow10(int e) {
public static long pow10(int e) {
return pow10[e];
}

Expand All @@ -107,7 +107,7 @@ static long pow10(int e) {
* |{@code e}| &le; 5_456_721 for safe results.
* @return &lfloor;log<sub>10</sub>2<sup>{@code e}</sup>&rfloor;.
*/
static int flog10pow2(int e) {
public static int flog10pow2(int e) {
return (int) (e * C_10 >> Q_10);
}

Expand All @@ -125,7 +125,7 @@ static int flog10pow2(int e) {
* @return &lfloor;log<sub>10</sub>(3/4 &middot;
* 2<sup>{@code e}</sup>)&rfloor;.
*/
static int flog10threeQuartersPow2(int e) {
public static int flog10threeQuartersPow2(int e) {
return (int) (e * C_10 + A_10 >> Q_10);
}

Expand All @@ -141,7 +141,7 @@ static int flog10threeQuartersPow2(int e) {
* |{@code e}| &le; 1_838_394 for safe results.
* @return &lfloor;log<sub>2</sub>10<sup>{@code e}</sup>&rfloor;.
*/
static int flog2pow10(int e) {
public static int flog2pow10(int e) {
return (int) (e * C_2 >> Q_2);
}

Expand All @@ -168,7 +168,7 @@ static int flog2pow10(int e) {
* {@link #K_MIN} &le; {@code e} &le; {@link #K_MAX}.
* @return <i>g</i><sub>1</sub> as described above.
*/
static long g1(int k) {
public static long g1(int k) {
return g[k - K_MIN << 1];
}

Expand All @@ -181,7 +181,7 @@ static long g1(int k) {
* @return <i>g</i><sub>0</sub> as described in
* {@link #g1(int)}.
*/
static long g0(int k) {
public static long g0(int k) {
return g[k - K_MIN << 1 | 1];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ public NonBlockingJsonParserBase(ObjectReadContext readCtxt, IOContext ctxt,
/**********************************************************
*/

protected ByteQuadsCanonicalizer symbolTableForTests() {
// Alas, needs to be public for testing
public ByteQuadsCanonicalizer symbolTableForTests() {
return _symbols;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
* UTF-8 encoded bytes of name (null-padded), and last int is offset in
* {@code _names} that contains actual name Strings.
*/
public final class ByteQuadsCanonicalizer
public class ByteQuadsCanonicalizer
{
/**
* Initial size of the primary hash area. Each entry consumes 4 ints (16 bytes),
* and secondary area is same as primary; so default size will use 2kB of memory
* (plus 64x4 or 64x8 (256/512 bytes) for references to Strings, and Strings
* themselves).
*/
private static final int DEFAULT_T_SIZE = 64;
protected static final int DEFAULT_T_SIZE = 64;
// private static final int DEFAULT_T_SIZE = 256;

/**
Expand Down Expand Up @@ -219,7 +219,7 @@ public final class ByteQuadsCanonicalizer
* @param seed Random seed valued used to make it more difficult to cause
* collisions (used for collision-based DoS attacks).
*/
private ByteQuadsCanonicalizer(int sz, int seed)
protected ByteQuadsCanonicalizer(int sz, int seed)
{
// Settings to distinguish parent table: no parent
_parent = null;
Expand Down Expand Up @@ -1090,7 +1090,7 @@ private int _resizeAndFindOffsetForAdd(int hash) throws StreamConstraintsExcepti
}

// @since 2.17
static int multiplyByFourFifths(int number) {
public static int multiplyByFourFifths(int number) {
return (int) (number * 3_435_973_837L >>> 32);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public final class CharsToNameCanonicalizer
* this corresponds to 64k main hash index. This should allow for enough distinct
* names for almost any case.
*/
static final int MAX_ENTRIES_FOR_REUSE = 12000;
public static final int MAX_ENTRIES_FOR_REUSE = 12000;

/**
* Also: to thwart attacks based on hash collisions (which may or may not
Expand Down Expand Up @@ -740,7 +740,7 @@ protected void _reportTooManyCollisions(int maxLen) {

// Diagnostics method that will verify that internal data structures are consistent;
// not meant as user-facing method but only for test suites and possible troubleshooting.
protected void verifyInternalConsistency() {
public void verifyInternalConsistency() { // public for unit tests
int count = 0;
final int size = _symbols.length;

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/tools/jackson/core/util/TextBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ public class TextBuffer
*<p>
* Reduced from 1000 down to 500 in 2.10.
*/
protected final static int MIN_SEGMENT_LEN = 500;
public final static int MIN_SEGMENT_LEN = 500;

// Non-private to access from a test
/*
* Let's limit maximum segment length to something sensible.
* For 2.10, let's limit to using 64kc chunks (128 kB) -- was 256kC/512kB up to 2.9
*/
protected final static int MAX_SEGMENT_LEN = 0x10000;
public final static int MAX_SEGMENT_LEN = 0x10000;

/*
/**********************************************************************
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tools/jackson/core/util/VersionUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static Version parseVersion(String s, String groupId, String artifactId)
return Version.unknownVersion();
}

protected static int parseVersionPart(String s) {
public static int parseVersionPart(String s) {
int number = 0;
for (int i = 0, len = s.length(); i < len; ++i) {
char c = s.charAt(i);
Expand Down
Loading

0 comments on commit 7a9cad8

Please sign in to comment.