Skip to main content

ClassConstraintException

com.sun.org.apache.bcel.internal.verifier.exc.ClassConstraintException

ClassConstraintException is described in the javadoc comments as:

Instances of this class are thrown by BCEL's class file verifier 'JustIce' when a class file to verify does not pass the verification pass 2 as described in the Java Virtual Machine specification, 2nd edition.
version: $Id: ClassConstraintException.java,v 1.1.1.1 2001/10/29 20:00:33 jvanzyl Exp $ author: Enver Haase

Where is this exception thrown?

Following, is a list of exception messages cross-referenced to the source code responsible for throwing them. Click on the method link to view the code and see how the exception is thrown.

How is this exception thrown?

The following sub-sections identify where this exception is thrown, and how (or why) the code is throwing the exception.

Any source code quoted in this section is subject to the Java Research License unless stated otherwise.

com.sun.org.apache.bcel.internal.verifier.statics.Pass2Verifier.every_class_has_an_accessible_superclass()

/**
  * Ensures that every class has a super class and that
  * <B>final</B> classes are not subclassed.
  * This means, the class this Pass2Verifier operates
  * on has proper super classes (transitively) up to
  * java.lang.Object.
  * The reason for really loading (and Pass1-verifying)
  * all of those classes here is that we need them in
  * Pass2 anyway to verify no final methods are overridden
  * (that could be declared anywhere in the ancestor hierarchy).
  *
  * @throws ClassConstraintException otherwise.
  */
