Skip to content

aspectj tests are not runnable due to wrong classloader setup #42

@Andrei-Pozolotin

Description

@Andrei-Pozolotin

in projects such as kamon
https://github.com/kamon-io/Kamon

eclipse/scala-test aspectj tests are not runnable due to wrong classloader setup
https://github.com/scalatest/scalatest-eclipse-plugin/blob/master/org.scala-ide.sdt.scalatest/src/scala/tools/eclipse/scalatest/launching/ScalaTestLauncher.scala#L45

problem arises as follows:

  1. scala-test is launched with -javaagent:aspectjweaving.jar
  • system classloader is empty and injected by jvm into aspectj
  • aspectj finds no META-INF/aop.xml and disables any further class transform form system classloader
  1. scala-test launcher is hacking system classloader in main() by adding all the jars from eclipse class path, but aspectj will never see the change

  2. all following tests fail, since META-INF/aop.xml are present, but ignored by aspectj.

solution:

  • create a class path url array first and build child classloader from final array
  • when child classloader is injected by jvm into aspectj, it will discover all metadata

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions