Вопрос может рассматриваться в широком смысле, но, например, РЕПЛИ имеет некоторую поддержку javax.script
с контекстными привязками:
$ scala
Welcome to Scala version 2.11.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_11).
Type in expressions to have them evaluated.
Type :help for more information.
scala> val e = $intp.asInstanceOf[javax.script.ScriptEngine]
e: javax.script.ScriptEngine = [email protected]
scala> e.getContext
res0: javax.script.ScriptContext = [email protected]
scala> e.getContext.getScopes
res1: java.util.List[Integer] = [100, 200]
scala> e.getContext.getBindings(100)
res2: javax.script.Bindings = {}
И сама РЕПЛ держит сферу охвата, которая может быть запрошена, представляющей историю тока сеанс, который автоматически импортируется в текущую строку скрипта:
scala> $intp.replScope
res3: $intp.global.Scope = Scopes(value $intp, value e, value res0, value res1, value res2)
Это также можно осуществить механизм завершения Repl в:
scala> :power
** Power User mode enabled - BEEP WHIR GYVE **
** :phase has been set to 'typer'. **
** scala.tools.nsc._ has been imported **
** global._, definitions._ also imported **
** Try :help, :vals, power.<tab> **
scala> reader.completion
res4: scala.tools.nsc.interpreter.Completion = [email protected]
scala> res4.completer.complete("",0)
res6: scala.tools.nsc.interpreter.Completion.Candidates = Candidates(0,List($intp, $ires0, $ires1, $ires10, $ires11, $ires12, $ires13, $ires14, $ires15, $ires16, $ires17, $ires18, $ires2, $ires3, $ires4, $ires5, $ires6, $ires7, $ires8, $ires9, $r, AND, BLOCK, CASE, DEFAULT, FALSE, IF, LIT, NEW, NOT, NULL, REF, SOME, SelectStart, TRUE, TRY, UNIT, ZERO, analyzer, classOf, completion, e, fn, global, history, intp, isettings, lastRequest, mkTreeFromSelectStart, mkTreeMethods, mkTreeMethodsFromSelectStart, mkTreeMethodsFromSymbol, nullSafe, phased, power, r, reader, repl, replImplicits, res0, res1, res2, res3, res4, returning, scala$tools$nsc$ast$TreeDSL$CODE$$$outer, treedsl, typed, typer, vals))
scala>
Одна вкладка в консоли REPL предлагает функцию автозаполнения, которая здесь показывает все барахло в моей текущей директории, которая находится на пути к классу по умолчанию:
$ scala
Welcome to Scala version 2.11.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_11).
Type in expressions to have them evaluated.
Type :help for more information.
scala>
$intp broken enumtest inheritthewind maker oracle sbtbomb thingy
P bumper erased inlined mangled orelse scala throwgen
Q butwhen exh inliner mapeach org scallop thrownull
SO22581163 bytype eyeshadow inner maqicode othercase scrap tiles
_root_ callbacks fany inputcheck matchprim out scripts timezone
a capture featureless intcake maybeamb overdone searchme tmp
abjectfuture cce ff interp maykov overnullary selfpub toString
absval cdtest fielding interpat metamac pathmaker seqto tops
adaptation charmatch filloval intpbind mkarray peasy serialmigration trial
akka choosy filrdr intupolated mksym pet serious tribool
algedu classOf findwidgets invokeFrom modtest petconfig shapelessed tricks
angeldance classmatch finf isInstanceOf myanno phyl simple-swing trivial
annee classy fixedimp isanon mydays pickit singleton tryxform
annie cmpprs fixes isfun myintp pimpin slider tstest
annoconst coltfred fixme isscala mypkg pkginvoke slow typeref
annot com flib java mypriv plugincp smtest tztest
anymember compilit foodir javafx nestedmain plugs sobral unapplynull
anything convprs fooplus javax netscape pointers somatch unavail
applied copier for29 jbyte newfrom pointopt some_package unensured
arrow corner formac jdk nextcompleted pos sortitout unused
asInstanceOf counted ftw jex niolock poster sounds updater
atrait countints funk jext noany pow specbug valdef
autoenum cr funkstr jline noapp preferthunk speck vec
auxctor ctag futfilter jmap nodep prettycase splitat version
bad-scales curtest futuremap jover nofeature primover stale vowelshift
badXlint cyclic fval jperms nofuture printer statik w
badaccess dbadd gline junk noimp privctor str2int warnadapt
badbob default-tparam global k noinline privover strtyp weakerr
badgeneric delayed goodbye kcharex nointerp procked structural-return welper
badimp delayedsignal gr keptstar nonl protcase stupid whose
badinherit delineate grapher kmap norec protval succinctly widgets
badmap demoapi groupby lazyparadox nosehorn publicity sun wrappedarray
badmatch dep guiced lazyside nothingannot q superduper wtf
badover doc guy lazysplit ns qqparms sxema x
badoverride dockable halfinterval lib nts quickly syncd xmladd
badpath dosth here liner nullgroup quoterep syshook xmlex
badpkg doublearrow hidden linetest nullpair rawj t1 xmlregex
badseal dummyonly hiddenimport linted nulltype raws t1807 xmlreplace
badstrimp dynospec id linty nummaker reader t5148 xmlsub
badvargs earlier imparted lit off reflectenum t5589 xmlt
badvol eatery imparter littlecake oiler5 replslow t7121 xxx
bigmethod email impctx looker old-and-blue repro t7775 zed
binder empty impless lookit oldname required t8433
biterpolator emptypackage impmag lookup om sample-foo tabpane
blocking enclosing imptest loopy oneq samplewarn taggedparam
blownfuture enclosingcls imptrait macinfer oops saver target
bounded enpatch include macvar optdate sbt-test teachers
scala>
Среда REPL (где таковые могут возможно) отличается от отражения [Java/run-time] вообще (где такое невозможно). – user2864740
Что вам нужно - это инструмент с доступом ко всему исходному коду Java. Scala - не тот инструмент. См. Компилятор JavaC или ознакомьтесь с инструментами преобразования программ. –
Я хотел бы поблагодарить людей, чтобы они не меняли вопросы, которые я задаю. Корректировки форматирования велики, разъяснения велики. Но если вы хотите изменить вопрос, напишите один для себя. Речь идет о Scala в целом, а не только REPL. –