GERONIMO-6712 remove JsonProvider resolving for JsonValue class init
The usage of the full JsonProvider might have created a deadlock during class init.
git-svn-id: https://svn.apache.org/repos/asf/geronimo/specs/trunk@1854511 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/geronimo-json_1.1_spec/src/main/java/javax/json/EmptyJsonArray.java b/geronimo-json_1.1_spec/src/main/java/javax/json/EmptyJsonArray.java
new file mode 100644
index 0000000..d8862da
--- /dev/null
+++ b/geronimo-json_1.1_spec/src/main/java/javax/json/EmptyJsonArray.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package javax.json;
+
+import java.io.Serializable;
+import java.util.AbstractList;
+import java.util.List;
+
+class EmptyJsonArray extends AbstractList<JsonValue> implements JsonArray, Serializable {
+ @Override
+ public JsonValue get(int i) {
+ throw new IndexOutOfBoundsException();
+ }
+
+ @Override
+ public int size() {
+ return 0;
+ }
+
+ @Override
+ public JsonObject getJsonObject(int index) {
+ throw new IndexOutOfBoundsException();
+ }
+
+ @Override
+ public JsonArray getJsonArray(int index) {
+ throw new IndexOutOfBoundsException();
+ }
+
+ @Override
+ public JsonNumber getJsonNumber(int index) {
+ throw new IndexOutOfBoundsException();
+ }
+
+ @Override
+ public JsonString getJsonString(int index) {
+ throw new IndexOutOfBoundsException();
+ }
+
+ @Override
+ public <T extends JsonValue> List<T> getValuesAs(Class<T> clazz) {
+ return null;
+ }
+
+ @Override
+ public String getString(int index) {
+ throw new IndexOutOfBoundsException();
+ }
+
+ @Override
+ public String getString(int index, String defaultValue) {
+ throw new IndexOutOfBoundsException();
+ }
+
+ @Override
+ public int getInt(int index) {
+ throw new IndexOutOfBoundsException();
+ }
+
+ @Override
+ public int getInt(int index, int defaultValue) {
+ throw new IndexOutOfBoundsException();
+ }
+
+ @Override
+ public boolean getBoolean(int index) {
+ throw new IndexOutOfBoundsException();
+ }
+
+ @Override
+ public boolean getBoolean(int index, boolean defaultValue) {
+ throw new IndexOutOfBoundsException();
+ }
+
+ @Override
+ public boolean isNull(int index) {
+ throw new IndexOutOfBoundsException();
+ }
+
+ @Override
+ public ValueType getValueType() {
+ return ValueType.ARRAY;
+ }
+}
diff --git a/geronimo-json_1.1_spec/src/main/java/javax/json/EmptyJsonObject.java b/geronimo-json_1.1_spec/src/main/java/javax/json/EmptyJsonObject.java
new file mode 100644
index 0000000..09d86c3
--- /dev/null
+++ b/geronimo-json_1.1_spec/src/main/java/javax/json/EmptyJsonObject.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package javax.json;
+
+import java.io.Serializable;
+import java.util.AbstractMap;
+import java.util.Collections;
+import java.util.Set;
+
+class EmptyJsonObject extends AbstractMap<String, JsonValue> implements JsonObject, Serializable {
+ @Override
+ public Set<Entry<String, JsonValue>> entrySet() {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public JsonArray getJsonArray(String name) {
+ return null;
+ }
+
+ @Override
+ public JsonObject getJsonObject(String name) {
+ return null;
+ }
+
+ @Override
+ public JsonNumber getJsonNumber(String name) {
+ return null;
+ }
+
+ @Override
+ public JsonString getJsonString(String name) {
+ return null;
+ }
+
+ @Override
+ public String getString(String name) {
+ return null;
+ }
+
+ @Override
+ public String getString(String name, String defaultValue) {
+ return null;
+ }
+
+ @Override
+ public int getInt(String name) {
+ throw new NullPointerException("Calling getInt on EmptyJsonObject");
+ }
+
+ @Override
+ public int getInt(String name, int defaultValue) {
+ return defaultValue;
+ }
+
+ @Override
+ public boolean getBoolean(String name) {
+ throw new NullPointerException("Calling getInt on EmptyJsonObject");
+ }
+
+ @Override
+ public boolean getBoolean(String name, boolean defaultValue) {
+ return defaultValue;
+ }
+
+ @Override
+ public boolean isNull(String name) {
+ return true;
+ }
+
+ @Override
+ public ValueType getValueType() {
+ return ValueType.OBJECT;
+ }
+}
diff --git a/geronimo-json_1.1_spec/src/main/java/javax/json/JsonArray.java b/geronimo-json_1.1_spec/src/main/java/javax/json/JsonArray.java
index 83a7597..0949165 100644
--- a/geronimo-json_1.1_spec/src/main/java/javax/json/JsonArray.java
+++ b/geronimo-json_1.1_spec/src/main/java/javax/json/JsonArray.java
@@ -122,6 +122,7 @@
* @throws IndexOutOfBoundsException if the index is out of range
* @throws ClassCastException if the value at the specified position is not
* assignable to an int
+ * @throws NullPointerException if an object with the given name doesn't exist
*/
int getInt(int index);
@@ -138,6 +139,7 @@
* @throws IndexOutOfBoundsException if the index is out of range
* @throws ClassCastException if the value at the specified position is not
* assignable to a boolean
+ * @throws NullPointerException if an object with the given name doesn't exist
*/
boolean getBoolean(int index);
diff --git a/geronimo-json_1.1_spec/src/main/java/javax/json/JsonObject.java b/geronimo-json_1.1_spec/src/main/java/javax/json/JsonObject.java
index c1e6f82..e7989ec 100644
--- a/geronimo-json_1.1_spec/src/main/java/javax/json/JsonObject.java
+++ b/geronimo-json_1.1_spec/src/main/java/javax/json/JsonObject.java
@@ -75,6 +75,7 @@
/**
* @return the int with the given name or {@code null} if there is no attribute with that name
* @throws ClassCastException if the JsonValue cannot be correctly cast
+ * @throws NullPointerException if an object with the given name doesn't exist
*/
int getInt(String name);
@@ -87,6 +88,7 @@
/**
* @return the boolean with the given name or {@code null} if there is no attribute with that name
* @throws ClassCastException if the JsonValue cannot be correctly cast
+ * @throws NullPointerException if an object with the given name doesn't exist
*/
boolean getBoolean(String name);
diff --git a/geronimo-json_1.1_spec/src/main/java/javax/json/JsonValue.java b/geronimo-json_1.1_spec/src/main/java/javax/json/JsonValue.java
index 5bae7db..39b994e 100644
--- a/geronimo-json_1.1_spec/src/main/java/javax/json/JsonValue.java
+++ b/geronimo-json_1.1_spec/src/main/java/javax/json/JsonValue.java
@@ -24,12 +24,12 @@
/**
* The empty JSON object.
*/
- JsonObject EMPTY_JSON_OBJECT = Json.createObjectBuilder().build();
+ JsonObject EMPTY_JSON_OBJECT = new EmptyJsonObject();
/**
* The empty JSON array.
*/
- JsonArray EMPTY_JSON_ARRAY = Json.createArrayBuilder().build();
+ JsonArray EMPTY_JSON_ARRAY = new EmptyJsonArray();
/**