-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Repl javap decodes various synthetic names for us (fixing SI-6894)
For instance, javap -app Test is equivalent to javap Test$delayedInit$App with the correct line and iw prepended. This works by taking Test as a name in scope, translating that, and then supplying the suffix. Then javap -fun Test shows Test$$anonfun*, and for member m, javap -fun Test#m shows Test$$anonfun$$m*. This also works for classes and values defined in the repl. javap -fun -raw m shows $line3.$read$$iw$$iw$$anonfun$m$1. E.g., javap -fun scala.Enumeration obviates knowing or guessing scala/Enumeration$$anonfun$scala$Enumeration$$populateNameMap$1.class. Also, scala> :javap -fun scala.Array#concat but still to do is using imported syms. Both files and replout are supported for searching for artifacts. The trigger is detecting the synthetic name (has an interior dollar). Still to do, filter the output on Test#m to show only m. Need a way to explore the list of artifacts; ideally, related symbols would be available reflectively. Prefer companion class to object, otherwise it's not showable; for object, require dollar when both exist. A JavapTest is supplied that is a ReplTest that asserts something about its output instead of printing it.
- Loading branch information
Showing
11 changed files
with
376 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
package scala.tools.partest | ||
|
||
import scala.util.{Try,Success,Failure} | ||
import java.lang.System.{out => sysout} | ||
|
||
/** A trait for testing repl's javap command | ||
* or possibly examining its output. | ||
*/ | ||
abstract class JavapTest extends ReplTest { | ||
|
||
/** Your Assertion Here, whatever you want to bejahen. | ||
* Assertions must be satisfied by all flavors of javap | ||
* and should not be fragile with respect to compiler output. | ||
*/ | ||
def yah(res: Seq[String]): Boolean | ||
|
||
def baddies = List(":javap unavailable", ":javap not yet working") | ||
|
||
// give it a pass if javap is broken | ||
override def show() = try { | ||
val res = eval().toSeq | ||
val unsupported = res exists (s => baddies exists (s contains _)) | ||
assert ((unsupported || yah(res)), res.mkString("","\n","\n")) | ||
} catch { case ae: AssertionError => ae.printStackTrace(sysout) } | ||
} |
Oops, something went wrong.