JDK 11 jdk.jdeps.jmod - JDeps Tool

JDK 11 jdk.jdeps.jmod is the JMOD file for JDK 11 JDeps tool, which can be invoked by the "jdeps" command.

JDK 11 JDeps tool compiled class files are stored in \fyicenter\jdk-11.0.1\jmods\jdk.jdeps.jmod.

JDK 11 JDeps tool compiled class files are also linked and stored in the \fyicenter\jdk-11.0.1\lib\modules JImage file.

JDK 11 JDeps tool source code files are stored in \fyicenter\jdk-11.0.1\lib\src.zip\jdk.jdeps.

You can click and view the content of each source code file in the list below.

✍: FYIcenter

com/sun/tools/javap/CodeWriter.java

/*
 * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */

package com.sun.tools.javap;

import java.util.ArrayList;
import java.util.List;

import com.sun.tools.classfile.AccessFlags;
import com.sun.tools.classfile.Code_attribute;
import com.sun.tools.classfile.ConstantPool;
import com.sun.tools.classfile.ConstantPoolException;
import com.sun.tools.classfile.DescriptorException;
import com.sun.tools.classfile.Instruction;
import com.sun.tools.classfile.Instruction.TypeKind;
import com.sun.tools.classfile.Method;

/*
 *  Write the contents of a Code attribute.
 *
 *  <p><b>This is NOT part of any supported API.
 *  If you write code that depends on this, you do so at your own risk.
 *  This code and its internal interfaces are subject to change or
 *  deletion without notice.</b>
 */
public class CodeWriter extends BasicWriter {
    public static CodeWriter instance(Context context) {
        CodeWriter instance = context.get(CodeWriter.class);
        if (instance == null)
            instance = new CodeWriter(context);
        return instance;
    }

    protected CodeWriter(Context context) {
        super(context);
        context.put(CodeWriter.class, this);
        attrWriter = AttributeWriter.instance(context);
        classWriter = ClassWriter.instance(context);
        constantWriter = ConstantWriter.instance(context);
        sourceWriter = SourceWriter.instance(context);
        tryBlockWriter = TryBlockWriter.instance(context);
        stackMapWriter = StackMapWriter.instance(context);
        localVariableTableWriter = LocalVariableTableWriter.instance(context);
        localVariableTypeTableWriter = LocalVariableTypeTableWriter.instance(context);
        typeAnnotationWriter = TypeAnnotationWriter.instance(context);
        options = Options.instance(context);
    }

    void write(Code_attribute attr, ConstantPool constant_pool) {
        println("Code:");
        indent(+1);
        writeVerboseHeader(attr, constant_pool);
        writeInstrs(attr);
        writeExceptionTable(attr);
        attrWriter.write(attr, attr.attributes, constant_pool);
        indent(-1);
    }

    public void writeVerboseHeader(Code_attribute attr, ConstantPool constant_pool) {
        Method method = classWriter.getMethod();
        String argCount;
        try {
            int n = method.descriptor.getParameterCount(constant_pool);
            if (!method.access_flags.is(AccessFlags.ACC_STATIC))
                ++n;  // for 'this'
            argCount = Integer.toString(n);
        } catch (ConstantPoolException e) {
            argCount = report(e);
        } catch (DescriptorException e) {
            argCount = report(e);
        }

        println("stack=" + attr.max_stack +
                ", locals=" + attr.max_locals +
                ", args_size=" + argCount);

    }

    public void writeInstrs(Code_attribute attr) {
        List<InstructionDetailWriter> detailWriters = getDetailWriters(attr);

        for (Instruction instr: attr.getInstructions()) {
            try {
                for (InstructionDetailWriter w: detailWriters)
                    w.writeDetails(instr);
                writeInstr(instr);
            } catch (ArrayIndexOutOfBoundsException e) {
                println(report("error at or after byte " + instr.getPC()));
                break;
            }
        }

        for (InstructionDetailWriter w: detailWriters)
            w.flush();
    }

