当我想将 java geohash代码迁移到 groovy平台,然后报告
ERROR: Groovy: java.lang.VerifyError: (class: GeoHash, method:
recombineLatLonBitsToHash signature: (Ljava/lang/Object;[J)LGeoHash;)
Expecting to find integer on stack
这是java geohash代码:
protected GeoHash recombineLatLonBitsToHash(long[] latBits, long[] lonBits) {
GeoHash hash = new GeoHash();
boolean isEvenBit = false;
latBits[0] <<= (MAX_BIT_PRECISION - latBits[1]);
lonBits[0] <<= (MAX_BIT_PRECISION - lonBits[1]);
double[] latitudeRange = [-90.0, 90.0];
double[] longitudeRange = [-180.0, 180.0];
for (int i = 0; i < latBits[1] + lonBits[1]; i++) {
if (isEvenBit) {
divideRangeDecode(hash, latitudeRange, (latBits[0] & FIRST_BIT_FLAGGED) == FIRST_BIT_FLAGGED);
latBits[0] <<= 1;
} else {
divideRangeDecode(hash, longitudeRange, (lonBits[0] & FIRST_BIT_FLAGGED) == FIRST_BIT_FLAGGED);
lonBits[0] <<= 1;
}
isEvenBit = !isEvenBit;
}
hash.bits <<= (MAX_BIT_PRECISION - hash.significantBits);
setBoundingBox(hash, latitudeRange, longitudeRange);
hash.point = hash.boundingBox.getCenterPoint();
return hash;
}
public GeoHash getSouthernNeighbour() {
long[] latitudeBits = getRightAlignedLatitudeBits();
long[] longitudeBits = getRightAlignedLongitudeBits();
latitudeBits[0] -= 1;
latitudeBits[0] = maskLastNBits(latitudeBits[0], latitudeBits[1]);
return recombineLatLonBitsToHash(latitudeBits, longitudeBits);
}
然后我将 recombineLatLonBitsToHash 参数类型 long [] 更改为 def ,它不会报告错误:
protected GeoHash recombineLatLonBitsToHash(def latBits, def lonBits) {
GeoHash hash = new GeoHash();
boolean isEvenBit = false;
latBits[0] <<= (MAX_BIT_PRECISION - latBits[1]);
lonBits[0] <<= (MAX_BIT_PRECISION - lonBits[1]);
double[] latitudeRange = [-90.0, 90.0];
double[] longitudeRange = [-180.0, 180.0];
for (int i = 0; i < latBits[1] + lonBits[1]; i++) {
if (isEvenBit) {
divideRangeDecode(hash, latitudeRange, (latBits[0] & FIRST_BIT_FLAGGED) == FIRST_BIT_FLAGGED);
latBits[0] <<= 1;
} else {
divideRangeDecode(hash, longitudeRange, (lonBits[0] & FIRST_BIT_FLAGGED) == FIRST_BIT_FLAGGED);
lonBits[0] <<= 1;
}
isEvenBit = !isEvenBit;
}
hash.bits <<= (MAX_BIT_PRECISION - hash.significantBits);
setBoundingBox(hash, latitudeRange, longitudeRange);
hash.point = hash.boundingBox.getCenterPoint();
return hash;
}
public GeoHash getSouthernNeighbour() {
long[] latitudeBits = getRightAlignedLatitudeBits();
long[] longitudeBits = getRightAlignedLongitudeBits();
latitudeBits[0] -= 1;
latitudeBits[0] = maskLastNBits(latitudeBits[0], latitudeBits[1]);
return recombineLatLonBitsToHash(latitudeBits, longitudeBits);
}
我想知道为什么报告错误以及为什么我将类型更改为def然后工作。 THX!