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

Generation fails when generic cllass in annotation #2509

Closed
caalador opened this issue May 24, 2022 · 1 comment · Fixed by #2562
Closed

Generation fails when generic cllass in annotation #2509

caalador opened this issue May 24, 2022 · 1 comment · Fixed by #2562
Assignees
Labels

Comments

@caalador
Copy link

Describe the bug
When having an annotation that takes a class value and the class is generic the mvn dokka:javadoc command fails with the exception:

[ERROR] Failed to execute goal org.jetbrains.dokka:dokka-maven-plugin:1.6.21:javadoc (default-cli) on project kotlin-maven-example: A type incompatibility occurred while executing org.jetbrains.dokka:dokka-maven-plugin:1.6.21:javadoc: class com.intellij.psi.impl.source.PsiImmediateClassType cannot be cast to class com.intellij.psi.impl.source.PsiClassReferenceType (com.intellij.psi.impl.source.PsiImmediateClassType and com.intellij.psi.impl.source.PsiClassReferenceType are in unnamed module of loader java.net.URLClassLoader @6cd15072)
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.jetbrains.dokka:dokka-maven-plugin:1.6.21
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/.../.m2/repository/org/jetbrains/dokka/dokka-maven-plugin/1.6.21/dokka-maven-plugin-1.6.21.jar
[ERROR] urls[1] = file:/C:/.../.m2/repository/org/jetbrains/dokka/dokka-core/1.6.21/dokka-core-1.6.21.jar
...
[ERROR] urls[39] = file:/C:/.../.m2/repository/org/jetbrains/annotations/13.0/annotations-13.0.jar
[ERROR] urls[40] = file:/C:/.../.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.6.21/kotlin-stdlib-jdk7-1.6.21.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------

Expected behaviour
Generation succeeds no matter what type of class is in the annotation.

Screenshots
If applicable, add screenshots to help explain your problem

To Reproduce
Have the Java classes:

package com.example;

// Generation succeeds if the generics is dropped
public class Breaking<Y> { 
}
package com.example;

public @interface TestAnnotate {

    Class<?> value();
}
package com.example;

@TestAnnotate(Breaking.class)
public class TestGeneric {
    
}

execute mvn compile dokka:javadoc

Dokka configuration

            <plugin>
                <groupId>org.jetbrains.dokka</groupId>
                <artifactId>dokka-maven-plugin</artifactId>
                <version>${dokka.version}</version>
                <executions>
                    <execution>
                        <phase>pre-site</phase>
                        <goals>
                            <goal>dokka</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <jdkVersion>${maven.compiler.source}</jdkVersion>
                    <sourceDirectories>
                        <sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
                    </sourceDirectories>
                </configuration>
            </plugin>

Installation

  • Operating system: Windows/Linux
  • Build tool: Maven
  • Dokka version: 1.6.21

Are you willing to provide a PR?
No time to get into the workings of a new project at the moment.

@IgnatBeresnev
Copy link
Member

Hi! Thanks for the report and huge thanks for the reproducer, it was of great help! I've added a unit test to cover your exact case

IgnatBeresnev added a commit that referenced this issue Jul 7, 2022
IgnatBeresnev added a commit that referenced this issue Jul 11, 2022
Fixes #2509
Fixes #2551
Fixes #2350

(cherry picked from commit 3332f9f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants