使用 throws 子句混淆方法

发布于 2024-07-26 06:41:48 字数 510 浏览 4 评论 0原文

我正在使用 ProGuard 来混淆我的代码。 我的项目由几个模块组成,每个模块都是独立混淆的。

一个库包含一个接口;

public interface IFace {
    public int methodA(boolean b) throws CustomException;
}

另一个库提供了一个实现,

public class IFaceImpl implements IFace {
    @Override
    public int methodA(boolean b) throws CustomException {
        return 0;
    }
}

首先构建带有接口的库,然后针对混淆版本构建第二个库。 不幸的是,由于接口没有 throws 子句,@Override 上的编译失败。

我有 proguard 保留接口及其所有成员,但我不知道如何保留 throws 子句。

I'm using ProGuard to obfuscate my code. My project is comprised of a few modules, each obfuscated independently.

One library includes an interface;

public interface IFace {
    public int methodA(boolean b) throws CustomException;
}

Another library provides an implmentation

public class IFaceImpl implements IFace {
    @Override
    public int methodA(boolean b) throws CustomException {
        return 0;
    }
}

The library with the interface is built first, and the second is built against the obfuscated version. Unfortunately the compile fails on the @Override as the interface does not have the throws clause.

I have proguard keeping the interface and all its members, but I can't figure out how to keep the throws clause.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

以为你会在 2024-08-02 06:41:48

我想到了。

-keepattributes 异常

I figured it out.

-keepattributes Exceptions

清欢 2024-08-02 06:41:48

使用 Maven 的示例:

<plugin>
    <groupId>com.github.wvengen</groupId>
    <artifactId>proguard-maven-plugin</artifactId>
    <version>2.0.6</version>
    <dependencies>
        <dependency>
            <groupId>net.sf.proguard</groupId>
            <artifactId>proguard-base</artifactId>
            <version>4.10</version>
        </dependency>
    </dependencies>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>proguard</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <proguardVersion>4.10</proguardVersion>
        <options>
            <option>-keepattributes Exceptions</option>
            <option>-keep public class some.package.SomeClass{*;}</option>
        </options>
        <libs>
            <lib>${java.home}/lib/rt.jar</lib>
            <lib>${java.home}/lib/jce.jar</lib>
            <lib>${java.home}/lib/jsse.jar</lib>
        </libs>
    </configuration>
</plugin>

Example with Maven:

<plugin>
    <groupId>com.github.wvengen</groupId>
    <artifactId>proguard-maven-plugin</artifactId>
    <version>2.0.6</version>
    <dependencies>
        <dependency>
            <groupId>net.sf.proguard</groupId>
            <artifactId>proguard-base</artifactId>
            <version>4.10</version>
        </dependency>
    </dependencies>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>proguard</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <proguardVersion>4.10</proguardVersion>
        <options>
            <option>-keepattributes Exceptions</option>
            <option>-keep public class some.package.SomeClass{*;}</option>
        </options>
        <libs>
            <lib>${java.home}/lib/rt.jar</lib>
            <lib>${java.home}/lib/jce.jar</lib>
            <lib>${java.home}/lib/jsse.jar</lib>
        </libs>
    </configuration>
</plugin>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文