Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Issue 61753019: Allow creation of public symbols using MirrorSystem.getSymbol when passing a null library. (Closed)

Created:
7 years, 1 month ago by rmacnak
Modified:
7 years, 1 month ago
Reviewers:
ahe, gbracha, siva
CC:
reviews_dartlang.org, vm-dev_dartlang.org
Visibility:
Public.

Description

Allow creation of public symbols using MirrorSystem.getSymbol when passing a null library. R=asiva@google.com, gbracha@google.com Committed: https://code.google.com/p/dart/source/detail?r=30435

Patch Set 1 #

Patch Set 2 : #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+7 lines, -2 lines) Patch
M runtime/lib/mirrors_patch.dart View 1 2 chunks +1 line, -2 lines 2 comments Download
M tests/lib/mirrors/private_symbol_test.dart View 1 chunk +6 lines, -0 lines 0 comments Download

Messages

Total messages: 6 (0 generated)
rmacnak
7 years, 1 month ago (2013-11-19 01:20:08 UTC) #1
gbracha
tests lgtm
7 years, 1 month ago (2013-11-19 01:52:06 UTC) #2
rmacnak
https://codereview.chromium.org/61753019/diff/50001/runtime/lib/mirrors_patch.dart File runtime/lib/mirrors_patch.dart (left): https://codereview.chromium.org/61753019/diff/50001/runtime/lib/mirrors_patch.dart#oldcode5 runtime/lib/mirrors_patch.dart:5: import "dart:nativewrappers"; We haven't needed this since the introduction ...
7 years, 1 month ago (2013-11-20 00:27:46 UTC) #3
siva
lgtm
7 years, 1 month ago (2013-11-20 01:17:54 UTC) #4
rmacnak
Committed patchset #2 manually as r30435 (presubmit successful).
7 years, 1 month ago (2013-11-20 01:33:29 UTC) #5
ahe
7 years, 1 month ago (2013-11-21 09:07:02 UTC) #6
Message was sent while issue was closed.
https://codereview.chromium.org/61753019/diff/50001/runtime/lib/mirrors_patch...
File runtime/lib/mirrors_patch.dart (right):

https://codereview.chromium.org/61753019/diff/50001/runtime/lib/mirrors_patch...
runtime/lib/mirrors_patch.dart:80: if ((library != null && library is!
_LocalLibraryMirror) ||
Why are you checking for is! _LocalLibraryMirror?

My understanding is that it is too protect _mangleName from being called with
anything that isn't a _MirrorReference.

Using reflection, I can instantiate _LocalLibraryMirror and ensure it has a
bogus value for the field _reflectee. I believe I can provoke a crash that way
if Mirrors_mangleName makes too many assumptions. I'd argue that you should
remove the type test here and replace line 84 with:

if (library != null) {
  name = _mangleName(name, library._reflectee as _MirrorReference);
}

However, if _mangleName is so brittle, then you probably also need to write:

if (library != null) {
  name = _mangleName(name as String, library._reflectee as _MirrorReference);
}

If _mangleName is an instance method on _MirrorReference, you can reduce this
to:

if (library != null) {
  name = library._reflectee._mangleName(name as String);
}

Regardless, _mangleName can be invoked reflectively, so it should probably be
checking for String in C++, so really the first lines of this method should just
be:

if (library != null) {
  name = library._reflectee._mangleName(name);
} else if (name.startsWith('_')) {
  throw new ArgumentError("'$name' is private so this method needs a library");
}

Powered by Google App Engine
This is Rietveld 408576698