1 /* 2 * Copyright (c) 2010, 2012, 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 package com.sun.java.util.jar.pack; 26 27 import com.sun.java.util.jar.pack.ConstantPool.ClassEntry; 28 import com.sun.java.util.jar.pack.ConstantPool.DescriptorEntry; 29 import com.sun.java.util.jar.pack.ConstantPool.LiteralEntry; 30 import com.sun.java.util.jar.pack.ConstantPool.MemberEntry; 31 import com.sun.java.util.jar.pack.ConstantPool.MethodHandleEntry; 32 import com.sun.java.util.jar.pack.ConstantPool.MethodTypeEntry; 33 import com.sun.java.util.jar.pack.ConstantPool.InvokeDynamicEntry; 34 import com.sun.java.util.jar.pack.ConstantPool.BootstrapMethodEntry; 35 import com.sun.java.util.jar.pack.ConstantPool.SignatureEntry; 36 import com.sun.java.util.jar.pack.ConstantPool.Utf8Entry; 37 import java.util.HashMap; 38 import java.util.Map; 39 import java.util.SortedMap; 40 41 /* 42 * @author ksrini 43 */ 44 45 /* 46 * This class provides a container to hold the global variables, for packer 47 * and unpacker instances. This is typically stashed away in a ThreadLocal, 48 * and the storage is destroyed upon completion. Therefore any local 49 * references to these members must be eliminated appropriately to prevent a 50 * memory leak. 51 */ 52 class TLGlobals { 53 // Global environment 54 final PropMap props; 55 56 // Needed by ConstantPool.java 57 private final Map<String, Utf8Entry> utf8Entries; 58 private final Map<String, ClassEntry> classEntries; 59 private final Map<Object, LiteralEntry> literalEntries; 60 private final Map<String, SignatureEntry> signatureEntries; 61 private final Map<String, DescriptorEntry> descriptorEntries; 62 private final Map<String, MemberEntry> memberEntries; 63 private final Map<String, MethodHandleEntry> methodHandleEntries; 64 private final Map<String, MethodTypeEntry> methodTypeEntries; 65 private final Map<String, InvokeDynamicEntry> invokeDynamicEntries; 66 private final Map<String, BootstrapMethodEntry> bootstrapMethodEntries; 67 TLGlobals()68 TLGlobals() { 69 utf8Entries = new HashMap<>(); 70 classEntries = new HashMap<>(); 71 literalEntries = new HashMap<>(); 72 signatureEntries = new HashMap<>(); 73 descriptorEntries = new HashMap<>(); 74 memberEntries = new HashMap<>(); 75 methodHandleEntries = new HashMap<>(); 76 methodTypeEntries = new HashMap<>(); 77 invokeDynamicEntries = new HashMap<>(); 78 bootstrapMethodEntries = new HashMap<>(); 79 props = new PropMap(); 80 } 81 getPropMap()82 SortedMap<String, String> getPropMap() { 83 return props; 84 } 85 getUtf8Entries()86 Map<String, Utf8Entry> getUtf8Entries() { 87 return utf8Entries; 88 } 89 getClassEntries()90 Map<String, ClassEntry> getClassEntries() { 91 return classEntries; 92 } 93 getLiteralEntries()94 Map<Object, LiteralEntry> getLiteralEntries() { 95 return literalEntries; 96 } 97 getDescriptorEntries()98 Map<String, DescriptorEntry> getDescriptorEntries() { 99 return descriptorEntries; 100 } 101 getSignatureEntries()102 Map<String, SignatureEntry> getSignatureEntries() { 103 return signatureEntries; 104 } 105 getMemberEntries()106 Map<String, MemberEntry> getMemberEntries() { 107 return memberEntries; 108 } 109 getMethodHandleEntries()110 Map<String, MethodHandleEntry> getMethodHandleEntries() { 111 return methodHandleEntries; 112 } 113 getMethodTypeEntries()114 Map<String, MethodTypeEntry> getMethodTypeEntries() { 115 return methodTypeEntries; 116 } 117 getInvokeDynamicEntries()118 Map<String, InvokeDynamicEntry> getInvokeDynamicEntries() { 119 return invokeDynamicEntries; 120 } 121 getBootstrapMethodEntries()122 Map<String, BootstrapMethodEntry> getBootstrapMethodEntries() { 123 return bootstrapMethodEntries; 124 } 125 } 126