Метод parseUnsignedInt был представлен в Java 1.8, так как он задокументирован в его javadoc (обратите внимание на @ начиная с 1.8 ):
/**
* Parses the string argument as an unsigned decimal integer. The
* characters in the string must all be decimal digits, except
* that the first character may be an an ASCII plus sign {@code
* '+'} ({@code '\u005Cu002B'}). The resulting integer value
* is returned, exactly as if the argument and the radix 10 were
* given as arguments to the {@link
* #parseUnsignedInt(java.lang.String, int)} method.
*
* @param s a {@code String} containing the unsigned {@code int}
* representation to be parsed
* @return the unsigned integer value represented by the argument in decimal.
* @throws NumberFormatException if the string does not contain a
* parsable unsigned integer.
* @since 1.8
*/
public static int parseUnsignedInt(String s) throws NumberFormatException {
return parseUnsignedInt(s, 10);
}
Но JDK также содержит источники, так что вы можете написать свой собственный метод parseUnsignedInt в своем собственном классе, аналогично реализации, содержащейся в Java 8, если лицензия Java 8 позволяет это.
См. http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/classes/java/lang/Integer.java
Линия 661 фф
Для получения подробной информации о безопасности (то есть, почему вы не можете разместить свой собственный класс Integer в пакете java.lang), опцию отмены этой безопасности и причину, по которой вы не должны (или лучше - почему вы не можете этого делать) см. выбранный ответ в Почему я могу заново создать пакет и классы java.lang?
Итак, вам придется реализовать свой собственный класс в своем собственном пакете:
package com.yourname;
/*
* Contains code from OpenJDK Java8, Copyright (c) 1994, 2013, Oracle and/or its affiliates.
* TODO add more info from Oracle class comment here.
*/
public class IntCompatUtilities {
public static int parseUnsignedInt(String s) throws NumberFormatException {
return parseUnsignedInt(s,10);
}
public static int parseUnsignedInt(String s, int radix)
throws NumberFormatException {
//TODO content from OpenJDK 8's Integer.parseUnsignedInt(String,int) here.
//instead of return parseInt(s, radix); change to return Integer.parseInt(s, radix);
//instead of throw NumberFormatException.forInputString(s); throw new NumberFormatException(...)
}
}
А затем пусть все ваши абоненты звонят com.yourname.IntCompatUtilities.parseUnsignedInt(...)