有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

Groovy:java。lang.VerifyError:希望在堆栈上找到整数

当我想将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);
}

然后我将参数类型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然后工作。谢谢


共 (0) 个答案