1 /* 2 * Copyright (c) 2016, 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. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package jdk.jfr.internal; 27 28 import java.util.List; 29 import java.util.Map; 30 31 import jdk.jfr.AnnotationElement; 32 import jdk.jfr.Configuration; 33 import jdk.jfr.EventType; 34 import jdk.jfr.FlightRecorderPermission; 35 import jdk.jfr.Recording; 36 import jdk.jfr.SettingDescriptor; 37 import jdk.jfr.ValueDescriptor; 38 39 /** 40 * Provides access to package private function in jdk.jfr. 41 * <p> 42 * The static initializer in this class loads the Settings class, which will 43 * call {@link #setPrivateAccess(PrivateAccess)} on this class, which can be 44 * used call to package protected methods. 45 * 46 * This is similar to how java.lang accesses package private methods in 47 * java.lang.reflect. 48 */ 49 public abstract class PrivateAccess { 50 private volatile static PrivateAccess instance; 51 getInstance()52 public static PrivateAccess getInstance() { 53 // Can't be initialized in <clinit> because it may 54 // deadlock with FlightRecordeerPermission.<clinit> 55 if (instance == null) { 56 // Will trigger 57 // FlightRecordeerPermission.<clinit> 58 // which will call PrivateAccess.setPrivateAccess 59 new FlightRecorderPermission(Utils.REGISTER_EVENT); 60 } 61 return instance; 62 } 63 setPrivateAccess(PrivateAccess pa)64 public static void setPrivateAccess(PrivateAccess pa) { 65 instance = pa; 66 } 67 getType(Object o)68 public abstract Type getType(Object o); 69 newConfiguration(String name, String label, String description, String provider, Map<String,String> settings, String contents)70 public abstract Configuration newConfiguration(String name, String label, String description, String provider, Map<String,String> settings, String contents); 71 newEventType(PlatformEventType eventTypes)72 public abstract EventType newEventType(PlatformEventType eventTypes); 73 newAnnotation(Type annotationType, List<Object> values, boolean boot)74 public abstract AnnotationElement newAnnotation(Type annotationType, List<Object> values, boolean boot); 75 newValueDescriptor(String name, Type fieldType, List<AnnotationElement> annotations, int dimension, boolean constantPool, String fieldName)76 public abstract ValueDescriptor newValueDescriptor(String name, Type fieldType, List<AnnotationElement> annotations, int dimension, boolean constantPool, String fieldName); 77 getPlatformRecording(Recording r)78 public abstract PlatformRecording getPlatformRecording(Recording r); 79 getPlatformEventType(EventType eventType)80 public abstract PlatformEventType getPlatformEventType(EventType eventType); 81 isConstantPool(ValueDescriptor v)82 public abstract boolean isConstantPool(ValueDescriptor v); 83 getFieldName(ValueDescriptor v)84 public abstract String getFieldName(ValueDescriptor v); 85 newValueDescriptor(Class<?> type, String name)86 public abstract ValueDescriptor newValueDescriptor(Class<?> type, String name); 87 newSettingDescriptor(Type type, String name, String def, List<AnnotationElement> aes)88 public abstract SettingDescriptor newSettingDescriptor(Type type, String name, String def, List<AnnotationElement> aes); 89 setAnnotations(ValueDescriptor v, List<AnnotationElement> a)90 public abstract void setAnnotations(ValueDescriptor v, List<AnnotationElement> a); 91 setAnnotations(SettingDescriptor s, List<AnnotationElement> a)92 public abstract void setAnnotations(SettingDescriptor s, List<AnnotationElement> a); 93 isUnsigned(ValueDescriptor v)94 public abstract boolean isUnsigned(ValueDescriptor v); 95 getPlatformRecorder()96 public abstract PlatformRecorder getPlatformRecorder(); 97 } 98