locationtech / locationtech/jts
Android dex2oatd error
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 2.2k
- Forks
- 475
- Avg merge
- 14d 10h
- Merged PRs (30d)
- 1
Description
Summary
jts-core 1.20.0 fails Android ART verification during dex2oatd compilation for RelatePointLocator.init(Geometry).
The failure appears to be caused by assigning arrays of concrete locator implementations to a field whose declared type is PointOnGeometryLocator[], without using the declared array type directly.
Environment
- JTS version: 1.20.0
- Platform: Android
- Compiler/runtime component: ART /
dex2oatd - Affected class:
org.locationtech.jts.operation.relateng.RelatePointLocator - Affected method:
init(Geometry)
Actual Behavior
During Android compilation, dex2oatd aborts with the following verifier error:
dex2oatd F 04-17 06:43:05 90246 90246 method_verifier.cc:5126]
Verification error in void org.locationtech.jts.operation.relateng.RelatePointLocator.init(org.locationtech.jts.geom.Geometry)
void org.locationtech.jts.operation.relateng.RelatePointLocator.init(org.locationtech.jts.geom.Geometry) failed to verify:
[0x2D] register v3 has type Reference: java.lang.Object[] but expected Reference:
org.locationtech.jts.algorithm.locate.PointOnGeometryLocator[]
dex2oatd F 04-17 06:43:10 90246 90246 compiler_driver.cc:866]
Had a hard failure verifying all classes, and was asked to abort in such situations.
Expected Behavior
jts-core should pass Android ART verification and compile successfully with dex2oatd.
Suspected Cause
The issue seems to come from this code in:
modules/core/src/main/java/org/locationtech/jts/operation/relateng/RelatePointLocator.java
private void init(Geometry geom) {
//-- cache empty status, since may be checked many times
isEmpty = geom.isEmpty();
extractElements(geom);
if (lines != null) {
lineBoundary = new LinearBoundary(lines, boundaryRule);
}
if (polygons != null) {
polyLocator = isPrepared
? new IndexedPointInAreaLocator[polygons.size()]
: new SimplePointInAreaLocator[polygons.size()];
}
}
polyLocator appears to be declared as:
PointOnGeometryLocator[] polyLocator;
The ternary expression creates either an IndexedPointInAreaLocator[] or a SimplePointInAreaLocator[].
Although both element types implement PointOnGeometryLocator, Android ART appears to infer or verify the ternary expression as Object[], which then fails when assigning it to PointOnGeometryLocator[].
Impact
This prevents use of JTS 1.20.0 in affected Android builds because ART verification fails during dex2oatd compilation.
Additional Notes
This may not appear on standard JVMs because the bytecode is accepted there, but Android ART verification is stricter in this case.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in modules/core/src/main/java/org/locationtech/jts/operation/relateng/RelatePointLocator.java, at init(Geometry), and inspect the polyLocator declaration alongside the ternary array construction. Reproduce or inspect the Android ART dex2oatd verification failure, then confirm that jts-core passes Android verification without the Object[] type mismatch.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100