Path: blob/master/src/jdk.jdi/share/classes/com/sun/tools/jdi/ModuleReferenceImpl.java
41171 views
/*1* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.sun.tools.jdi;2627import com.sun.jdi.ClassLoaderReference;28import com.sun.jdi.ModuleReference;29import com.sun.jdi.VirtualMachine;3031class ModuleReferenceImpl extends ObjectReferenceImpl implements ModuleReference {3233protected ModuleReferenceImpl(VirtualMachine aVm, long aRef) {34super(aVm, aRef);35}3637protected String description() {38return "ModuleReference " + ref();39}4041private String name;42private ClassLoaderReference classLoader;4344private boolean cachedName = false;45private boolean cachedClassLoader = false;464748public synchronized String name() {49if (cachedName) {50return name;51}52try {53name = JDWP.ModuleReference.Name.process(this.vm, this).name;54if (name != null && name.length() == 0) {55// The JDWP returns empty name for unnamed modules56name = null;57}58cachedName = true;59} catch (JDWPException ex) {60throw ex.toJDIException();61}62return name;63}6465public synchronized ClassLoaderReference classLoader() {66if (cachedClassLoader) {67return classLoader;68}69try {70classLoader = JDWP.ModuleReference.ClassLoader.71process(this.vm, this).classLoader;72cachedClassLoader = true;73} catch (JDWPException ex) {74throw ex.toJDIException();75}76return classLoader;77}78}798081