|
Java example source code file (MethodImpl.java)
The MethodImpl.java Java example source code
/*
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.tools.jdi;
import com.sun.jdi.*;
import java.util.List;
import java.util.Iterator;
import java.util.ArrayList;
import java.util.Comparator;
public abstract class MethodImpl extends TypeComponentImpl
implements Method {
private JNITypeParser signatureParser;
abstract int argSlotCount() throws AbsentInformationException;
abstract List<Location> allLineLocations(SDE.Stratum stratum,
String sourceName)
throws AbsentInformationException;
abstract List<Location> locationsOfLine(SDE.Stratum stratum,
String sourceName,
int lineNumber)
throws AbsentInformationException;
MethodImpl(VirtualMachine vm, ReferenceTypeImpl declaringType,
long ref,
String name, String signature,
String genericSignature, int modifiers) {
super(vm, declaringType, ref, name, signature,
genericSignature, modifiers);
signatureParser = new JNITypeParser(signature);
}
static MethodImpl createMethodImpl(VirtualMachine vm,
ReferenceTypeImpl declaringType,
long ref,
String name,
String signature,
String genericSignature,
int modifiers) {
if ((modifiers &
(VMModifiers.NATIVE | VMModifiers.ABSTRACT)) != 0) {
return new NonConcreteMethodImpl(vm, declaringType, ref,
name, signature,
genericSignature,
modifiers);
} else {
return new ConcreteMethodImpl(vm, declaringType, ref,
name, signature,
genericSignature,
modifiers);
}
}
public boolean equals(Object obj) {
if ((obj != null) && (obj instanceof MethodImpl)) {
MethodImpl other = (MethodImpl)obj;
return (declaringType().equals(other.declaringType())) &&
(ref() == other.ref()) &&
super.equals(obj);
} else {
return false;
}
}
public int hashCode() {
return (int)ref();
}
public final List<Location> allLineLocations()
throws AbsentInformationException {
return allLineLocations(vm.getDefaultStratum(), null);
}
public List<Location> allLineLocations(String stratumID,
String sourceName)
throws AbsentInformationException {
return allLineLocations(declaringType.stratum(stratumID),
sourceName);
}
public final List<Location> locationsOfLine(int lineNumber)
throws AbsentInformationException {
return locationsOfLine(vm.getDefaultStratum(),
null, lineNumber);
}
public List<Location> locationsOfLine(String stratumID,
String sourceName,
int lineNumber)
throws AbsentInformationException {
return locationsOfLine(declaringType.stratum(stratumID),
sourceName, lineNumber);
}
LineInfo codeIndexToLineInfo(SDE.Stratum stratum,
long codeIndex) {
if (stratum.isJava()) {
return new BaseLineInfo(-1, declaringType);
} else {
return new StratumLineInfo(stratum.id(), -1,
null, null);
}
}
/**
* @return a text representation of the declared return type
* of this method.
*/
public String returnTypeName() {
return signatureParser.typeName();
}
private String returnSignature() {
return signatureParser.signature();
}
public Type returnType() throws ClassNotLoadedException {
return findType(returnSignature());
}
public Type findType(String signature) throws ClassNotLoadedException {
ReferenceTypeImpl enclosing = (ReferenceTypeImpl)declaringType();
return enclosing.findType(signature);
}
public List<String> argumentTypeNames() {
return signatureParser.argumentTypeNames();
}
public List<String> argumentSignatures() {
return signatureParser.argumentSignatures();
}
Type argumentType(int index) throws ClassNotLoadedException {
ReferenceTypeImpl enclosing = (ReferenceTypeImpl)declaringType();
String signature = argumentSignatures().get(index);
return enclosing.findType(signature);
}
public List<Type> argumentTypes() throws ClassNotLoadedException {
int size = argumentSignatures().size();
ArrayList<Type> types = new ArrayList
Other Java examples (source code examples)Here is a short list of links related to this Java MethodImpl.java source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.