test/jdk/java/lang/invoke/InvokeDynamicPrintArgs.java
changeset 55462 6dfdcd31463d
parent 47216 71c04702a3d5
equal deleted inserted replaced
55461:e764228f71dc 55462:6dfdcd31463d
     1 /*
     1 /*
     2  * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   232         if (System.getProperty("InvokeDynamicPrintArgs.allow-untransformed") != null)  return;
   232         if (System.getProperty("InvokeDynamicPrintArgs.allow-untransformed") != null)  return;
   233         throw new AssertionError("this code should be statically transformed away by Indify");
   233         throw new AssertionError("this code should be statically transformed away by Indify");
   234     }
   234     }
   235 
   235 
   236     static class TestPolicy extends Policy {
   236     static class TestPolicy extends Policy {
       
   237         static final Policy DEFAULT_POLICY = Policy.getPolicy();
       
   238 
   237         final PermissionCollection permissions = new Permissions();
   239         final PermissionCollection permissions = new Permissions();
   238         TestPolicy() {
   240         TestPolicy() {
   239             permissions.add(new java.io.FilePermission("<<ALL FILES>>", "read"));
   241             permissions.add(new java.io.FilePermission("<<ALL FILES>>", "read"));
   240         }
   242         }
   241         public PermissionCollection getPermissions(ProtectionDomain domain) {
   243         public PermissionCollection getPermissions(ProtectionDomain domain) {
   245         public PermissionCollection getPermissions(CodeSource codesource) {
   247         public PermissionCollection getPermissions(CodeSource codesource) {
   246             return permissions;
   248             return permissions;
   247         }
   249         }
   248 
   250 
   249         public boolean implies(ProtectionDomain domain, Permission perm) {
   251         public boolean implies(ProtectionDomain domain, Permission perm) {
   250             return permissions.implies(perm);
   252             return permissions.implies(perm) || DEFAULT_POLICY.implies(domain, perm);
   251         }
   253         }
   252     }
   254     }
   253 }
   255 }