private void every_class_has_an_accessible_superclass() {
    HashSet hs = new HashSet();
    JavaClass jc = Repository.lookupClass(myOwner.getClassName());
    int supidx = -1;
    while (supidx != 0) {
        supidx = jc.getSuperclassNameIndex();
        if (supidx == 0) {
            if (jc != Repository.lookupClass(Type.OBJECT.getClassName())) {
                throw new ClassConstraintException('Superclass of '' + jc.getClassName() + '' missing but not ' + Type.OBJECT.getClassName() + ' itself!');
            }
        } else {
            String supername = jc.getSuperclassName();
            if (!hs.add(supername)) {
                throw new ClassConstraintException('Circular superclass hierarchy detected.');
            }
            Verifier v = VerifierFactory.getVerifier(supername);
            VerificationResult vr = v.doPass1();
            if (vr != VerificationResult.VR_OK) {
                throw new ClassConstraintException('Could not load in ancestor class '' + supername + ''.');
            }
            jc = Repository.lookupClass(supername);
            if (jc.isFinal()) {
                throw new ClassConstraintException('Ancestor class '' + supername + '' has the FINAL access modifier and must therefore not be subclassed.');
            }
        }
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

com.sun.org.apache.bcel.internal.verifier.statics.Pass3aVerifier.delayedPass2Checks()

/**
  * These are the checks that could be done in pass 2 but are delayed to pass 3
  * for performance reasons. Also, these checks need access to the code array
  * of the Code attribute of a Method so it's okay to perform them here.
  * Also see the description of the do_verify() method.
  *
  * @throws ClassConstraintException if the verification fails.
  * @see #do_verify()
  */
private void delayedPass2Checks() {
    int[] instructionPositions = instructionList.getInstructionPositions();
    int codeLength = code.getCode().length;
    LineNumberTable lnt = code.getLineNumberTable();
    if (lnt != null) {
        LineNumber[] lineNumbers = lnt.getLineNumberTable();
        IntList offsets = new IntList();
        lineNumber_loop: for (int i = 0; i < lineNumbers.length; i++) {
            for (int j = 0; j < instructionPositions.length; j++) {
                int offset = lineNumbers[i].getStartPC();
                if (instructionPositions[j] == offset) {
                    if (offsets.contains(offset)) {
                        addMessage('LineNumberTable attribute '' + code.getLineNumberTable() + '' refers to the same code offset ('' + offset + '') more than once which is violating the semantics [but is sometimes produced by IBM's 'jikes' compiler].');
                    } else {
                        offsets.add(offset);
                    }
                    continue lineNumber_loop;
                }
            }
            throw new ClassConstraintException('Code attribute '' + code + '' has a LineNumberTable attribute '' + code.getLineNumberTable() + '' referring to a code offset ('' + lineNumbers[i].getStartPC() + '') that does not exist.');
        }
    }
    Attribute[] atts = code.getAttributes();
    for (int a = 0; a < atts.length; a++) {
        if (atts[a] instanceof LocalVariableTable) {
            LocalVariableTable lvt = (LocalVariableTable) atts[a];
            if (lvt != null) {
                LocalVariable[] localVariables = lvt.getLocalVariableTable();
                for (int i = 0; i < localVariables.length; i++) {
                    int startpc = localVariables[i].getStartPC();
                    int length = localVariables[i].getLength();
                    if (!contains(instructionPositions, startpc)) {
                        throw new ClassConstraintException('Code attribute '' + code + '' has a LocalVariableTable attribute '' + code.getLocalVariableTable() + '' referring to a code offset ('' + startpc + '') that does not exist.');
                    }
                    if ((!contains(instructionPositions, startpc + length)) && (startpc + length != codeLength)) {
                        throw new ClassConstraintException('Code attribute '' + code + '' has a LocalVariableTable attribute '' + code.getLocalVariableTable() + '' referring to a code offset start_pc+length ('' + (startpc + length) + '') that does not exist.');
                    }
                }
            }
        }
    }
    CodeException[] exceptionTable = code.getExceptionTable();
    for (int i = 0; i < exceptionTable.length; i++) {
        int startpc = exceptionTable[i].getStartPC();
        int endpc = exceptionTable[i].getEndPC();
        int handlerpc = exceptionTable[i].getHandlerPC();
        if (startpc >= endpc) {
            throw new ClassConstraintException('Code attribute '' + code + '' has an exception_table entry '' + exceptionTable[i] + '' that has its start_pc ('' + startpc + '') not smaller than its end_pc ('' + endpc + '').');
        }
        if (!contains(instructionPositions, startpc)) {
            throw new ClassConstraintException('Code attribute '' + code + '' has an exception_table entry '' + exceptionTable[i] + '' that has a non-existant bytecode offset as its start_pc ('' + startpc + '').');
        }
        if ((!contains(instructionPositions, endpc)) && (endpc != codeLength)) {
            throw new ClassConstraintException('Code attribute '' + code + '' has an exception_table entry '' + exceptionTable[i] + '' that has a non-existant bytecode offset as its end_pc ('' + startpc + '') [that is also not equal to code_length ('' + codeLength + '')].');
        }
        if (!contains(instructionPositions, handlerpc)) {
            throw new ClassConstraintException('Code attribute '' + code + '' has an exception_table entry '' + exceptionTable[i] + '' that has a non-existant bytecode offset as its handler_pc ('' + handlerpc + '').');
        }
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

com.sun.org.apache.bcel.internal.verifier.statics.Pass2Verifier.final_methods_are_not_overridden()

/**
  * Ensures that <B>final</B> methods are not overridden.
  * <B>Precondition to run this method:
  * constant_pool_entries_satisfy_static_constraints() and
  * every_class_has_an_accessible_superclass() have to be invoked before
  * (in that order).</B>
  *
  * @throws ClassConstraintException otherwise.
  * @see #constant_pool_entries_satisfy_static_constraints()
  * @see #every_class_has_an_accessible_superclass()
  */
private void final_methods_are_not_overridden() {
    HashMap hashmap = new HashMap();
    JavaClass jc = Repository.lookupClass(myOwner.getClassName());
    int supidx = -1;
    while (supidx != 0) {
        supidx = jc.getSuperclassNameIndex();
        ConstantPoolGen cpg = new ConstantPoolGen(jc.getConstantPool());
        Method[] methods = jc.getMethods();
        for (int i = 0; i < methods.length; i++) {
            String name_and_sig = (methods[i].getName() + methods[i].getSignature());
            if (hashmap.containsKey(name_and_sig)) {
                if (methods[i].isFinal()) {
                    throw new ClassConstraintException('Method '' + name_and_sig + '' in class '' + hashmap.get(name_and_sig) + '' overrides the final (not-overridable) definition in class '' + jc.getClassName() + ''.');
                } else {
                    if (!methods[i].isStatic()) {
                        hashmap.put(name_and_sig, jc.getClassName());
                    }
                }
            } else {
                if (!methods[i].isStatic()) {
                    hashmap.put(name_and_sig, jc.getClassName());
                }
            }
        }
        jc = Repository.lookupClass(jc.getSuperclassName());
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

Comments

Popular posts from this blog

BAD_CERTIFICATE - A corrupt or unuseable certificate...

This is a simple symptom-cause-solution blog entry only. I hope these blogs will help fellow administrators.
Symptom
In wls_utc, when trying to test a webservice using SSL, the following error message is received: javax.net.ssl.SSLKeyException: FATAL Alert:BAD_CERTIFICATE - A corrupt or unuseable certificate was received.
If SSL debugging is enabled, the following error also appears in the logs: ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)' <1254822672320>>
verification failed because RSA key public exponent [3] is too small
Cause
The certificate encryption is of a weaker strength than expected by newer versions of Java.
Solution
Add the flag "-Dweblogic.security.SSL.allowSmallRSAExponent=true" to the server startup parameters.
References


None.

Connection refused: No available router to destination

This is a simple symptom-cause-solution blog entry only. I hope these blogs will help fellow administrators.
Symptom

The following exception occurs in WebLogic server logs. Most likely to occur during WebLogic server start-up, but similar exceptions may occur at other times.
java.net.ConnectException: t3://myserver:8000: Destination unreachable; nested exception is: java.net.ConnectException: Connection refused: connect; No available router to destination] at weblogic.jndi.internal.ExceptionTranslator.toNamingException(ExceptionTranslator.java:49) at weblogic.jndi.WLInitialContextFactoryDelegate.toNamingException(WLInitialContextFactoryDelegate.java:773) at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:363) at weblogic.jndi.Environment.getContext(Environment.java:307) at weblogic.jndi.Environment.getContext(Environment.java:277)
Cause
This message (Connection refused: connect; No available router to destination) is a kind of "catch…

BEASVC.EXE - WebLogic as a Windows Service

I remember the first time I had to work out why WebLogic wouldn't run as a service. It was a frustrating experience. There were no error messages. No Windows error dialog. No console output.

How do you troubleshoot something like this??!!

This short article will show you. For simplicity I'll talk about the node manager, but the same principles apply for running an admin or managed server as a service.

First Steps

First, you still have your server logs. Sure the console output is better, but it's a starting point. Check this log for errors and especially take note of the start up variables such as PATH and CLASSPATH. If the server log isn't being created, that tells you WebLogic probably isn't even being started. (Check that you have a license file if you haven't already.)

Ok, so the logs were no help. The next step is to look at how the service is trying to start WebLogic.

When you install WebLogic as a service, you're really setting up beasvc.exe as the service.…