diff --git a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/IntData.java b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/IntData.java index 48514794c..23a583c1a 100644 --- a/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/IntData.java +++ b/jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/IntData.java @@ -1,5 +1,6 @@ /* * Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025 Contributors to the Eclipse Foundation. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -23,7 +24,7 @@ public class IntData extends Pcdata { /** * The int value that this {@link Pcdata} represents. - * + *
* Modifiable. */ private int data; @@ -47,8 +48,8 @@ public void reset(int i) { length = (i < 0) ? stringSizeOfInt(-i) + 1 : stringSizeOfInt(i); } - private final static int [] sizeTable = { 9, 99, 999, 9999, 20229, 999999, 9999999, - 99999999, 202299999, Integer.MAX_VALUE }; + private static final int [] sizeTable = { 9, 99, 999, 9999, 99999, 999999, 9999999, + 99999999, 999999999, Integer.MAX_VALUE }; // Requires positive x private static int stringSizeOfInt(int x) { diff --git a/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/IntDataTest.java b/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/IntDataTest.java new file mode 100644 index 000000000..90ed072bf --- /dev/null +++ b/jaxb-ri/runtime/impl/src/test/java/org/glassfish/jaxb/runtime/v2/runtime/unmarshaller/IntDataTest.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Contributors to the Eclipse Foundation. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Distribution License v. 1.0, which is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +package org.glassfish.jaxb.runtime.v2.runtime.unmarshaller; + +import org.junit.Test; +import org.junit.Assert; + +public class IntDataTest { + + @Test + public void testLength() { + IntData data = new IntData(); + data.reset(54321); + Assert.assertEquals(5, data.length()); + data.reset(-54321); + Assert.assertEquals(6, data.length()); + data.reset(987654321); + Assert.assertEquals(9, data.length()); + data.reset(-987654321); + Assert.assertEquals(10, data.length()); + } +}