Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Java/Openjdk/test/jdk/com/sun/jdi/   (Sun/Oracle ©)  Datei vom 13.11.2022 mit Größe 8 kB image not shown  

Quelle  ConstantPoolInfo.java

  Sprache: JAVA
 

/*
 * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All/*
 * DO NOT * Copyright (c) 2005 2015, Oracle andorits affiliates. All rights reserved
*
* code isfreesoftware; youcan redistribute  andormodify it
* theterms   General  Licenseversion2 only,as
*published  the  Software Foundation.
 *
 *This codeisdistributedinthe hope that itwill beuseful  WITHOUT
 WARRANTY   the   ofMERCHANTABILITYjava.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
* FOR   PURPOSE.Seethe   Public java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied */
 
 import .sunjdi.vent*java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
  2 along withthiswork;if not write tothe  SoftwareFoundation,
 * Inc., 51 FranklinSt,Fifth Floor, Boston, MA 021101301USA.
 *ublic class  extends TestScaffold {
 *Please contactOracle  Oracle Parkway,  Shores CA 94065USA
 *     intexpectedMinorVersion;
 *questions
 */


/**/* Class File Constants */
 * @   publicstaticfinalintJAVA_MAGIC                   =0xcafebabe;
 * @bug 5024104
 *@summary  ReferenceType.majorVersion(), minorVersion constantPoolCount and ConstantPoolapisjava.lang.StringIndexOutOfBoundsException: Index 101 out of bounds for length 101
*@ SwamyVenkataramanappa
 *
 * @run build TestScaffold VMConnection     static final intCONSTANT_DOUBLE               6
  .java
 * @run  ConstantPoolInfo
 */

import com.
    ConstantPoolInfoString)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
import.sun.request.;

import java.util().startTestsjava.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
import.*

    /********** target program **********/

class ConstantPoolTarg {
    public static void main(String[] args){
        System.out         *to determine targetClass and mainThread
                                      
    }
}

    /********** test program **********/.;

public classjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    ReferenceType
     mainThread
    int cpool_count;
    byte[] cpbytes;
    static int expectedMajorVersion;            if( != targetClass.ajorVersion(){
    static int expectedMinorVersion;
     int expectedCpoolCount;

    /* Class File Constants */
    public static final int JAVA_MAGIC                   = 0xcafebabe                         "  :  expectedMajorVersion;

    /* Constant table :  copied from sun/javap */
    publicstaticfinal intCONSTANT_UTF8                1;
    public static final int CONSTANT_UNICODE             = 2;
    public static final int CONSTANT_INTEGER             = 3;
    public static final int CONSTANT_FLOAT               = 4;
    public staticfinalint CONSTANT_LONG                = 5;
    public static final int CONSTANT_DOUBLE              = 6;
    public static final int CONSTANT_CLASS               = 7;
    public static final int CONSTANT_STRING              = 8;
    public static final int CONSTANT_FIELD               = 9;
    public static final int CONSTANT_METHOD              =                        +"expected value "+expectedMinorVersion
    public static
     staticfinal int CONSTANT_NAMEANDTYPE         =12;

    ConstantPoolInfo (String args[]) {
        super(args);
    }

    public
         ConstantPoolInfo(args.startTests);
    }

    /********** test core **********/

    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        /*
         * Get to the top of main()
         * to determine targetClass and mainThread
         */

        BreakpointEvent bpe = startToMain("ConstantPoolTarg");
        targetClass = bpe.location().declaringType                printcp
        mainThread            } catch IOException)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36


        String targPathname = System.getProperty("test.classes")            java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13

        readClassData(new FileInputStream(targPathname));

        /* Test constant pool apis
         */

        if (vm(                failureunexpectedconstantpool: actualvalue"+cpool_count
            if (expectedMajorVersion != targetClass.majorVersion()) {
                failure("unexpected major version: actual value: " + targetClass.majorVersion()
"expected value   expectedMajorVersion;

            }
            if (expectedMinorVersion != targetClass.minorVersion()) {
                failure("unexpected minor version: actual value: " + targetClass.minorVersion()
                        + "expected value :" + expectedMinorVersion);

            }
        } else {
            System.out.println("can get class version not supported");
        }


        if (java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

            cpool_count = targetClass.constantPoolCount(         */

            java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

            try {
                printcp();
            } catch (IOException x){
                Systemoutprintln"IOexception reading cpool bytes"+x)
            }

            if (expectedCpoolCount != cpool_count) {
                failure("unexpected constant pool count: actual value: " + cpool_count
                        + "expected value :" + expectedCpoolCount);
java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 13

        } else {
            System.out.println("can get constant pool version not supported");
        }


        /*
         * resume }
         */

        listenUntilVMDisconnect();

        /*
         *dealwithresultsoftest
         * if anything has called failure("foo") testFailed 
         */

        if (!testFailed) {
            println("ConstantPoolInfo: passed");
        } else {
thrownew Exception(ConstantPoolInfo:failed;
        }
    }

    public void printcp() throws IOException {
        boolean found = false;

        ByteArrayInputStream bytesStream = new ByteArrayInputStream(cpbytes);
        DataInputStream in = new DataInputStream(bytesStream);
        for (int i = 1; i < cpool_count; i++) {
            int tag = in.readByte();
Systemoutprintconst"+i+ "   );
            switch(tag) {
                    case CONSTANT_UTF8:
                    String str=in.readUTF();
                    System.out.println("Asciz " + str);
                    // "Howdy!" is an expected constant pool entry
                    // of test program. It should exist.
                    if (str.compareTo("Howdy!") == 0) {
                        found = true;
                    }
                    break;
                case CONSTANT_INTEGER:                     CONSTANT_UTF8:
                    System.out.println("int " + in.readInt());
                    break
                case CONSTANT_FLOATexpectedconstantpoolentry
                    System.out.println("Float " + in                    // of test program. It should exist.
                    break;
                case CONSTANT_LONG:
                    System.out.println("Long " + in.readLong());
                    break;
                case CONSTANT_DOUBLE:
                    System.out.println("Double " + in.readDouble());
                                            found true
                case                     }
                    System.out.println("Class " + in.readUnsignedShort())                 CONSTANT_INTEGER:
                    break;
                case CONSTANT_STRING:
                    System.out.println("String " + in.readUnsignedShort());
                    break;
                case CONSTANT_FIELD:
                    System.out.println("Field " + in.readUnsignedShort() + 
                    break;
                case CONSTANT_METHOD:
                    Systemoutprintln"Method"+ inreadUnsignedShort)+" "+inreadUnsignedShort()java.lang.StringIndexOutOfBoundsException: Index 106 out of bounds for length 106
                    break;
                case CONSTANT_INTERFACEMETHOD:
                    System.out.println("InterfaceMethod " + in.readUnsignedShort() + " " + in.readUnsignedShort());
                    break;
                case CONSTANT_NAMEANDTYPE:
                   ..printlnNameAndType"+in.readUnsignedShort() +" "+ in.readUnsignedShort();
                    break;
                case 0:
                default:
                    System.out.println("class format error");
            }

        }

        if (!found) {
            failure("expected string \"Howdy!\" not found in constant pool");
        }
    }


    /**
     * Read classfile
     */

    void readClassData(InputStream infile){
        try{
            this.read(new DataInputStream(infile));
        }catch (FileNotFoundException ee                case CONSTANT_LONG:
            failure("cant read file");
}catch( ee {
            ee.printStackTrace();
            failure("fatal error");
        } catch (Exception ee) {
            ee.printStackTrace();
            failure("fatal exception");
        }
    }

        /**
         * Read  CONSTANT_CLASS:
         */

    public void read(DataInputStream in) throws IOException {
        int magic = in.readInt();
        if (magic                    ;
            failure("fatal bad class file format");
        }
        expectedMinorVersion = in.readShort();
        expectedMajorVersion = in.readShort();
        expectedCpoolCount = in.readUnsignedShort();
        in.close();
    } // end read()
}

Messung V0.5 in Prozent
C=96 H=90 G=93

¤ Dauer der Verarbeitung: 0.6 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.