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

IllegalAccessError from super[Object].clone in a trait #12926

Open
noresttherein opened this issue Jan 6, 2024 · 1 comment
Open

IllegalAccessError from super[Object].clone in a trait #12926

noresttherein opened this issue Jan 6, 2024 · 1 comment

Comments

@noresttherein
Copy link

noresttherein commented Jan 6, 2024

Reproduction steps

Scala version: 2.13.11

	trait Clone extends AnyRef with Cloneable {
		override def clone :Clone = super[Object].clone.asInstanceOf[Clone]
	}
	class C extends Clone
	(new C).clone

Problem

Exception in thread "main" java.lang.IllegalAccessError: class Playground$Clone tried to access protected method 'java.lang.Object java.lang.Object.clone()' (Playground$Clone is in unnamed module of loader 'app'; java.lang.Object is in module java.base of loader 'bootstrap')
	at Playground$Clone.clone(Playground.scala:114)
	at Playground$Clone.clone$(Playground.scala:114)
	at Playground$C.clone(Playground.scala:116)
	at Playground$.delayedEndpoint$Playground$1(Playground.scala:117)
	at Playground$delayedInit$body.apply(Playground.scala:106)
	at scala.Function0.apply$mcV$sp(Function0.scala:42)
	at scala.Function0.apply$mcV$sp$(Function0.scala:42)
	at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17)
	at scala.App.$anonfun$main$1(App.scala:98)
	at scala.App.$anonfun$main$1$adapted(App.scala:98)
	at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:576)
	at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:574)
	at scala.collection.AbstractIterable.foreach(Iterable.scala:933)
	at scala.App.main(App.scala:98)
	at scala.App.main$(App.scala:96)
	at Playground$.main(Playground.scala:106)
	at Playground.main(Playground.scala)

I understand that 'super to class from an interface' is problematic in itself, but IllegalAccessError at runtime is still bad.

@SethTisue
Copy link
Member

happens in Scala 3.4.0-RC3 as well

@SethTisue SethTisue added this to the Backlog milestone Jan 26, 2024
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