You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PrivilegeBeyondScope.java 636B

1234567891011121314151617181920212223242526
  1. import java.util.Observable;
  2. /** @testcase PR#906 privileged access out of code the compiler controls */
  3. public class PrivilegeBeyondScope {
  4. public static void main (String[] args) {
  5. new C().get();
  6. throw new Error("expected compiler error");
  7. }
  8. }
  9. class C {
  10. Object get() {return null;}
  11. }
  12. privileged aspect A {
  13. Observable observable = new Observable();
  14. after() returning (Object o ) :
  15. execution(Object C.get()) {
  16. observable.setChanged(); // CE 23 (unable to implement privilege outside C
  17. // CE unable to implement privilege outside code the compiler controls
  18. }
  19. }