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

android and scala 2.10.0-M1: Could not find method scala.collection.immutable.StringLike.toString, referenced from method scala.collection.immutable.StringLike$class.apply #5397

Open
scabug opened this issue Jan 21, 2012 · 12 comments
Milestone

Comments

@scabug
Copy link

scabug commented Jan 21, 2012

In the android application line 88
01-21 00:31:36.339: E/AndroidRuntime(625): at
com.android.demo.notepad1.Notepadv1.fillData(Activity.scala:88)

is a runtime initialization error raised "Could not find method scala.collection.immutable.StringLike.toString, referenced from method scala.collection.immutable.StringLike$class.apply"

var to = Array[Int](R.id.text1) 

in

  private def fillData() { 
        // Get all of the notes from the database and create the item list 
        val notesCursor = mDbHelper.fetchAllNotes() 
        startManagingCursor(notesCursor) 


        var from = Array[String](mDbHelper.KEY_TITLE) 
        var to = Array[Int](R.id.text1) 


        // Now create an array adapter and set it to display using our row 
        val notes = new SimpleCursorAdapter(this, R.layout.notes_row, 
notesCursor, from, to) 
        setListAdapter(notes) 
  } 

see for full logcat stacktrace(also attached):
http://groups.google.com/group/scala-internals/browse_thread/thread/9b8f2d51da6cadcc?hl=nl

attached is the zipped android app project notepadv1.zip
used:
android-sbt git cloned publish-local 0.6.1-SNAPSHOT
sbt 0.11.2

One guess to point in a direction is that this is a regression bug:

Johannes Rudolph 2:
"That seems to be the same problem which Paul already tried to fix
where an invokeinterface bytecode is used to call toString()

From StringLike$class.split:

1: invokeinterface #12, 1; //InterfaceMethod
scala/collection/immutable/StringLike.toString:()Ljava/lang/String;

Strange that it has reappeared."

@scabug
Copy link
Author

scabug commented Jan 21, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5397?orig=1
Reporter: DaveScala (davescala)
Affected Versions: 2.10.0-RC2, 2.10.0, 2.11.7
Attachments:

@scabug
Copy link
Author

scabug commented Jan 23, 2012

@jrudolph said:
That's a simple example of triggering the issue:

trait Parent {
  override def toString = "blubber"
}

trait Simple extends Parent {
  def test = toString
}

Scalac generates this bytecode:

public static java.lang.String test(Simple);
  Code:
   Stack=1, Locals=1, Args_size=1
   0:	aload_0
   1:	invokeinterface	#12,  1; //InterfaceMethod Simple.toString:()Ljava/lang/String;
   6:	areturn

where javac would normally generate an invokevirtual Object.toString. Using invokeinterface in those cases isn't supported by dalvik currently.

It seems that the last fix for this issue didn't solve the problem if the method was overridden in a super-interface.

@scabug
Copy link
Author

scabug commented Jul 21, 2012

DaveScala (davescala) said:
For milestone 1 (I can still reproduce this error in M1)
there seems to be a workaround

add this

-keep class scala.collection.SeqLike {
    public protected *;
}

to the proguard options

But in milestone 5, I cannot reproduce this error.
Has it been solved as a side effect of another issue?
Or can anyone reproduce this error in M5?

@scabug
Copy link
Author

scabug commented Jul 23, 2012

DaveScala (davescala) said:

07-23 17:13:18.415: E/AndroidRuntime(925): FATAL EXCEPTION: main
07-23 17:13:18.415: E/AndroidRuntime(925): java.lang.NoSuchMethodError: scala.collection.immutable.StringLike.toString
07-23 17:13:18.415: E/AndroidRuntime(925): 	at scala.collection.immutable.StringLike$class.apply(StringLike.scala:53)
07-23 17:13:18.415: E/AndroidRuntime(925): 	at scala.collection.immutable.WrappedString.apply(WrappedString.scala:31)
07-23 17:13:18.415: E/AndroidRuntime(925): 	at scala.collection.immutable.WrappedString.apply(WrappedString.scala:31)
07-23 17:13:18.415: E/AndroidRuntime(925): 	at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:34)
07-23 17:13:18.415: E/AndroidRuntime(925): 	at scala.collection.immutable.WrappedString.foreach(WrappedString.scala:31)
07-23 17:13:18.415: E/AndroidRuntime(925): 	at scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)
07-23 17:13:18.415: E/AndroidRuntime(925): 	at scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:178)
07-23 17:13:18.415: E/AndroidRuntime(925): 	at scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:45)
07-23 17:13:18.415: E/AndroidRuntime(925): 	at scala.collection.TraversableLike$class.to(TraversableLike.scala:623)
07-23 17:13:18.415: E/AndroidRuntime(925): 	at scala.collection.immutable.StringOps.to(StringOps.scala:31)
07-23 17:13:18.415: E/AndroidRuntime(925): 	at scala.collection.TraversableOnce$class.toList(TraversableOnce.scala:243)
07-23 17:13:18.415: E/AndroidRuntime(925): 	at scala.collection.immutable.StringOps.toList(StringOps.scala:31)

It is still there. The workaround works.

@scabug
Copy link
Author

scabug commented Jul 23, 2012

DaveScala (davescala) said:
The test line is:

val lst = "test123".toList

@scabug
Copy link
Author

scabug commented Jul 27, 2012

loool (faez.lo) said:
تجربه

@scabug
Copy link
Author

scabug commented Nov 13, 2012

Martin Kneissl (mkneissl) said:
Bug is still present in 2.10.0-RC2, workaround works.

@scabug
Copy link
Author

scabug commented Jan 24, 2013

Christian Braun (hcb) said:
Bug is in 2.10.0.v20121205-210653-43cd2b26d3. workaround works.

@scabug
Copy link
Author

scabug commented May 17, 2013

Sung-Ho Lee (pocorall) said:
Bug is still present in 2.10.1, workaround works.

@scabug
Copy link
Author

scabug commented Oct 3, 2013

Sung-Ho Lee (pocorall) said:
Bug is still present in 2.10.3, workaround works.

@scabug
Copy link
Author

scabug commented Sep 15, 2015

Antoine Dutot (Antoine) said:
The bug still seems to be present in 2.11.7, excepted I was not able to use the workaround. I have a minimal android project that produces the error if needed, tested with android 22 (5.1).

I found this bug trying to use Spray.http where the problem occurs in spray.http.Rendering.scala, with two traits exactly similar to the example of Johannes are used.

@scabug
Copy link
Author

scabug commented Feb 3, 2016

Perry Nguyen (pfn) said (edited on Feb 3, 2016 12:44:08 AM UTC):
I have encountered this issue using manual configuration of ACRA as well ACRA/acra#355 (with scala 2.11.7)

@SethTisue SethTisue added this to the Backlog milestone Feb 17, 2018
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