1 /*
   2  * Copyright (c) 2014, 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  */
  23 package jdk.vm.ci.hotspot.services;
  24 
  25 /**
  26  * An empty implementation for {@link EventProvider}. This implementation is used when no logging is
  27  * requested.
  28  */
  29 final class EmptyEventProvider extends EventProvider {
  30 
  31     EmptyEventProvider() {
  32         super(null);
  33     }
  34 
  35     static InternalError shouldNotReachHere() {
  36         throw new InternalError("should not reach here");
  37     }
  38 
  39     @Override
  40     public CompilationEvent newCompilationEvent() {
  41         return new EmptyCompilationEvent();
  42     }
  43 
  44     static class EmptyCompilationEvent implements CompilationEvent {
  45         public void commit() {
  46             throw shouldNotReachHere();
  47         }
  48 
  49         public boolean shouldWrite() {
  50             // Events of this class should never been written.
  51             return false;
  52         }
  53 
  54         public void begin() {
  55         }
  56 
  57         public void end() {
  58         }
  59 
  60         public void setMethod(String method) {
  61             throw shouldNotReachHere();
  62         }
  63 
  64         public void setCompileId(int compileId) {
  65             throw shouldNotReachHere();
  66         }
  67 
  68         public void setCompileLevel(int compileLevel) {
  69             throw shouldNotReachHere();
  70         }
  71 
  72         public void setSucceeded(boolean succeeded) {
  73             throw shouldNotReachHere();
  74         }
  75 
  76         public void setIsOsr(boolean isOsr) {
  77             throw shouldNotReachHere();
  78         }
  79 
  80         public void setCodeSize(int codeSize) {
  81             throw shouldNotReachHere();
  82         }
  83 
  84         public void setInlinedBytes(int inlinedBytes) {
  85             throw shouldNotReachHere();
  86         }
  87     }
  88 
  89     @Override
  90     public CompilerFailureEvent newCompilerFailureEvent() {
  91         return new EmptyCompilerFailureEvent();
  92     }
  93 
  94     static class EmptyCompilerFailureEvent implements CompilerFailureEvent {
  95         public void commit() {
  96             throw shouldNotReachHere();
  97         }
  98 
  99         public boolean shouldWrite() {
 100             // Events of this class should never been written.
 101             return false;
 102         }
 103 
 104         public void setCompileId(int compileId) {
 105             throw shouldNotReachHere();
 106         }
 107 
 108         public void setMessage(String message) {
 109             throw shouldNotReachHere();
 110         }
 111     }
 112 
 113 }