Skip to content

Commit

Permalink
Fix Android 2.2 compatibility
Browse files Browse the repository at this point in the history
FroYo doesn't support some of Arrays' functions, such as copyOf() and
copyOfRange(). ArraysCompat implements all variants of those methods,
adding FroYo compatibility back
  • Loading branch information
goncalossilva committed Jan 25, 2014
1 parent 1c3530e commit 8ac0c66
Show file tree
Hide file tree
Showing 6 changed files with 502 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.fasterxml.jackson.core.io;

import java.util.Arrays;

import com.fasterxml.jackson.core.SerializableString;
import com.fasterxml.jackson.core.util.ArraysCompat;

/**
* Abstract base class that defines interface for customizing character
Expand Down Expand Up @@ -67,6 +66,6 @@ public abstract class CharacterEscapes
public static int[] standardAsciiEscapesForJSON()
{
int[] esc = CharTypes.get7BitOutputEscapes();
return Arrays.copyOf(esc, esc.length);
return ArraysCompat.copyOf(esc, esc.length);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.fasterxml.jackson.core.json;

import java.io.*;
import java.util.Arrays;

import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.core.base.ParserBase;
Expand Down Expand Up @@ -3129,7 +3128,7 @@ public static int[] growArrayBy(int[] arr, int more)
if (arr == null) {
return new int[more];
}
return Arrays.copyOf(arr, arr.length + more);
return ArraysCompat.copyOf(arr, arr.length + more);
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicReference;

import com.fasterxml.jackson.core.util.ArraysCompat;
import com.fasterxml.jackson.core.util.InternCache;

/**
Expand Down Expand Up @@ -1012,7 +1013,7 @@ private int findBestBucket()
private void unshareMain()
{
final int[] old = _mainHash;
_mainHash = Arrays.copyOf(old, old.length);
_mainHash = ArraysCompat.copyOf(old, old.length);
_mainHashShared = false;
}

Expand All @@ -1022,22 +1023,22 @@ private void unshareCollision()
if (old == null) {
_collList = new Bucket[INITIAL_COLLISION_LEN];
} else {
_collList = Arrays.copyOf(old, old.length);
_collList = ArraysCompat.copyOf(old, old.length);
}
_collListShared = false;
}

private void unshareNames()
{
final Name[] old = _mainNames;
_mainNames = Arrays.copyOf(old, old.length);
_mainNames = ArraysCompat.copyOf(old, old.length);
_mainNamesShared = false;
}

private void expandCollision()
{
final Bucket[] old = _collList;
_collList = Arrays.copyOf(old, old.length * 2);
_collList = ArraysCompat.copyOf(old, old.length * 2);
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.Arrays;

import com.fasterxml.jackson.core.util.ArraysCompat;
import com.fasterxml.jackson.core.util.InternCache;

/**
Expand Down Expand Up @@ -576,9 +577,9 @@ public int calcHash(String key)
private void copyArrays()
{
final String[] oldSyms = _symbols;
_symbols = Arrays.copyOf(oldSyms, oldSyms.length);
_symbols = ArraysCompat.copyOf(oldSyms, oldSyms.length);
final Bucket[] oldBuckets = _buckets;
_buckets = Arrays.copyOf(oldBuckets, oldBuckets.length);
_buckets = ArraysCompat.copyOf(oldBuckets, oldBuckets.length);
}

/**
Expand Down
Loading

0 comments on commit 8ac0c66

Please sign in to comment.