All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.aspectj.apache.bcel.classfile.MethodParameters Maven / Gradle / Ivy

/* *******************************************************************
 * Copyright (c) 2013 VMware
 *
 * All rights reserved.
 * This program and the accompanying materials are made available
 * under the terms of the Eclipse Public License v 2.0
 * which accompanies this distribution and is available at
 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
 *
 * Contributors:
 *    Andy Clement     initial implementation
 * ******************************************************************/
package org.aspectj.apache.bcel.classfile;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

import org.aspectj.apache.bcel.Constants;

// see http://cr.openjdk.java.net/~abuckley/8misc.pdf
public class MethodParameters extends Attribute {

	public final static int[] NO_PARAMETER_NAME_INDEXES = new int[0];
	public final static int[] NO_PARAMETER_ACCESS_FLAGS = new int[0];

	public final static int ACCESS_FLAGS_FINAL     = 0x0010;
	public final static int ACCESS_FLAGS_SYNTHETIC = 0x1000;
	public final static int ACCESS_FLAGS_MANDATED  = 0x8000;

	// if 'isInPackedState' then this data needs unpacking
	private boolean isInPackedState = false;
	private byte[] data;
	private int[] names;
	private int[] accessFlags;

	public MethodParameters(int index, int length, DataInputStream dis, ConstantPool cpool) throws IOException {
		super(Constants.ATTR_METHOD_PARAMETERS,index,length,cpool);
		data = new byte[length];
		dis.readFully(data,0,length);
		isInPackedState = true;
	}

	private void ensureInflated() {
		if (names!=null) return;
		try {
			DataInputStream dis = new DataInputStream(new ByteArrayInputStream(data));
			int parametersCount = dis.readUnsignedByte();
			if (parametersCount == 0) {
				names = NO_PARAMETER_NAME_INDEXES;
				accessFlags = NO_PARAMETER_ACCESS_FLAGS;
			} else {
				names = new int[parametersCount];
				accessFlags = new int[parametersCount];
				for (int i=0;i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy