Java programmers...error v.'code too large'

Discussion in 'OT Technology' started by Krakerjak, Mar 2, 2009.

  1. Krakerjak

    Krakerjak Active Member

    Joined:
    Jul 7, 2003
    Messages:
    8,288
    Likes Received:
    0
    Location:
    Edmonton eh
    Hey, im having an issue with my program.

    I have a class that is using 2 type short arrays that are both very long containing constant values like a lookup table.


    Both arrays have just under 8000 elements in them, and when compiling an error is returned.

    Code:
    \src\HandEval.java:11: code too large
        private static final short flushes[] = {
    I was reading how Java has a code size limit of 64kb for any given method.
    Anyway, what could I do to get around this? :confused:

    This is my HandEval class so far, there is still a bunch more code needed to be written for it so I need to get past this error.

    Code:
    public class HandEval {
        
    //----------------------------------
    // Instance Variables
    //----------------------------------
    private static final short flushes[] = {
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 1599, 0, 0, 0, 0, 0, 0, 0, 1598, 0, 0, 0, 1597, 0, 1596,
    8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1595, 0, 0, 0,
    0, 0, 0, 0, 1594, 0, 0, 0, 1593, 0, 1592, 1591, 0, 0, 0, 0, 0, 0,
    0,  0,  1590,  0, 0, 0, 1589, 0, 1588, 1587, 0, 0, 0, 0, 1586, 0,
    1585, 1584, 0, 0, 1583, 1582, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    ......etc.......};
    
    private static final short unique5[] = {
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 1608, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 7462, 0, 0, 0, 0, 0, 0, 0, 7461, 0, 0,  0,  7460,  0,
    7459, 1607, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7458,
    0, 0, 0, 0, 0, 0, 0, 7457, 0, 0, 0, 7456, 0, 7455, 7454, 0, 0, 0,
    ......etc.....};
    
    //----------------------------------
    // Constructors
    //----------------------------------
        public HandEval(Hand fiveCardHand) {
            
        }
        
        public HandEval(Card c1, Card c2, Card c3, Card c4, Card c5) {
            
        }
        
        public HandEval(Card c1, Card c2, Card c3, Card c4, Card c5, Card c6, Card c7) {
            
        }
        
        public HandEval(int c1, int c2, int c3, int c4, int c5) {
            
        }
        
        public HandEval(int c1, int c2, int c3, int c4, int c5, int c6, int c7) {
            
        }
        
        public HandEval(Hand holeCards, Hand communityCards) {
            
        }
        
    
    //----------------------------------
    // Methods
    //----------------------------------    
        
    }
     
  2. ge0

    ge0 New Member

    Joined:
    Oct 31, 2005
    Messages:
    8,398
    Likes Received:
    0
    Location:
    JERSEY
    put an array inside of an array.
     
  3. Krakerjak

    Krakerjak Active Member

    Joined:
    Jul 7, 2003
    Messages:
    8,288
    Likes Received:
    0
    Location:
    Edmonton eh
    This fixes it...
    There are 2 more big arrays I need in this class too
    fucking perfect hash lookups :o

    Code:
    public class HandEval {
        
    //----------------------------------
    // Instance Variables
    //----------------------------------
    private static short flushes[];
    
    private static short unique5[];
    
    //----------------------------------
    // Constructors
    //----------------------------------
        public HandEval(Hand fiveCardHand) {
            initFlushesArray();
            initUnique5Array();
        }
        
        public HandEval(Card c1, Card c2, Card c3, Card c4, Card c5) {
            initFlushesArray();
            initUnique5Array();
        }
        
       public HandEval(int c1, int c2, int c3, int c4, int c5) {
            initFlushesArray();
            initUnique5Array();
        }
        
       public HandEval(Hand holeCards, Hand communityCards) {
            initFlushesArray();  
            initUnique5Array();   
        }
        
    
    //----------------------------------
    // Methods
    //----------------------------------    
        private void initFlushesArray() {
            flushes = new short[] {
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     0, 0, 0, 1599, 0, 0, 0, 0, 0, 0, 0, 1598, 0, 0, 0, 1597, 0, 1596,
     8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1595, 0, 0, 0,
     0, 0, 0, 0, 1594, 0, 0, 0, 1593, 0, 1592, 1591, 0, 0, 0, 0, 0, 0,
     0,  0,  1590,  0, 0, 0, 1589, 0, 1588, 1587, 0, 0, 0, 0, 1586, 0,
     1585, 1584, 0, 0, 1583, 1582, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     ......etc.......};
        }
    
        private void initUnique5Array() {
           Unique5  = new short[] {
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     0, 0, 0, 0, 0, 0, 0, 0, 0, 1608, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     0, 0, 0, 0, 7462, 0, 0, 0, 0, 0, 0, 0, 7461, 0, 0,  0,  7460,  0,
     7459, 1607, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7458,
     0, 0, 0, 0, 0, 0, 0, 7457, 0, 0, 0, 7456, 0, 7455, 7454, 0, 0, 0,
     ......etc.....};
        }
    }
     

Share This Page