Skip to content

Android dex2oatd error #1192

@gszo123

Description

@gszo123

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions