< prev index next >

src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/Assumptions.java

Print this page


   1 /*
   2  * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


  81         public boolean canRecordTo(Assumptions target) {
  82             /*
  83              * We can use the result if it is either assumption free, or if we have a valid
  84              * Assumptions object where we can record assumptions.
  85              */
  86             return assumptions.length == 0 || target != null;
  87         }
  88 
  89         public void recordTo(Assumptions target) {
  90             assert canRecordTo(target);
  91 
  92             if (assumptions.length > 0) {
  93                 for (Assumption assumption : assumptions) {
  94                     target.record(assumption);
  95                 }
  96             }
  97         }
  98     }
  99 
 100     /**
 101      * An assumption that a given class has no subclasses implementing {@link Object#finalize()}).
 102      */
 103     public static final class NoFinalizableSubclass extends Assumption {
 104 
 105         private ResolvedJavaType receiverType;
 106 
 107         public NoFinalizableSubclass(ResolvedJavaType receiverType) {
 108             this.receiverType = receiverType;
 109         }
 110 
 111         @Override
 112         public int hashCode() {
 113             return 31 + receiverType.hashCode();
 114         }
 115 
 116         @Override
 117         public boolean equals(Object obj) {
 118             if (obj instanceof NoFinalizableSubclass) {
 119                 NoFinalizableSubclass other = (NoFinalizableSubclass) obj;
 120                 return other.receiverType.equals(receiverType);
 121             }


   1 /*
   2  * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


  81         public boolean canRecordTo(Assumptions target) {
  82             /*
  83              * We can use the result if it is either assumption free, or if we have a valid
  84              * Assumptions object where we can record assumptions.
  85              */
  86             return assumptions.length == 0 || target != null;
  87         }
  88 
  89         public void recordTo(Assumptions target) {
  90             assert canRecordTo(target);
  91 
  92             if (assumptions.length > 0) {
  93                 for (Assumption assumption : assumptions) {
  94                     target.record(assumption);
  95                 }
  96             }
  97         }
  98     }
  99 
 100     /**
 101      * An assumption that a given class has no subclasses implementing {@code Object#finalize()}).
 102      */
 103     public static final class NoFinalizableSubclass extends Assumption {
 104 
 105         private ResolvedJavaType receiverType;
 106 
 107         public NoFinalizableSubclass(ResolvedJavaType receiverType) {
 108             this.receiverType = receiverType;
 109         }
 110 
 111         @Override
 112         public int hashCode() {
 113             return 31 + receiverType.hashCode();
 114         }
 115 
 116         @Override
 117         public boolean equals(Object obj) {
 118             if (obj instanceof NoFinalizableSubclass) {
 119                 NoFinalizableSubclass other = (NoFinalizableSubclass) obj;
 120                 return other.receiverType.equals(receiverType);
 121             }


< prev index next >