Skip to main content

ClassCastException

java.lang.ClassCastException

ClassCastException is described in the javadoc comments as:

Thrown to indicate that the code has attempted to cast an object to a subclass of which it is not an instance. For example, the following code generates a ClassCastException:

   Object x = new Integer(0);   System.out.println((String)x); 

author: unascribed version: 1.20, 12/19/03 since: JDK1.0

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.xml.internal.dtm.ref.dom2dtm.DOM2DTM.addNode(Node, int, int, int)

/**
   * Construct the node map from the node.
   * @param node The node that is to be added to the DTM.
   * @param parentIndex The current parent index.
   * @param previousSibling The previous sibling index.
   * @param forceNodeType If not DTM.NULL, overrides the DOM node type.
   * Used to force nodes to Text rather than CDATASection when their
   * coalesced value includes ordinary Text nodes (current DTM behavior).
   * @return The index identity of the node that was added.
   */
protected int addNode(Node node, int parentIndex, int previousSibling, int forceNodeType) {
    int nodeIndex = m_nodes.size();
    if (m_dtmIdent.size() == (nodeIndex >>> DTMManager.IDENT_DTM_NODE_BITS)) {
        try {
            if (m_mgr == null) throw new ClassCastException();
            DTMManagerDefault mgrD = (DTMManagerDefault) m_mgr;
            int id = mgrD.getFirstFreeDTMID();
            mgrD.addDTM(this, id, nodeIndex);
            m_dtmIdent.addElement(id << DTMManager.IDENT_DTM_NODE_BITS);
        } catch (ClassCastException e) {
            error(XMLMessages.createXMLMessage(XMLErrorResources.ER_NO_DTMIDS_AVAIL, null));
        }
    }
    m_size++;
    int type;
    if (NULL == forceNodeType) type = node.getNodeType(); else type = forceNodeType;
    if (Node.ATTRIBUTE_NODE == type) {
        String name = node.getNodeName();
        if (name.startsWith('xmlns:') || name.equals('xmlns')) {
            type = DTM.NAMESPACE_NODE;
        }
    }
    m_nodes.addElement(node);
    m_firstch.setElementAt(NOTPROCESSED, nodeIndex);
    m_nextsib.setElementAt(NOTPROCESSED, nodeIndex);
    m_prevsib.setElementAt(previousSibling, nodeIndex);
    m_parent.setElementAt(parentIndex, nodeIndex);
    if (DTM.NULL != parentIndex && type != DTM.ATTRIBUTE_NODE && type != DTM.NAMESPACE_NODE) {
        if (NOTPROCESSED == m_firstch.elementAt(parentIndex)) m_firstch.setElementAt(nodeIndex, parentIndex);
    }
    String nsURI = node.getNamespaceURI();
    String localName = (type == Node.PROCESSING_INSTRUCTION_NODE) ? node.getNodeName() : node.getLocalName();
    if (((type == Node.ELEMENT_NODE) || (type == Node.ATTRIBUTE_NODE)) && null == localName) localName = node.getNodeName();
    ExpandedNameTable exnt = m_expandedNameTable;
    if (node.getLocalName() == null && (type == Node.ELEMENT_NODE || type == Node.ATTRIBUTE_NODE)) {
    }
    int expandedNameID = (null != localName) ? exnt.getExpandedTypeID(nsURI, localName, type) : exnt.getExpandedTypeID(type);
    m_exptype.setElementAt(expandedNameID, nodeIndex);
    indexNode(expandedNameID, nodeIndex);
    if (DTM.NULL != previousSibling) m_nextsib.setElementAt(nodeIndex, previousSibling);
    if (type == DTM.NAMESPACE_NODE) declareNamespaceInContext(parentIndex, nodeIndex);
    return nodeIndex;
}

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.xml.internal.dtm.ref.sax2dtm.SAX2DTM.addNewDTMID(int)

/**
   * Get a new DTM ID beginning at the specified node index.
   * @param  nodeIndex The node identity at which the new DTM ID will begin
   * addressing.
   */
protected void addNewDTMID(int nodeIndex) {
    try {
        if (m_mgr == null) throw new ClassCastException();
        DTMManagerDefault mgrD = (DTMManagerDefault) m_mgr;
        int id = mgrD.getFirstFreeDTMID();
        mgrD.addDTM(this, id, nodeIndex);
        m_dtmIdent.addElement(id << DTMManager.IDENT_DTM_NODE_BITS);
    } catch (ClassCastException e) {
        error(XMLMessages.createXMLMessage(XMLErrorResources.ER_NO_DTMIDS_AVAIL, null));
    }
}

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

java.io.ObjectInputStream.defaultReadFields(Object, ObjectStreamClass)

/**
     * Reads in values of serializable fields declared by given class
     * descriptor.  If obj is non-null, sets field values in obj.  Expects that
     * passHandle is set to obj's handle before this method is called.
     */
private void defaultReadFields(Object obj, ObjectStreamClass desc) throws IOException {
    Class cl = desc.forClass();
    if (cl != null && obj != null && !cl.isInstance(obj)) {
        throw new ClassCastException();
    }
    int primDataSize = desc.getPrimDataSize();
    if (primVals == null || primVals.length < primDataSize) {
        primVals = new byte[primDataSize];
    }
    bin.readFully(primVals, 0, primDataSize, false);
    if (obj != null) {
        desc.setPrimFieldValues(obj, primVals);
    }
    int objHandle = passHandle;
    ObjectStreamField[] fields = desc.getFields(false);
    Object[] objVals = new Object[desc.getNumObjFields()];
    int numPrimFields = fields.length - objVals.length;
    for (int i = 0; i < objVals.length; i++) {
        ObjectStreamField f = fields[numPrimFields + i];
        objVals[i] = readObject0(f.isUnshared());
        if (f.getField() != null) {
            handles.markDependency(objHandle, passHandle);
        }
    }
    if (obj != null) {
        desc.setObjFieldValues(obj, objVals);
    }
    passHandle = objHandle;
}

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

java.lang.Class.cast(Object)

/**
     * Casts an object to the class or interface represented
     * by this <tt>Class</tt> object.
     * @param obj the object to be cast
     * @return the object after casting, or null if obj is null
     * @throws ClassCastException if the object is not
     * null and is not assignable to the type T.
     * @since 1.5
     */
public T cast(Object obj) {
    if (obj != null && !isInstance(obj)) throw new ClassCastException();
    return (T) obj;
}

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

java.lang.Enum.compareTo(E)

/**
     * Compares this enum with the specified object for order.  Returns a
     * negative integer, zero, or a positive integer as this object is less
     * than, equal to, or greater than the specified object.
     * Enum constants are only comparable to other enum constants of the
     * same enum type.  The natural order implemented by this
     * method is the order in which the constants are declared.
     */
public final int compareTo(E o) {
    Enum other = (Enum) o;
    Enum self = this;
    if (self.getClass() != other.getClass() && self.getDeclaringClass() != other.getDeclaringClass()) throw new ClassCastException();
    return self.ordinal - other.ordinal;
}

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

javax.swing.LayoutComparator.compare(Object, Object)

public int compare(Object o1, Object o2) {
    Component a = (Component) o1;
    Component b = (Component) o2;
    if (a == b) {
        return 0;
    }
    if (a.getParent() != b.getParent()) {
        LinkedList aAncestory, bAncestory;
        for (aAncestory = new LinkedList(); a != null; a = a.getParent()) {
            aAncestory.add(a);
            if (a instanceof Window) {
                break;
            }
        }
        if (a == null) {
            throw new ClassCastException();
        }
        for (bAncestory = new LinkedList(); b != null; b = b.getParent()) {
            bAncestory.add(b);
            if (b instanceof Window) {
                break;
            }
        }
        if (b == null) {
            throw new ClassCastException();
        }
        for (ListIterator aIter = aAncestory.listIterator(aAncestory.size()), bIter = bAncestory.listIterator(bAncestory.size()); ; ) {
            if (aIter.hasPrevious()) {
                a = (Component) aIter.previous();
            } else {
                return -1;
            }
            if (bIter.hasPrevious()) {
                b = (Component) bIter.previous();
            } else {
                return 1;
            }
            if (a != b) {
                break;
            }
        }
    }
    int ax = a.getX(), ay = a.getY(), bx = b.getX(), by = b.getY();
    int zOrder = a.getParent().getComponentZOrder(a) - b.getParent().getComponentZOrder(b);
    if (horizontal) {
        if (leftToRight) {
            if (Math.abs(ay - by) < ROW_TOLERANCE) {
                return (ax < bx) ? -1 : ((ax > bx) ? 1 : zOrder);
            } else {
                return (ay < by) ? -1 : 1;
            }
        } else {
            if (Math.abs(ay - by) < ROW_TOLERANCE) {
                return (ax > bx) ? -1 : ((ax < bx) ? 1 : zOrder);
            } else {
                return (ay < by) ? -1 : 1;
            }
        }
    } else {
        if (leftToRight) {
            if (Math.abs(ax - bx) < ROW_TOLERANCE) {
                return (ay < by) ? -1 : ((ay > by) ? 1 : zOrder);
            } else {
                return (ax < bx) ? -1 : 1;
            }
        } else {
            if (Math.abs(ax - bx) < ROW_TOLERANCE) {
                return (ay < by) ? -1 : ((ay > by) ? 1 : zOrder);
            } else {
                return (ax > bx) ? -1 : 1;
            }
        }
    }
}

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

javax.swing.JScrollPane.setLayout(LayoutManager)

/** 
     * Sets the layout manager for this <code>JScrollPane</code>.
     * This method overrides <code>setLayout</code> in
     * <code>java.awt.Container</code> to ensure that only
     * <code>LayoutManager</code>s which
     * are subclasses of <code>ScrollPaneLayout</code> can be used in a
     * <code>JScrollPane</code>. If <code>layout</code> is non-null, this
     * will invoke <code>syncWithScrollPane</code> on it.
     * @param layout the specified layout manager
     * @exception ClassCastException if layout is not a
     *   <code>ScrollPaneLayout</code>
     * @see java.awt.Container#getLayout
     * @see java.awt.Container#setLayout
     * @beaninfo
     *    hidden: true
     */
public void setLayout(LayoutManager layout) {
    if (layout instanceof ScrollPaneLayout) {
        super.setLayout(layout);
        ((ScrollPaneLayout) layout).syncWithScrollPane(this);
    } else if (layout == null) {
        super.setLayout(layout);
    } else {
        String s = 'layout of JScrollPane must be a ScrollPaneLayout';
        throw new ClassCastException(s);
    }
}

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

java.util.EnumMap.typeCheck(K)

/**
     * Throws an exception if e is not of the correct type for this enum set.
     */
private void typeCheck(K key) {
    Class keyClass = key.getClass();
    if (keyClass != keyType && keyClass.getSuperclass() != keyType) throw new ClassCastException(keyClass + ' != ' + keyType);
}

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

java.util.EnumSet.typeCheck(E)

/**
     * Throws an exception if e is not of the correct type for this enum set.
     */
final void typeCheck(E e) {
    Class eClass = e.getClass();
    if (eClass != elementType && eClass.getSuperclass() != elementType) throw new ClassCastException(eClass + ' != ' + elementType);
}

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

com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(java.lang.Object, java.lang.Class)

/**
     * Checks to ensure that an object of a remote or abstract interface type
     * can be cast to a desired type.
     * @param narrowFrom the object to check.
     * @param narrowTo the desired type.
     * @return an object which can be cast to the desired type.
     * @throws ClassCastException if narrowFrom cannot be cast to narrowTo.
     */
public java.lang.Object narrow(java.lang.Object narrowFrom, java.lang.Class narrowTo) throws ClassCastException {
    java.lang.Object result = null;
    if (narrowFrom == null) return null;
    if (narrowTo == null) throw new NullPointerException('invalid argument');
    try {
        if (narrowTo.isAssignableFrom(narrowFrom.getClass())) return narrowFrom;
        if (narrowTo.isInterface() && narrowTo != java.io.Serializable.class && narrowTo != java.io.Externalizable.class) {
            org.omg.CORBA.Object narrowObj = (org.omg.CORBA.Object) narrowFrom;
            String id = RepositoryId.createForAnyType(narrowTo);
            if (narrowObj._is_a(id)) {
                return Utility.loadStub(narrowObj, narrowTo);
            } else {
                throw new ClassCastException('Object is not of remote type ' + narrowTo.getName());
            }
        } else {
            throw new ClassCastException('Class ' + narrowTo.getName() + ' is not a valid remote interface');
        }
    } catch (Exception error) {
        ClassCastException cce = new ClassCastException();
        cce.initCause(error);
        throw cce;
    }
}

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

javax.management.openmbean.TabularDataSupport.putAll(Map)

/**
     * Add all the values contained in the specified map <var>t</var> to this <tt>TabularData</tt> instance. 
     * This method converts the collection of values contained in this map into an array of <tt>CompositeData</tt> values,
     * if possible, and then call the method <tt>putAll(CompositeData[])</tt>. Note that the keys used in the specified
     * map <var>t</var> are ignored. This method allows, for example to add the content of another <tt>TabularData</tt> 
     * instance with the same row type (but possibly different index names) into this instance.
     * @param  t  the map whose values are to be added as new rows to this <tt>TabularData</tt> instance;
     *    if <var>t</var> is <tt>null</tt> or empty, this method returns without doing anything.
     * @throws NullPointerException  if a value in <var>t</var> is <tt>null</tt>.
     * @throws ClassCastException    if a value in <var>t</var> is not an instance of <tt>CompositeData</tt>.
     * @throws InvalidOpenTypeException   if a value in <var>t</var> does not conform to 
     *       this <tt>TabularData</tt> instance's row type definition.
     * @throws KeyAlreadyExistsException  if the index for a value in <var>t</var>, calculated according to 
     *       this <tt>TabularData</tt> instance's <tt>TabularType</tt> definition 
     *       already maps to an existing value in this instance,
     *       or two values in <var>t</var> have the same index.
     */
public void putAll(Map t) {
    if ((t == null) || (t.size() == 0)) {
        return;
    }
    CompositeData[] values;
    try {
        values = (CompositeData[]) t.values().toArray(new CompositeData[t.size()]);
    } catch (java.lang.ArrayStoreException e) {
        throw new ClassCastException('Map argument t contains values which are not instances of <tt>CompositeData</tt>');
    }
    putAll(values);
}

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

javax.naming.CompositeName.compareTo(Object)

/**
     * Compares this CompositeName with the specified Object for order.  
     * Returns a
     * negative integer, zero, or a positive integer as this Name is less
     * than, equal to, or greater than the given Object.
     * If obj is null or not an instance of CompositeName, ClassCastException
     * is thrown.
     * See equals() for what it means for two composite names to be equal.
     * If two composite names are equal, 0 is returned.
     * Ordering of composite names follows the lexicographical rules for
     * string comparison, with the extension that this applies to all
     * the components in the composite name. The effect is as if all the
     * components were lined up in their specified ordered and the
     * lexicographical rules applied over the two line-ups.
     * If this composite name is 'lexicographically' lesser than obj,
     * a negative number is returned.
     * If this composite name is 'lexicographically' greater than obj,
     * a positive number is returned.
     * @param obj The non-null object to compare against.
     * @return  a negative integer, zero, or a positive integer as this Name
     *  is less than, equal to, or greater than the given Object.
     * @exception ClassCastException if obj is not a CompositeName.
     */
public int compareTo(Object obj) {
    if (!(obj instanceof CompositeName)) {
        throw new ClassCastException('Not a CompositeName');
    }
    return impl.compareTo(((CompositeName) obj).impl);
}

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

javax.naming.CompoundName.compareTo(Object)

/**
     * Compares this CompoundName with the specified Object for order.  
     * Returns a
     * negative integer, zero, or a positive integer as this Name is less
     * than, equal to, or greater than the given Object. 
     * If obj is null or not an instance of CompoundName, ClassCastException
     * is thrown.
     * See equals() for what it means for two compound names to be equal.
     * If two compound names are equal, 0 is returned.
     * Ordering of compound names depend on the syntax of the compound name.
     * By default, they follow lexicographical rules for string comparison
     * with the extension that this applies to all the components in the
     * compound name and that comparison of individual components is
     * affected by the jndi.syntax.ignorecase and jndi.syntax.trimblanks
     * properties, identical to how they affect equals().
     * If this compound name is 'lexicographically' lesser than obj,
     * a negative number is returned.
     * If this compound name is 'lexicographically' greater than obj,
     * a positive number is returned.
     * Implementation note: Currently the syntax properties of the two compound
     * names are not compared when checking order. They might be in the future.
     * @param obj The non-null object to compare against.
     * @return  a negative integer, zero, or a positive integer as this Name
     *  is less than, equal to, or greater than the given Object.
     * @exception ClassCastException if obj is not a CompoundName.
     * @see #equals(java.lang.Object)
     */
public int compareTo(Object obj) {
    if (!(obj instanceof CompoundName)) {
        throw new ClassCastException('Not a CompoundName');
    }
    return impl.compareTo(((CompoundName) obj).impl);
}

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

javax.naming.ldap.LdapName.compareTo(Object)

/**
     * Compares this LdapName with the specified Object for order.
     * Returns a negative integer, zero, or a positive integer as this
     * Name is less than, equal to, or greater than the given Object.
     * If obj is null or not an instance of LdapName, ClassCastException
     * is thrown.
     * Ordering of LDAP names follows the lexicographical rules for
     * string comparison, with the extension that this applies to all
     * the RDNs in the LDAP name. All the RDNs are lined up in their
     * specified order and compared lexicographically.
     * See {@link Rdn#compareTo(Object obj) Rdn.compareTo(Object obj)}
     * for RDN comparison rules.
     * If this LDAP name is lexicographically lesser than obj,
     * a negative number is returned.
     * If this LDAP name is lexicographically greater than obj,
     * a positive number is returned.
     * @param obj The non-null LdapName instance to compare against.
     * @return  A negative integer, zero, or a positive integer as this Name
     *   is less than, equal to, or greater than the given obj.
     * @exception ClassCastException if obj is null or not a LdapName.
     */
public int compareTo(Object obj) {
    if (!(obj instanceof LdapName)) {
        throw new ClassCastException('The obj is not a LdapName');
    }
    if (obj == this) {
        return 0;
    }
    LdapName that = (LdapName) obj;
    if (unparsed != null && unparsed.equalsIgnoreCase(that.unparsed)) {
        return 0;
    }
    int minSize = Math.min(rdns.size(), that.rdns.size());
    for (int i = 0; i < minSize; i++) {
        Rdn rdn1 = (Rdn) rdns.get(i);
        Rdn rdn2 = (Rdn) that.rdns.get(i);
        int diff = rdn1.compareTo(rdn2);
        if (diff != 0) {
            return diff;
        }
    }
    return (rdns.size() - that.rdns.size());
}

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

javax.naming.ldap.Rdn.compareTo(Object)

/**
     * Compares this Rdn with the specified Object for order.
     * Returns a negative integer, zero, or a positive integer as this
     * Rdn is less than, equal to, or greater than the given Object.
     * If obj is null or not an instance of Rdn, ClassCastException
     * is thrown.
     * The attribute type and value pairs of the RDNs are lined up
     * against each other and compared lexicographically. The order of
     * components in multi-valued Rdns (such as 'ou=Sales+cn=Bob') is not
     * significant.
     * @param obj The non-null object to compare against.
     * @return  A negative integer, zero, or a positive integer as this Rdn
     *   is less than, equal to, or greater than the given Object.
     * @exception ClassCastException if obj is null or not a Rdn.
     */
public int compareTo(Object obj) {
    if (!(obj instanceof Rdn)) {
        throw new ClassCastException('The obj is not a Rdn');
    }
    if (obj == this) {
        return 0;
    }
    Rdn that = (Rdn) obj;
    int minSize = Math.min(entries.size(), that.entries.size());
    for (int i = 0; i < minSize; i++) {
        int diff = ((RdnEntry) entries.get(i)).compareTo(that.entries.get(i));
        if (diff != 0) {
            return diff;
        }
    }
    return (entries.size() - that.entries.size());
}

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

java.awt.image.DirectColorModel.getDataElements(int[], int, Object)

/**
     * Returns a data element array representation of a pixel in this
     * <code>ColorModel</code>, given an array of unnormalized color/alpha 
     * components.
     * This array can then be passed to the <code>setDataElements</code> 
     * method of a <code>WritableRaster</code> object.
     * An <code>ArrayIndexOutOfBoundsException</code> is thrown if the 
     * <code>components</code> array
     * is not large enough to hold all the color and alpha components,
     * starting at offset.  If the <code>obj</code> variable is 
     * <code>null</code>, a new array is allocated.  If <code>obj</code> is 
     * not <code>null</code>, it must be a primitive array
     * of type <code>transferType</code>; otherwise, a 
     * <code>ClassCastException</code> is thrown.
     * An <code>ArrayIndexOutOfBoundsException</code> is thrown if 
     * <code>obj</code> is not large enough to hold a pixel value for this 
     * <code>ColorModel</code>.
     * Since <code>DirectColorModel</code> can be subclassed, subclasses
     * inherit the implementation of this method and if they don't
     * override it then they throw an exception if they use an unsupported
     * <code>transferType</code>.
     * @param components an array of unnormalized color and alpha
     * components
     * @param offset the index into <code>components</code> at which to
     * begin retrieving color and alpha components
     * @param obj the <code>Object</code> representing an array of color
     * and alpha components
     * @return an <code>Object</code> representing an array of color and
     * alpha components.
     * @exception <code>ClassCastException</code> if <code>obj</code>
     *  is not a primitive array of type <code>transferType</code>
     * @exception <code>ArrayIndexOutOfBoundsException</code> if
     *  <code>obj</code> is not large enough to hold a pixel value
     *  for this <code>ColorModel</code> or the <code>components</code>
     * array is not large enough to hold all of the color and alpha
     * components starting at <code>offset</code> 
     * @exception UnsupportedOperationException if this
     *            <code>transferType</code> is not supported by this
     *            color model
     * @see WritableRaster#setDataElements
     * @see SampleModel#setDataElements
     */
public Object getDataElements(int[] components, int offset, Object obj) {
    int pixel = 0;
    for (int i = 0; i < numComponents; i++) {
        pixel |= ((components[offset + i] << maskOffsets[i]) & maskArray[i]);
    }
    switch(transferType) {
        case DataBuffer.TYPE_BYTE:
            if (obj instanceof byte[]) {
                byte bdata[] = (byte[]) obj;
                bdata[0] = (byte) (pixel & 0xff);
                return bdata;
            } else {
                byte bdata[] = { (byte) (pixel & 0xff) };
                return bdata;
            }
        case DataBuffer.TYPE_USHORT:
            if (obj instanceof short[]) {
                short sdata[] = (short[]) obj;
                sdata[0] = (short) (pixel & 0xffff);
                return sdata;
            } else {
                short sdata[] = { (short) (pixel & 0xffff) };
                return sdata;
            }
        case DataBuffer.TYPE_INT:
            if (obj instanceof int[]) {
                int idata[] = (int[]) obj;
                idata[0] = pixel;
                return idata;
            } else {
                int idata[] = { pixel };
                return idata;
            }
        default:
            throw new ClassCastException('This method has not been ' + 'implemented for transferType ' + transferType);
    }
}

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

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…

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.

WebLogic Admin Console

WebLogic Admin Console
The WebLogic Admin Console is a web-based, user interface used to configure and control a set of WebLogic servers or clusters (i.e. a "domain"). In any logical group of WebLogic servers there must exist one admin server, which hosts the WebLogic Admin Console application and manages the associated configuration files.
WebLogic Administrators will use the Administration Console for a number of tasks, including:
Starting and stopping WebLogic servers or entire clusters.Configuring server parameters, security, database connections and deployed applications.Viewing server status, health and metrics. Note: It is not strictly necessary to use the Weblogic Admin Console to perform these tasks, as they can be scripted using WLST (the WebLogic Scripting Tool).
Accessing the Admin Console
WebLogic Admin Console Url: http://hostname:port/console.
To access the WebLogic Administration Console, assuming the admin server has been started, goto the above url. Where hostname…