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

Unified Diff: runtime/lib/mirrors.cc

Issue 1834673003: Do not compile a class when the class mirror tries to access the metadata. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: undo-changes Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/lib/mirrors/mirror_in_static_init_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/mirrors.cc
diff --git a/runtime/lib/mirrors.cc b/runtime/lib/mirrors.cc
index d24f75c992f6cc2c9502d72a34afc7faaf0a3b38..5127dce9addf9b97436566cd29b7ebdffac9ae26 100644
--- a/runtime/lib/mirrors.cc
+++ b/runtime/lib/mirrors.cc
@@ -333,12 +333,6 @@ static RawInstance* CreateClassMirror(const Class& cls,
return CreateTypedefMirror(cls, type, is_declaration, owner_mirror);
}
- const Error& error = Error::Handle(cls.EnsureIsFinalized(Thread::Current()));
- if (!error.IsNull()) {
- Exceptions::PropagateError(error);
- UNREACHABLE();
- }
-
const Array& args = Array::Handle(Array::New(9));
args.SetAt(0, MirrorReference::Handle(MirrorReference::New(cls)));
args.SetAt(1, type);
@@ -1471,6 +1465,12 @@ DEFINE_NATIVE_ENTRY(ClassMirror_invoke, 5) {
GET_NON_NULL_NATIVE_ARGUMENT(Array, args, arguments->NativeArgAt(3));
GET_NON_NULL_NATIVE_ARGUMENT(Array, arg_names, arguments->NativeArgAt(4));
+ const Error& error = Error::Handle(zone, klass.EnsureIsFinalized(thread));
+ if (!error.IsNull()) {
+ Exceptions::PropagateError(error);
+ UNREACHABLE();
+ }
+
Function& function = Function::Handle(
klass.LookupStaticFunction(function_name));
@@ -1543,6 +1543,11 @@ DEFINE_NATIVE_ENTRY(ClassMirror_invokeGetter, 3) {
// with its cousins.
GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1));
const Class& klass = Class::Handle(ref.GetClassReferent());
+ const Error& error = Error::Handle(zone, klass.EnsureIsFinalized(thread));
+ if (!error.IsNull()) {
+ Exceptions::PropagateError(error);
+ UNREACHABLE();
+ }
GET_NON_NULL_NATIVE_ARGUMENT(String, getter_name, arguments->NativeArgAt(2));
return InvokeClassGetter(klass, getter_name, true);
}
@@ -1557,6 +1562,12 @@ DEFINE_NATIVE_ENTRY(ClassMirror_invokeSetter, 4) {
GET_NON_NULL_NATIVE_ARGUMENT(String, setter_name, arguments->NativeArgAt(2));
GET_NATIVE_ARGUMENT(Instance, value, arguments->NativeArgAt(3));
+ const Error& error = Error::Handle(zone, klass.EnsureIsFinalized(thread));
+ if (!error.IsNull()) {
+ Exceptions::PropagateError(error);
+ UNREACHABLE();
+ }
+
// Check for real fields and user-defined setters.
const Field& field = Field::Handle(klass.LookupStaticField(setter_name));
Function& setter = Function::Handle();
@@ -1616,6 +1627,12 @@ DEFINE_NATIVE_ENTRY(ClassMirror_invokeConstructor, 5) {
GET_NON_NULL_NATIVE_ARGUMENT(Array, explicit_args, arguments->NativeArgAt(3));
GET_NON_NULL_NATIVE_ARGUMENT(Array, arg_names, arguments->NativeArgAt(4));
+ const Error& error = Error::Handle(zone, klass.EnsureIsFinalized(thread));
+ if (!error.IsNull()) {
+ Exceptions::PropagateError(error);
+ UNREACHABLE();
+ }
+
// By convention, the static function implementing a named constructor 'C'
// for class 'A' is labeled 'A.C', and the static function implementing the
// unnamed constructor for class 'A' is labeled 'A.'.
« no previous file with comments | « no previous file | tests/lib/mirrors/mirror_in_static_init_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698