    public void writeInstr(Instruction instr) {
        print(String.format("%4d: %-13s ", instr.getPC(), instr.getMnemonic()));
        // compute the number of indentations for the body of multi-line instructions
        // This is 6 (the width of "%4d: "), divided by the width of each indentation level,
        // and rounded up to the next integer.
        int indentWidth = options.indentWidth;
        int indent = (6 + indentWidth - 1) / indentWidth;
        instr.accept(instructionPrinter, indent);
        println();
    }
    // where
    Instruction.KindVisitor<Void,Integer> instructionPrinter =
            new Instruction.KindVisitor<Void,Integer>() {

        public Void visitNoOperands(Instruction instr, Integer indent) {
            return null;
        }

        public Void visitArrayType(Instruction instr, TypeKind kind, Integer indent) {
            print(" " + kind.name);
            return null;
        }

        public Void visitBranch(Instruction instr, int offset, Integer indent) {
            print((instr.getPC() + offset));
            return null;
        }

        public Void visitConstantPoolRef(Instruction instr, int index, Integer indent) {
            print("#" + index);
            tab();
            print("// ");
            printConstant(index);
            return null;
        }

        public Void visitConstantPoolRefAndValue(Instruction instr, int index, int value, Integer indent) {
            print("#" + index + ",  " + value);
            tab();
            print("// ");
            printConstant(index);
            return null;
        }

        public Void visitLocal(Instruction instr, int index, Integer indent) {
            print(index);
            return null;
        }

        public Void visitLocalAndValue(Instruction instr, int index, int value, Integer indent) {
            print(index + ", " + value);
            return null;
        }

        public Void visitLookupSwitch(Instruction instr,
                int default_, int npairs, int[] matches, int[] offsets, Integer indent) {
            int pc = instr.getPC();
            print("{ // " + npairs);
            indent(indent);
            for (int i = 0; i < npairs; i++) {
                print(String.format("%n%12d: %d", matches[i], (pc + offsets[i])));
            }
            print("\n     default: " + (pc + default_) + "\n}");
            indent(-indent);
            return null;
        }

        public Void visitTableSwitch(Instruction instr,
                int default_, int low, int high, int[] offsets, Integer indent) {
            int pc = instr.getPC();
            print("{ // " + low + " to " + high);
            indent(indent);
            for (int i = 0; i < offsets.length; i++) {
                print(String.format("%n%12d: %d", (low + i), (pc + offsets[i])));
            }
            print("\n     default: " + (pc + default_) + "\n}");
            indent(-indent);
            return null;
        }

        public Void visitValue(Instruction instr, int value, Integer indent) {
            print(value);
            return null;
        }

        public Void visitUnknown(Instruction instr, Integer indent) {
            return null;
        }
    };


    public void writeExceptionTable(Code_attribute attr) {
        if (attr.exception_table_length > 0) {
            println("Exception table:");
            indent(+1);
            println(" from    to  target type");
            for (int i = 0; i < attr.exception_table.length; i++) {
                Code_attribute.Exception_data handler = attr.exception_table[i];
                print(String.format(" %5d %5d %5d",
                        handler.start_pc, handler.end_pc, handler.handler_pc));
                print("   ");
                int catch_type = handler.catch_type;
                if (catch_type == 0) {
                    println("any");
                } else {
                    print("Class ");
                    println(constantWriter.stringValue(catch_type));
                }
            }
            indent(-1);
        }

    }

    private void printConstant(int index) {
        constantWriter.write(index);
    }

    private List<InstructionDetailWriter> getDetailWriters(Code_attribute attr) {
        List<InstructionDetailWriter> detailWriters = new ArrayList<>();
        if (options.details.contains(InstructionDetailWriter.Kind.SOURCE)) {
            sourceWriter.reset(classWriter.getClassFile(), attr);
            if (sourceWriter.hasSource())
                detailWriters.add(sourceWriter);
            else
                println("(Source code not available)");
        }

        if (options.details.contains(InstructionDetailWriter.Kind.LOCAL_VARS)) {
            localVariableTableWriter.reset(attr);
            detailWriters.add(localVariableTableWriter);
        }

        if (options.details.contains(InstructionDetailWriter.Kind.LOCAL_VAR_TYPES)) {
            localVariableTypeTableWriter.reset(attr);
            detailWriters.add(localVariableTypeTableWriter);
        }

        if (options.details.contains(InstructionDetailWriter.Kind.STACKMAPS)) {
            stackMapWriter.reset(attr);
            stackMapWriter.writeInitialDetails();
            detailWriters.add(stackMapWriter);
        }

        if (options.details.contains(InstructionDetailWriter.Kind.TRY_BLOCKS)) {
            tryBlockWriter.reset(attr);
            detailWriters.add(tryBlockWriter);
        }

        if (options.details.contains(InstructionDetailWriter.Kind.TYPE_ANNOS)) {
            typeAnnotationWriter.reset(attr);
            detailWriters.add(typeAnnotationWriter);
        }

        return detailWriters;
    }

    private AttributeWriter attrWriter;
    private ClassWriter classWriter;
    private ConstantWriter constantWriter;
    private LocalVariableTableWriter localVariableTableWriter;
    private LocalVariableTypeTableWriter localVariableTypeTableWriter;
    private TypeAnnotationWriter typeAnnotationWriter;
    private SourceWriter sourceWriter;
    private StackMapWriter stackMapWriter;
    private TryBlockWriter tryBlockWriter;
    private Options options;
}

com/sun/tools/javap/CodeWriter.java

 

Or download all of them as a single archive file:

File name: jdk.jdeps-11.0.1-src.zip
File size: 244145 bytes
Release date: 2018-11-04
Download 

 

JDK 11 jdk.jdi.jmod - JDI Tool

JDK 11 jdk.jconsole.jmod - JConsole Tool

Download and Use JDK 11

⇑⇑ FAQ for JDK (Java Development Kit)

2020-07-07, 32065👍, 0💬