1 /*
   2  * Copyright (c) 2014, 2015, Dynatrace and/or its affiliates. All rights reserved.
   3  * 
   4  * This file is part of the Lock Contention Tracing Subsystem for the HotSpot
   5  * Virtual Machine, which is developed at Christian Doppler Laboratory on
   6  * Monitoring and Evolution of Very-Large-Scale Software Systems. Please
   7  * contact us at <http://mevss.jku.at/> if you need additional information
   8  * or have any questions.
   9  *
  10  * This code is free software; you can redistribute it and/or modify it
  11  * under the terms of the GNU General Public License version 2 only, as
  12  * published by the Free Software Foundation.
  13  *
  14  * This code is distributed in the hope that it will be useful, but WITHOUT
  15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  16  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  17  * version 2 for more details (a copy is included in the LICENSE file that
  18  * accompanied this code).
  19  *
  20  * You should have received a copy of the GNU General Public License version
  21  * 2 along with this work. If not, see <http://www.gnu.org/licenses/>.
  22  *
  23  */ 
  24 package sun.evtracing.processing.statistics.metadata;
  25 
  26 import java.util.Arrays;
  27 
  28 public abstract class JavaObjectStack {
  29 
  30         public static final JavaObjectStack HIDDEN = new JavaObjectArrayStack(0) {
  31                 @Override
  32                 public boolean equals(Object obj) {
  33                         return (this == obj);
  34                 }
  35         };
  36 
  37         public abstract JavaObject top();
  38 
  39         public abstract JavaObject[] objects();
  40 
  41         public abstract void setObject(int number, JavaObject obj);
  42 
  43         public abstract JavaClassStack getClassStack();
  44 
  45         @Override
  46         public int hashCode() {
  47                 return Arrays.hashCode(objects());
  48         }
  49 
  50         @Override
  51         public boolean equals(Object obj) {
  52                 if (this == obj) {
  53                         return true;
  54                 }
  55                 if (obj instanceof JavaObjectStack) {
  56                         JavaObjectStack other = (JavaObjectStack) obj;
  57                         return Arrays.equals(objects(), other.objects());
  58                 }
  59                 return false;
  60         }
  61 }