2

我正在构建一个 SDK,它将通过 JAR 无源分发。一切正常,但我在接口类中使用的描述性参数名称在此过程中丢失了。

我的界面:

package com.example;
public interface ExampleInterfaceClass {
    /**
     * Method documentation
     * @param descriptiveParameter a parameter name I want included for anyone implementing this interface from a JAR
     */
    public void DoSomething(int descriptiveParameter);
}

当我使用可用源实现此接口时,“descriptiveParameter”会自动生成为“descriptiveParameter”:

public class ExampleImplementor implements ExampleInterfaceClass {
    @Override
    public void DoSomething(int descriptiveParameter) {
        // TODO Auto-generated method stub
    }
}

但是,当我从已编译的 JAR 实现时,参数会自动生成为“arg0”:

public class ExampleImplementFromJAR implements ExampleInterfaceClass {
    @Override
    public void DoSomething(int arg0) {
        // TODO Auto-generated method stub
    }
}

通过这样的问题提出了许多解决方案:Preserving parameter/argument names in compiled java classes,但没有一个解决方案使我能够 1. 在我的 JAR 中包含描述性参数,以及 2. 从其他类中隐藏源. 有没有办法通过 eclipse 导出仅在 JAR 文件中包含来自我的接口文件的源代码?如果不是,那么使用源对象子集生成 JAR 的下一个最简单方法是什么?

4

1 回答 1

0

我的猜测是这是不可能的。

我猜的原因是 Android SDK 本身中有几个示例,其中自动填充方法获取名为 arg0、arg1、arg2 等的参数...

我想如果可以在官方 Android SDK 中构建组件时携带描述性参数名称,他们会这样做。

That being said, my theory is entirely based on my own observations while working with Android SDK / Eclipse, I have not read specifically anywhere that it is infact not possible.

于 2012-06-15T19:31:46.513 回答