Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Сan't find referenced class ClassName$DefaultImpls #290

Closed
tox1cozZ opened this issue Nov 1, 2022 · 4 comments
Closed

Сan't find referenced class ClassName$DefaultImpls #290

tox1cozZ opened this issue Nov 1, 2022 · 4 comments

Comments

@tox1cozZ
Copy link

tox1cozZ commented Nov 1, 2022

Proguard 7.3.0-beta2
Kotlin 1.7.20

I don't understand why he is looking for the DefaultImpls class for the annotation?
And in general, I have Java 8 and there is a parameter -Xjvm-default=all in the compiler arguments

Screenshot_6
Screenshot_7

@rubenpieters
Copy link
Contributor

Hey, thanks for the report. Do you have a small reproducible sample that results in this behavior? As far as I can tell from your report, ProGuard is warning that there is a reference to class NoArg$DefaultImpls from NoArg, but NoArg$DefaultImpls can't be found (which presumably is something the Kotlin compiler has added). We can look into it more closely once you provide a reproducible sample.

Does the code still work after processing with ProGuard or does it result in a crash/different behavior?

@oliver-charlesworth
Copy link

I can reproduce this symptom when I use keepkotlinmetadata.

Repro

src/main/kotlin/wat/Foo.kt

package wat

interface Foo

build.gradle.kts

import proguard.gradle.ProGuardTask

buildscript {
    dependencies {
        classpath("com.guardsquare:proguard-gradle:7.3.0-beta2")
    }
}

plugins {
    kotlin("jvm") version "1.7.21"
}

repositories {
    mavenCentral()
}

val proguard by tasks.registering(ProGuardTask::class) {
    injars(tasks.jar)
    outjars(buildDir.resolve("obfuscated/obfuscated.jar"))

    libraryjars(configurations.compileClasspath)

    val javaHome = System.getProperty("java.home")
    libraryjars(
        mapOf(
            "jarfilter" to "!**.jar",
            "filter"    to "!module-info.class",
        ),
        "$javaHome/jmods/java.base.jmod"
    )

    keepkotlinmetadata()
    dontshrink()
    dontoptimize()
    printmapping()
}

Error

ProGuard, version 7.3.0-beta2
Warning: wat.Foo: can't find referenced class wat.Foo$DefaultImpls

If I remove the keepkotlinmetadata(), then this succeeds.

@mrjameshamilton
Copy link
Collaborator

Thanks for the sample @oliver-charlesworth ! We tracked down the cause solved the underlying issue in ProGuardCORE. This should make it into the next patch release of ProGuard.

For now, you should be able to add -dontwarn for those classes (e.g. dontwarn("**DefaultImpls")), or use -ignorewarnings.

@mrjameshamilton
Copy link
Collaborator

Hi @tox1cozZ , @oliver-charlesworth ! The fix is now in ProGuard 7.3.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants