Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7763433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:39:27+00:00 2026-06-01T14:39:27+00:00

I need some help in understanding what is happening here .I am getting a

  • 0

I need some help in understanding what is happening here .I am getting a “IndexOutOfBoundsException” while inserting an element into a Map.Here is the the stack trace.

 java.lang.IndexOutOfBoundsException: Index: 192, Size: 192
        at java.util.ArrayList.RangeCheck(ArrayList.java:547)
        at java.util.ArrayList.get(ArrayList.java:322)
        at somepackage.SequentialMap.getKey(Unknown Source)
        at somepackage.SequentialIterator.next(Unknown Source)
        at java.util.HashMap.buildCache(HashMap.java:590)
        at java.util.HashMap.resize(HashMap.java:576)
        at java.util.HashMap.addEntry(HashMap.java:939)
        at java.util.HashMap.put(HashMap.java:477)
        at somepackage.SequentialMap.put(Unknown Source)
        at somepackage.BatchBurstingInfo.parseContents(Unknown Source)
        at somepackage.BatchBurstingInfo.parse(Unknown Source)
        at somepackager.BatchBurstingInfo.setFileContents(Unknown Source)
        at somepackage.BurstingListBean.setMembers(Unknown Source)

SeqentialMap above extends HashMap .
Here we are trying to insert a list of objects greater than 200 .The problem is it works fine when i run in dev set up which uses JDK 1.6 but in weblogic server I always get this exception for same steps .
Also while debugging i could not find any buildCache method in HashMap class,so does it mean weblogic JDK is some different version og implementation.

here is the code snippet

public class SequentialMap extends HashMap
{
    private ArrayList m_keys = new ArrayList();

    /**
     * Removes the mapping for this key from this map if present.
     *
     * @param  key key whose mapping is to be removed from the map.
     * @return previous value associated with specified key, or <tt>null</tt>
     *         if there was no mapping for key.  A <tt>null</tt> return can
     *         also indicate that the map previously associated <tt>null</tt>
     *         with the specified key.
     */
    public Object remove(Object key) 
    {
        synchronized(this)
        {
                if(m_keys != null)
            {
                int iSize = m_keys.size();
                ArrayList oNewArray = new ArrayList();
                for(int i = 0; i < iSize; i++)
                {
                        if(m_keys.get(i).equals(key) == false)
                    {
                            oNewArray.add(m_keys.get(i));
                    }
                }
                m_keys = oNewArray;
            }
            return super.remove(key);
        }
    }   

    /**
     * Returns a collection view of the values contained in this map.  The
     * collection is backed by the map, so changes to the map are reflected in
     * the collection, and vice-versa.  The collection supports element
     * removal, which removes the corresponding mapping from this map, via the
     * <tt>Iterator.remove</tt>, <tt>Collection.remove</tt>,
     * <tt>removeAll</tt>, <tt>retainAll</tt>, and <tt>clear</tt> operations.
     * It does not support the <tt>add</tt> or <tt>addAll</tt> operations.
     *
     * @return a collection view of the values contained in this map.
     */
    /*public Collection values() 
    {
    }*/
    /**
     * Returns a collection view of the mappings contained in this map.  Each
     * element in the returned collection is a <tt>Map.Entry</tt>.  The
     * collection is backed by the map, so changes to the map are reflected in
     * the collection, and vice-versa.  The collection supports element
     * removal, which removes the corresponding mapping from the map, via the
     * <tt>Iterator.remove</tt>, <tt>Collection.remove</tt>,
     * <tt>removeAll</tt>, <tt>retainAll</tt>, and <tt>clear</tt> operations.
     * It does not support the <tt>add</tt> or <tt>addAll</tt> operations.
     *
     * @return a collection view of the mappings contained in this map.
     * @see Map.Entry
     */
    public Set entrySet() 
    {
            return super.entrySet();
    }

    /**
     * Removes all mappings from this map.
     */
    public void clear() 
    {
            synchronized(this)
        {
            m_keys.clear();
            super.clear();
        }
    }

    /**
     * Associates the specified value with the specified key in this map.
     * If the map previously contained a mapping for this key, the old
     * value is replaced.
     *
     * @param key key with which the specified value is to be associated.
     * @param value value to be associated with the specified key.
     * @return previous value associated with specified key, or <tt>null</tt>
     *         if there was no mapping for key.  A <tt>null</tt> return can
     *         also indicate that the HashMap previously associated
     *         <tt>null</tt> with the specified key.
     */
    public Object put(Object key, Object value) 
    {
        int iExistingIndex = this.getKeyIndex(key);
        Object oldObj = super.put(key, value);
        if(iExistingIndex == -1)
        {
            m_keys.add(key);
        }
        else
        {
                m_keys.add(iExistingIndex, key);
        }

        return oldObj;
    }

    /**
     * Returns a set view of the keys contained in this map.  The set is
     * backed by the map, so changes to the map are reflected in the set, and
     * vice-versa.  The set supports element removal, which removes the
     * corresponding mapping from this map, via the <tt>Iterator.remove</tt>,
     * <tt>Set.remove</tt>, <tt>removeAll</tt>, <tt>retainAll</tt>, and
     * <tt>clear</tt> operations.  It does not support the <tt>add</tt> or
     * <tt>addAll</tt> operations.
     *
     * @return a set view of the keys contained in this map.
     */
    public Set keySet() 
    {
        Set oSet = super.keySet();
        final SequentialMap oThis = this;
        HashSet oNewSet = new HashSet(oSet){
            /**
             * Returns an iterator over the elements in this set.  The elements
             * are returned in no particular order.
             *
             * @return an Iterator over the elements in this set.
             * @see ConcurrentModificationException
             */
            public Iterator iterator() {
                return new SequentialIterator(oThis);
            }
        };

        return oNewSet;
    }

    protected int getKeyIndex(Object key)
    {
        int index = -1;

            if(m_keys != null)
        {
            int iSize = m_keys.size();
            for(int i = 0; i < iSize; i++)
            {
                if(m_keys.get(i).equals(key))
                {
                        index = i;
                        break;
                }
            }
        }

        return index;
    }

    Object getKey(int index)
    {
            return m_keys.get(index);
    }
}



class SequentialIterator implements Iterator
{
    private SequentialMap m_oMap = null;
    private int m_iCurrentIndex = 0;

        SequentialIterator(SequentialMap oMap)
    {
            this.m_oMap = oMap;
    }
    /**
     * Returns <tt>true</tt> if the iteration has more elements. (In other
     * words, returns <tt>true</tt> if <tt>next</tt> would return an element
     * rather than throwing an exception.)
     *
     * @return <tt>true</tt> if the iterator has more elements.
     */
    public boolean hasNext() {
            return (m_iCurrentIndex < m_oMap.size());
    }
    /**
     * Returns the next element in the iteration.
     *
     * @return the next element in the iteration.
     * @exception NoSuchElementException iteration has no more elements.
     */
    public Object next() {
        Object key = m_oMap.getKey(m_iCurrentIndex);
        m_iCurrentIndex++;
        return key;
    }
    /**
     *
     * Removes from the underlying collection the last element returned by the
     * iterator (optional operation).  This method can be called only once per
     * call to <tt>next</tt>.  The behavior of an iterator is unspecified if
     * the underlying collection is modified while the iteration is in
     * progress in any way other than by calling this method.
     *
     * @exception UnsupportedOperationException if the <tt>remove</tt>
     *        operation is not supported by this Iterator.

     * @exception IllegalStateException if the <tt>next</tt> method has not
     *        yet been called, or the <tt>remove</tt> method has already
     *        been called after the last call to the <tt>next</tt>
     *        method.
     */
    public void remove() {
            Object key = m_oMap.getKey(m_iCurrentIndex - 1);
        m_oMap.remove(key);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T14:39:28+00:00Added an answer on June 1, 2026 at 2:39 pm

    I guess that your Weblogic is using an old version of JRockit. I’ve checked the source code of the last version and they are not using this buildCache anymore.

    I’m not sure, but I think that if you replace this:

    public boolean hasNext() {
            return (m_iCurrentIndex < m_oMap.size());
    }
    

    for this implementation:

    public boolean hasNext() {
            return (m_iCurrentIndex < m_keys.size());
    }
    

    You won’t have this error.

    Also you need to throw a NoSuchElementException on next() method if there is no next element, instead of throw a IndexOutOfBoundsException that is what your current implementation is doing now.

    Add something like this

    if (!hasNext()) {
        throw new NoSuchElementException();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help understanding what's happening here. This code is from a models/log.py
Need some help understanding if I'm on the right track here and exactly what
I need some help understanding this bit of code pre { white-space: pre; white-space:
I need some help in understanding when and why to use Remote Service instead
I have been trying out Cassandra and need some help in understanding a few
I need help understanding some C++ operator overload statements. The class is declared like
Need some help understanding why my concat() is failing and how to fix it.
I need some help understanding some of the points from Paul Graham’s What Made
I need some help understanding the correct way to mix variables with strings like
I need some help understanding how stdext::hash_multimap's lower_bound, upper_bound and equal_range work (at least

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.