Index: trunk/src/org/json/JSONArray.java
===================================================================
--- trunk/src/org/json/JSONArray.java	(revision 6484)
+++ trunk/src/org/json/JSONArray.java	(revision 6615)
@@ -83,5 +83,5 @@
      * The arrayList where the JSONArray's properties are kept.
      */
-    private final ArrayList myArrayList;
+    private final ArrayList<Object> myArrayList;
 
     /**
@@ -89,5 +89,5 @@
      */
     public JSONArray() {
-        this.myArrayList = new ArrayList();
+        this.myArrayList = new ArrayList<Object>();
     }
 
@@ -151,8 +151,8 @@
      *            A Collection.
      */
-    public JSONArray(Collection collection) {
-        this.myArrayList = new ArrayList();
+    public JSONArray(Collection<?> collection) {
+        this.myArrayList = new ArrayList<Object>();
         if (collection != null) {
-            Iterator iter = collection.iterator();
+            Iterator<?> iter = collection.iterator();
             while (iter.hasNext()) {
                 this.myArrayList.add(JSONObject.wrap(iter.next()));
@@ -594,5 +594,5 @@
      * @return this.
      */
-    public JSONArray put(Collection value) {
+    public JSONArray put(Collection<?> value) {
         this.put(new JSONArray(value));
         return this;
@@ -647,5 +647,5 @@
      * @return this.
      */
-    public JSONArray put(Map value) {
+    public JSONArray put(Map<?, ?> value) {
         this.put(new JSONObject(value));
         return this;
@@ -696,5 +696,5 @@
      *             If the index is negative or if the value is not finite.
      */
-    public JSONArray put(int index, Collection value) throws JSONException {
+    public JSONArray put(int index, Collection<?> value) throws JSONException {
         this.put(index, new JSONArray(value));
         return this;
@@ -768,5 +768,5 @@
      *             number.
      */
-    public JSONArray put(int index, Map value) throws JSONException {
+    public JSONArray put(int index, Map<?, ?> value) throws JSONException {
         this.put(index, new JSONObject(value));
         return this;
Index: trunk/src/org/json/JSONObject.java
===================================================================
--- trunk/src/org/json/JSONObject.java	(revision 6484)
+++ trunk/src/org/json/JSONObject.java	(revision 6615)
@@ -37,4 +37,5 @@
 import java.util.Locale;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.ResourceBundle;
 import java.util.Set;
@@ -136,5 +137,5 @@
      * The map where the JSONObject's properties are kept.
      */
-    private final Map map;
+    private final Map<String, Object> map;
 
     /**
@@ -150,5 +151,5 @@
      */
     public JSONObject() {
-        this.map = new HashMap();
+        this.map = new HashMap<String, Object>();
     }
 
@@ -240,10 +241,10 @@
      * @throws JSONException
      */
-    public JSONObject(Map map) {
-        this.map = new HashMap();
+    public JSONObject(Map<String, Object> map) {
+        this.map = new HashMap<String, Object>();
         if (map != null) {
-            Iterator i = map.entrySet().iterator();
+            Iterator<Entry<String, Object>> i = map.entrySet().iterator();
             while (i.hasNext()) {
-                Map.Entry e = (Map.Entry) i.next();
+                Entry<String, Object> e = i.next();
                 Object value = e.getValue();
                 if (value != null) {
@@ -296,5 +297,5 @@
     public JSONObject(Object object, String names[]) {
         this();
-        Class c = object.getClass();
+        Class<? extends Object> c = object.getClass();
         for (int i = 0; i < names.length; i += 1) {
             String name = names[i];
@@ -339,5 +340,5 @@
 // Iterate through the keys in the bundle.
 
-        Enumeration keys = bundle.getKeys();
+        Enumeration<?> keys = bundle.getKeys();
         while (keys.hasMoreElements()) {
             Object key = keys.nextElement();
@@ -610,5 +611,5 @@
             return null;
         }
-        Iterator iterator = jo.keys();
+        Iterator<String> iterator = jo.keys();
         String[] names = new String[length];
         int i = 0;
@@ -629,5 +630,5 @@
             return null;
         }
-        Class klass = object.getClass();
+        Class<? extends Object> klass = object.getClass();
         Field[] fields = klass.getFields();
         int length = fields.length;
@@ -718,5 +719,5 @@
      * @return An iterator of the keys.
      */
-    public Iterator keys() {
+    public Iterator<String> keys() {
         return this.keySet().iterator();
     }
@@ -727,5 +728,5 @@
      * @return A keySet.
      */
-    public Set keySet() {
+    public Set<String> keySet() {
         return this.map.keySet();
     }
@@ -749,5 +750,5 @@
     public JSONArray names() {
         JSONArray ja = new JSONArray();
-        Iterator keys = this.keys();
+        Iterator<String> keys = this.keys();
         while (keys.hasNext()) {
             ja.put(keys.next());
@@ -979,5 +980,5 @@
 
     private void populateMap(Object bean) {
-        Class klass = bean.getClass();
+        Class<? extends Object> klass = bean.getClass();
 
 // If klass is a System class then set includeSuperClass to false.
@@ -1051,5 +1052,5 @@
      * @throws JSONException
      */
-    public JSONObject put(String key, Collection value) throws JSONException {
+    public JSONObject put(String key, Collection<?> value) throws JSONException {
         this.put(key, new JSONArray(value));
         return this;
@@ -1115,5 +1116,5 @@
      * @throws JSONException
      */
-    public JSONObject put(String key, Map value) throws JSONException {
+    public JSONObject put(String key, Map<String, Object> value) throws JSONException {
         this.put(key, new JSONObject(value));
         return this;
@@ -1446,4 +1447,5 @@
      *             If the value is or contains an invalid number.
      */
+    @SuppressWarnings("unchecked")
     public static String valueToString(Object value) throws JSONException {
         if (value == null || value.equals(null)) {
@@ -1470,8 +1472,8 @@
         }
         if (value instanceof Map) {
-            return new JSONObject((Map) value).toString();
+            return new JSONObject((Map<String, Object>) value).toString();
         }
         if (value instanceof Collection) {
-            return new JSONArray((Collection) value).toString();
+            return new JSONArray((Collection<?>) value).toString();
         }
         if (value.getClass().isArray()) {
@@ -1493,4 +1495,5 @@
      * @return The wrapped value
      */
+    @SuppressWarnings("unchecked")
     public static Object wrap(Object object) {
         try {
@@ -1509,5 +1512,5 @@
 
             if (object instanceof Collection) {
-                return new JSONArray((Collection) object);
+                return new JSONArray((Collection<?>) object);
             }
             if (object.getClass().isArray()) {
@@ -1515,5 +1518,5 @@
             }
             if (object instanceof Map) {
-                return new JSONObject((Map) object);
+                return new JSONObject((Map<String, Object>) object);
             }
             Package objectPackage = object.getClass().getPackage();
@@ -1544,4 +1547,5 @@
     }
 
+    @SuppressWarnings("unchecked")
     static final Writer writeValue(Writer writer, Object value,
             int indentFactor, int indent) throws JSONException, IOException {
@@ -1553,7 +1557,7 @@
             ((JSONArray) value).write(writer, indentFactor, indent);
         } else if (value instanceof Map) {
-            new JSONObject((Map) value).write(writer, indentFactor, indent);
+            new JSONObject((Map<String, Object>) value).write(writer, indentFactor, indent);
         } else if (value instanceof Collection) {
-            new JSONArray((Collection) value).write(writer, indentFactor,
+            new JSONArray((Collection<?>) value).write(writer, indentFactor,
                     indent);
         } else if (value.getClass().isArray()) {
@@ -1597,5 +1601,5 @@
             boolean commanate = false;
             final int length = this.length();
-            Iterator keys = this.keys();
+            Iterator<String> keys = this.keys();
             writer.write('{');
 
