Skip to content

Commit

Permalink
Fix #557: add direct use of module-info.java
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 15, 2025
1 parent c7f91fb commit 127167e
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 38 deletions.
7 changes: 0 additions & 7 deletions avro/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,6 @@ abstractions.
</execution>
</executions>
</plugin>
<!-- 19-Mar-2019, tatu: Add rudimentary JDK9+ module info. To build with JDK 8
will have to use `moduleInfoFile` as anything else requires JDK 9+
-->
<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
module tools.jackson.dataformat.avro {
// Avro Main artifact Module descriptor
module tools.jackson.dataformat.avro
{
requires transitive com.fasterxml.jackson.annotation;
requires tools.jackson.core;
requires tools.jackson.databind;

// silly avro Apache impl, its deps:
requires static avro;
requires static jackson.core.asl;
requires static jackson.mapper.asl;
requires org.apache.avro;

exports tools.jackson.dataformat.avro;
exports tools.jackson.dataformat.avro.annotation;
Expand Down
35 changes: 35 additions & 0 deletions avro/src/test/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Avro unit test Module descriptor
module tools.jackson.dataformat.avro
{
// Since we are not split from Main artifact, will not
// need to depend on Main artifact -- but need its dependencies

requires tools.jackson.core;
requires tools.jackson.databind;

requires org.apache.avro;

// Additional test lib/framework dependencies
requires org.assertj.core;
requires org.junit.jupiter.api;
requires org.junit.jupiter.params;

// Further, need to open up some packages for JUnit et al

opens tools.jackson.dataformat.avro;
opens tools.jackson.dataformat.avro.annotation;
opens tools.jackson.dataformat.avro.dos;
opens tools.jackson.dataformat.avro.fuzz;
opens tools.jackson.dataformat.avro.gen;
opens tools.jackson.dataformat.avro.interop;
opens tools.jackson.dataformat.avro.interop.annotations;
opens tools.jackson.dataformat.avro.interop.arrays;
opens tools.jackson.dataformat.avro.interop.maps;
opens tools.jackson.dataformat.avro.interop.records;
opens tools.jackson.dataformat.avro.jsr310;
opens tools.jackson.dataformat.avro.schema;
opens tools.jackson.dataformat.avro.schemaev;
opens tools.jackson.dataformat.avro.testsupport;
opens tools.jackson.dataformat.avro.testutil.failure;
opens tools.jackson.dataformat.avro.tofix;
}
7 changes: 0 additions & 7 deletions cbor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@ encoded data using Jackson abstractions (streaming API, data binding, tree model
</execution>
</executions>
</plugin>
<!-- 19-Mar-2019, tatu: Add rudimentary JDK9+ module info. To build with JDK 8
will have to use `moduleInfoFile` as anything else requires JDK 9+
-->
<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module tools.jackson.dataformat.cbor {
// CBOR Main artifact Module descriptor
module tools.jackson.dataformat.cbor
{
requires tools.jackson.core;
requires tools.jackson.databind;

Expand Down
27 changes: 27 additions & 0 deletions cbor/src/test/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// CBOR unit test Module descriptor
module tools.jackson.dataformat.cbor
{
// Since we are not split from Main artifact, will not
// need to depend on Main artifact -- but need its dependencies

requires tools.jackson.core;
requires tools.jackson.databind;

// Additional test lib/framework dependencies
requires org.junit.jupiter.api;
requires org.junit.jupiter.params;

// Further, need to open up some packages for JUnit et al
opens tools.jackson.dataformat.cbor;
opens tools.jackson.dataformat.cbor.constraints;
opens tools.jackson.dataformat.cbor.dos;
opens tools.jackson.dataformat.cbor.filter;
opens tools.jackson.dataformat.cbor.fuzz;
opens tools.jackson.dataformat.cbor.gen;
opens tools.jackson.dataformat.cbor.gen.dos;
opens tools.jackson.dataformat.cbor.mapper;
opens tools.jackson.dataformat.cbor.parse;
opens tools.jackson.dataformat.cbor.seq;
opens tools.jackson.dataformat.cbor.testutil;
opens tools.jackson.dataformat.cbor.testutil.failure;
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,27 @@ public void testSimpleDefault() throws Exception
assertTrue(syms.isCanonicalizing()); // added in 2.13

assertEquals(0, syms.size());
assertEquals(0, _findParent(syms).size());
//assertEquals(0, _findParent(syms).size());

assertToken(JsonToken.START_OBJECT, p.nextToken());
assertToken(JsonToken.PROPERTY_NAME, p.nextToken());
assertEquals("a", p.currentName());
assertEquals(1, syms.size());
// not yet synced to parent
assertEquals(0, _findParent(syms).size());
//assertEquals(0, _findParent(syms).size());

while (p.nextToken() != null) { ; }
assertEquals(2, syms.size());
// but after closing, should sync
assertEquals(2, _findParent(syms).size());
//assertEquals(2, _findParent(syms).size());
}

// by default, should canonicalize etc:
try (JsonParser p = vanillaMapper.createParser(doc)) {
ByteQuadsCanonicalizer syms = _findSymbols(p);
assertEquals(2, syms.size());
// also check that parent (root) has it all?
assertEquals(2, _findParent(syms).size());
//assertEquals(2, _findParent(syms).size());

// but no additions second time around
while (p.nextToken() != null) { ; }
Expand Down Expand Up @@ -118,7 +118,7 @@ public void testSimpleNoCanonicalize() throws Exception
assertFalse(syms.isCanonicalizing()); // added in 2.13
assertEquals(-1, syms.size());
// also, should not have parent:
assertNull(_findParent(syms));
//assertNull(_findParent(syms));

assertToken(JsonToken.START_OBJECT, p.nextToken());
assertToken(JsonToken.PROPERTY_NAME, p.nextToken());
Expand Down Expand Up @@ -227,10 +227,13 @@ private ByteQuadsCanonicalizer _findSymbols(JsonParser p) throws Exception
return (ByteQuadsCanonicalizer) f.get(p);
}

// Cannot access under JPMS, alas
/*
private ByteQuadsCanonicalizer _findParent(ByteQuadsCanonicalizer sym) throws Exception
{
Field f = ByteQuadsCanonicalizer.class.getDeclaredField("_parent");
f.setAccessible(true);
return (ByteQuadsCanonicalizer) f.get(sym);
}
*/
}
1 change: 1 addition & 0 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ implementations)
`SmileGenerator.Feature` as `SmileWriteFeature`
#543: (avro) Enable "logical types" support in `AvroSchemaGenerator`
by default (3.0)
#557: Change 3.0 to use `module-info.java` directly [JSTEP-11]
- Minimum Java baseline: Java 17
7 changes: 0 additions & 7 deletions smile/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,6 @@ tree model)
</execution>
</executions>
</plugin>
<!-- 19-Mar-2019, tatu: Add rudimentary JDK9+ module info. To build with JDK 8
will have to use `moduleInfoFile` as anything else requires JDK 9+
-->
<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module tools.jackson.dataformat.smile {
// Smile Main artifact Module descriptor
module tools.jackson.dataformat.smile
{
requires tools.jackson.core;
requires tools.jackson.databind;

Expand Down
28 changes: 28 additions & 0 deletions smile/src/test/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Smile unit test Module descriptor
module tools.jackson.dataformat.smile
{
// Since we are not split from Main artifact, will not
// need to depend on Main artifact -- but need its dependencies

requires tools.jackson.core;
requires tools.jackson.databind;

// Additional test lib/framework dependencies
requires org.junit.jupiter.api;
requires org.junit.jupiter.params;

// Further, need to open up some packages for JUnit et al
opens tools.jackson.dataformat.smile;
opens tools.jackson.dataformat.smile.async;
opens tools.jackson.dataformat.smile.constraints;
opens tools.jackson.dataformat.smile.dos;
opens tools.jackson.dataformat.smile.filter;
opens tools.jackson.dataformat.smile.fuzz;
opens tools.jackson.dataformat.smile.gen;
opens tools.jackson.dataformat.smile.gen.dos;
opens tools.jackson.dataformat.smile.mapper;
opens tools.jackson.dataformat.smile.parse;
opens tools.jackson.dataformat.smile.seq;
opens tools.jackson.dataformat.smile.testutil;
opens tools.jackson.dataformat.smile.testutil.failure;
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,27 @@ public void testSimpleDefault() throws Exception
assertTrue(syms.isCanonicalizing()); // added in 2.13

assertEquals(0, syms.size());
assertEquals(0, _findParent(syms).size());
//assertEquals(0, _findParent(syms).size());

assertToken(JsonToken.START_OBJECT, p.nextToken());
assertToken(JsonToken.PROPERTY_NAME, p.nextToken());
assertEquals("a", p.currentName());
assertEquals(1, syms.size());
// not yet synced to parent
assertEquals(0, _findParent(syms).size());
//assertEquals(0, _findParent(syms).size());

while (p.nextToken() != null) { ; }
assertEquals(2, syms.size());
// but after closing, should sync
assertEquals(2, _findParent(syms).size());
//assertEquals(2, _findParent(syms).size());
}

// by default, should canonicalize etc:
try (JsonParser p = vanillaMapper.createParser(doc)) {
ByteQuadsCanonicalizer syms = _findSymbols(p);
assertEquals(2, syms.size());
// also check that parent (root) has it all?
assertEquals(2, _findParent(syms).size());
//assertEquals(2, _findParent(syms).size());

// but no additions second time around
while (p.nextToken() != null) { ; }
Expand Down Expand Up @@ -128,7 +128,7 @@ public void testSimpleNoCanonicalize() throws Exception
assertFalse(syms.isCanonicalizing()); // added in 2.13
assertEquals(-1, syms.size());
// also, should not have parent:
assertNull(_findParent(syms));
//assertNull(_findParent(syms));

assertToken(JsonToken.START_OBJECT, p.nextToken());
assertToken(JsonToken.PROPERTY_NAME, p.nextToken());
Expand Down Expand Up @@ -237,10 +237,13 @@ private ByteQuadsCanonicalizer _findSymbols(JsonParser p) throws Exception
return (ByteQuadsCanonicalizer) f.get(p);
}

// Cannot access under JPMS, alas
/*
private ByteQuadsCanonicalizer _findParent(ByteQuadsCanonicalizer sym) throws Exception
{
Field f = ByteQuadsCanonicalizer.class.getDeclaredField("_parent");
f.setAccessible(true);
return (ByteQuadsCanonicalizer) f.get(sym);
}
*/
}

0 comments on commit 127167e

Please sign in to comment.