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

calling toArray on an existing Array crashes at runtime #668

Closed
scabug opened this issue Mar 21, 2008 · 3 comments
Closed

calling toArray on an existing Array crashes at runtime #668

scabug opened this issue Mar 21, 2008 · 3 comments
Milestone

Comments

@scabug
Copy link

scabug commented Mar 21, 2008

Since nulls are not allowed to be unboxed to values, the following code fails (causing the scrip tests to fail as well).

  val chrs: Array[Char] = ...
  chrs.toArray
scala> val ints = Array(1, 2, 3)
ints: Array[Int] = Array(1, 2, 3)

scala> ints.toArray
java.lang.ClassCastException: null is no Int value
        at scala.runtime.BoxesRunTime.unboxToInt(Unknown Source)
        at scala.runtime.BoxedAnyArray.unbox(BoxedAnyArray.scala:97)
        at scala.runtime.BoxedAnyArray.unbox(BoxedAnyArray.scala:80)
        at scala.runtime.BoxedAnyArray.adapt(BoxedAnyArray.scala:205)
        at scala.runtime.BoxedAnyArray.copyFrom(BoxedAnyArray.scala:236)
        at scala.Array$$.copy(Arr...
@scabug
Copy link
Author

scabug commented Mar 21, 2008

Imported From: https://issues.scala-lang.org/browse/SI-668?orig=1
Reporter: @dragos

@scabug
Copy link
Author

scabug commented Mar 21, 2008

@dubochet said:
Fixed by reverting change in r14428. But issue #602 is broken again.

I wonder if fixing the array copy mechanism wouldn't be better. The fact that it has to unbox each null value in the array to Integer(0) before overwriting it with the copied value just seems wrong.

I reassign this bug to devteam so that the Array expert, whoever that is, can have a look.

If you choose to correct copy, please reapply fix for #602 that is commented out in scala.runtime.BoxesRunTime in the Java and CLDC libraries.

@scabug
Copy link
Author

scabug commented Jan 14, 2009

@odersky said:
Milestone 2.7.1 deleted

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

No branches or pull requests

1 participant