src/share/vm/runtime/reflection.cpp

changeset 1100
c89f86385056
parent 866
a45484ea312d
child 1577
4ce7240d622c
     1.1 --- a/src/share/vm/runtime/reflection.cpp	Thu Mar 19 09:13:24 2009 -0700
     1.2 +++ b/src/share/vm/runtime/reflection.cpp	Fri Mar 20 23:19:36 2009 -0700
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -554,10 +554,18 @@
    1.11    return instanceKlass::cast(class1)->is_same_class_package(class2);
    1.12  }
    1.13  
    1.14 +bool Reflection::is_same_package_member(klassOop class1, klassOop class2, TRAPS) {
    1.15 +  return instanceKlass::cast(class1)->is_same_package_member(class2, THREAD);
    1.16 +}
    1.17 +
    1.18  
    1.19  // Checks that the 'outer' klass has declared 'inner' as being an inner klass. If not,
    1.20  // throw an incompatible class change exception
    1.21 -void Reflection::check_for_inner_class(instanceKlassHandle outer, instanceKlassHandle inner, TRAPS) {
    1.22 +// If inner_is_member, require the inner to be a member of the outer.
    1.23 +// If !inner_is_member, require the inner to be anonymous (a non-member).
    1.24 +// Caller is responsible for figuring out in advance which case must be true.
    1.25 +void Reflection::check_for_inner_class(instanceKlassHandle outer, instanceKlassHandle inner,
    1.26 +                                       bool inner_is_member, TRAPS) {
    1.27    const int inner_class_info_index = 0;
    1.28    const int outer_class_info_index = 1;
    1.29  
    1.30 @@ -567,7 +575,7 @@
    1.31       int ioff = icls->ushort_at(i + inner_class_info_index);
    1.32       int ooff = icls->ushort_at(i + outer_class_info_index);
    1.33  
    1.34 -     if (ioff != 0 && ooff != 0) {
    1.35 +     if (inner_is_member && ioff != 0 && ooff != 0) {
    1.36          klassOop o = cp->klass_at(ooff, CHECK);
    1.37          if (o == outer()) {
    1.38            klassOop i = cp->klass_at(ioff, CHECK);
    1.39 @@ -576,6 +584,13 @@
    1.40            }
    1.41          }
    1.42       }
    1.43 +     if (!inner_is_member && ioff != 0 && ooff == 0 &&
    1.44 +         cp->klass_name_at_matches(inner, ioff)) {
    1.45 +        klassOop i = cp->klass_at(ioff, CHECK);
    1.46 +        if (i == inner()) {
    1.47 +          return;
    1.48 +        }
    1.49 +     }
    1.50    }
    1.51  
    1.52    // 'inner' not declared as an inner klass in outer

mercurial