Everything necessary for this is in place. Full example looks like this:
import 'dart:mirrors';
class Foo {
final foo;
Foo(this.foo);
String toString() => 'foo $foo';
}
main() {
var mirrors = currentMirrorSystem();
var lib = mirrors.libraries['file:///home/ladicek/work/dart/projects/playground/mirrors.dart'];
var fooClass = lib.classes['Foo'];
fooClass.newInstance('', ['bar']).then((fooInstance) {
print('foo = ${fooInstance.reflectee}');
});
}
But, eh, the library URI in the code... there used to be a MirrorSystem.rootLibrary getter, but that seems to be gone. Can anyone comment on that?
Also, if I print a map of libraries (print mirrors.libraries), I get
{dart:collection: LibraryMirror on 'dart:collection', dart:io: LibraryMirror on 'dart:io', dart:isolate: LibraryMirror on 'dart:isolate', dart:mirrors: LibraryMirror on 'dart:mirrors', dart:async: LibraryMirror on 'dart:async', dart.json: LibraryMirror on 'dart.json', dart:nativewrappers: LibraryMirror on 'dart:nativewrappers', crypto: LibraryMirror on 'crypto', dart:math: LibraryMirror on 'dart:math', dart:core: LibraryMirror on 'dart:core', builtin: LibraryMirror on 'builtin', utf: LibraryMirror on 'utf', dart:scalarlist: LibraryMirror on 'dart:scalarlist', dart.uri: LibraryMirror on 'dart.uri', file:///home/ladicek/work/dart/projects/playground/mirrors-new.dart: LibraryMirror on 'file:///home/ladicek/work/dart/projects/playground/mirrors-new.dart'}
The keys are pretty inconsistent. The dart:core library is keyed by dart:core, dart:json by dart.json, dart:utf by utf... That is more than work in progress :-) I'm SO not going to post this on StackOverflow.
LT