Skip to content

Cyclic reference involving class org.apiguardian.api.API (JUnit 5) #6868

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

Closed
michelou opened this issue Jul 17, 2019 · 1 comment
Closed

Cyclic reference involving class org.apiguardian.api.API (JUnit 5) #6868

michelou opened this issue Jul 17, 2019 · 1 comment

Comments

@michelou
Copy link
Contributor

The following code snippet works fine with Scala 2.13 but fails with Dotty 0.16-RC3.

Environment setup (in fresh created directory):

> java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_212-b03)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.212-b03, mixed mode)

> scalac -version
Scala compiler version 2.13.0 -- Copyright 2002-2019, LAMP/EPFL and Lightbend, Inc.

> dotc -version
Dotty compiler version 0.16.0-RC3 -- Copyright 2002-2019, LAMP/EPFL

> mkdir target\classes target\libs
> curl.exe --silent --output target\libs\junit-platform-console-standalone-1.5.0.jar https://repo1.maven.org/maven2/org/junit/platform/junit-platform-console-standalone/1.5.0/junit-platform-console-standalone-1.5.0.jar

Scala source code (src\test\scala\MainTests.scala):

package myexamples

import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test

class MainTests {
  @Test
  @DisplayName("test01 example")
  def test01: Unit = {
    Assertions.assertEquals(2, 1 + 1, "1 + 1 should equal 2")
  }
}

Scala 2.13 session

> scalac.bat -deprecation -feature -classpath target\libs\junit-platform-console-standalone-1.5.0.jar -d target\classes  src\test\scala\MainTests.scala

> java.exe -classpath target\libs\junit-platform-console-standalone-1.5.0.jar;c:\opt\scala-2.13.0\lib\scala-library.jar org.junit.platform.console.ConsoleLauncher --disable-banner --classpath target\classes --select-package=myexamples --include-classname=.*Tests
.
+-- JUnit Jupiter [OK]
| '-- MainTests [OK]
|   '-- test01 example [OK]
'-- JUnit Vintage [OK]

Test run finished after 186 ms
[         3 containers found      ]
[         0 containers skipped    ]
[         3 containers started    ]
[         0 containers aborted    ]
[         3 containers successful ]
[         0 containers failed     ]
[         1 tests found           ]
[         0 tests skipped         ]
[         1 tests started         ]
[         0 tests aborted         ]
[         1 tests successful      ]
[         0 tests failed          ]

Dotty 0.16-RC3 session:

> dotc.bat -deprecation -feature -classpath target\libs\junit-platform-console-standalone-1.5.0.jar -d target\classes  src\test\scala\MainTests.scala
exception caught when loading class Status: CyclicReferenceInvolving(class API)
exception caught when loading class API: CyclicReferenceInvolving(class API)
exception caught when loading class API$Status: CyclicReferenceInvolving(class API)
exception caught when loading class Test: CyclicReferenceInvolving(class API)
-- [E046] Cyclic Error: src\test\scala\MainTests.scala:9:3 ---------------------
9 |  @Test
  |   ^
  |   Cyclic reference involving class API

longer explanation available when compiling with `-explain`
Caught: java.lang.AssertionError: assertion failed: failure to resolve inner class:
externalName = org.apiguardian.api.API$Status,
outerName = org.apiguardian.api.API,
innerName = Status
owner.fullName = org.apiguardian.api.API
while parsing target\libs\junit-platform-console-standalone-1.5.0.jar(org/junit/jupiter/api/DisplayName.class) while parsing annotations in target\libs\junit-platform-console-standalone-1.5.0.jar(org/junit/jupiter/api/DisplayName.class)
Caught: java.lang.AssertionError: assertion failed: failure to resolve inner class:
externalName = org.apiguardian.api.API$Status,
outerName = org.apiguardian.api.API,
innerName = Status
[...]
owner.fullName = org.apiguardian.api.API
while parsing target\libs\junit-platform-console-standalone-1.5.0.jar(org/junit/jupiter/api/Assertions.class) while parsing annotations in target\libs\junit-platform-console-standalone-1.5.0.jar(org/junit/jupiter/api/Assertions.class)
23 warnings found
one error found

where command dotc.bat (see PR #5444) is equivalent to:

"C:\opt\jdk-1.8.0_212-b03\bin\java.exe" -Xmx2048m -XX:ReservedCodeCacheSize=2048m -XX:MaxMetaspaceSize=1024m   -classpath C:\opt\dotty-0.16.0-RC3\lib\scala-library-2.12.8.jar;C:\opt\dotty-0.16.0-RC3\lib\scala-asm-6.0.0-scala-1.jar;C:\opt\dotty-0.16.0-RC3\lib\compiler-interface-1.2.5.jar;C:\opt\dotty-0.16.0-RC3\lib\dotty-interfaces-0.16.0-RC3.jar;C:\opt\dotty-0.16.0-RC3\lib\dotty-library_0.16-0.16.0-RC3.jar;C:\opt\dotty-0.16.0-RC3\lib\dotty-compiler_0.16-0.16.0-RC3.jar;C:\opt\dotty-0.16.0-RC3\lib\jline-reader-3.9.0.jar;C:\opt\dotty-0.16.0-RC3\lib\jline-terminal-3.9.0.jar;C:\opt\dotty-0.16.0-RC3\lib\jline-terminal-jna-3.9.0.jar;C:\opt\dotty-0.16.0-RC3\lib\jna-4.2.2.jar -Dscala.usejavacp=true dotty.tools.dotc.Main   -deprecation -feature -classpath target\libs\junit-platform-console-standalone-1.5.0.jar -d target\classes src\test\scala\MainTests.scala
@bishabosha
Copy link
Member

This is still occurring on master branch dotty

noti0na1 added a commit to noti0na1/dotty that referenced this issue Jul 23, 2019
noti0na1 added a commit to noti0na1/dotty that referenced this issue Jul 23, 2019
smarter added a commit to dotty-staging/dotty that referenced this issue Jul 31, 2019
Compute the info of synthesized Java annotation constructors lazily,
just like the info of all the other members created by ClassfileParser.

Thanks to noti0na1 for the initial investigation and test case!
@odersky odersky closed this as completed in 0ea949a Aug 2, 2019
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

2 participants