Exception Fact Sheet for "java-util"

The goal of an Exception Fact Sheet is to reveal the design of exception handling in an application.

--Maxence, Martin

For feedback, please contact Martin

Table of contents

Basic Statistics

Number of Classes 261
Number of Domain Exception Types (Thrown or Caught) 21
Number of Domain Checked Exception Types 2
Number of Domain Runtime Exception Types 19
Number of Domain Unknown Exception Types 0
nTh = Number of Throw 468
nTh = Number of Throw in Catch 54
Number of Catch-Rethrow (may not be correct) 1
nC = Number of Catch 107
nCTh = Number of Catch with Throw 51
Number of Empty Catch (really Empty) 17
Number of Empty Catch (with comments) 3
Number of Empty Catch 20
nM = Number of Methods 2581
nbFunctionWithCatch = Number of Methods with Catch 89 / 2581
nbFunctionWithThrow = Number of Methods with Throw 368 / 2581
nbFunctionWithThrowS = Number of Methods with ThrowS 117 / 2581
nbFunctionTransmitting = Number of Methods with "Throws" but NO catch, NO throw (only transmitting) 91 / 2581
P1 = nCTh / nC 47.7% (0.477)
P2 = nMC / nM 3.4% (0.034)
P3 = nbFunctionWithThrow / nbFunction 14.3% (0.143)
P4 = nbFunctionTransmitting / nbFunction 3.5% (0.035)
P5 = nbThrowInCatch / nbThrow 11.5% (0.115)
R2 = nCatch / nThrow 0.229
A1 = Number of Caught Exception Types From External Libraries 23
A2 = Number of Reused Exception Types From External Libraries (thrown from application code) 16

W1 is a rough estimation of the richness of the exception model. It does not take into account the inheritance relationships between domain exceptions.

Proportion P1 measures the overall exception flow. According to our experience, it varies from 5% to 70%. Early-catch design generally yields a low P1, libraries that must warn clients about errors (e.g. databases) generally have a high P1.

Proportion P2 measures the dispersion of catch blocks in the application. According to our experience, it varies from 2% to 15%. A small P2 indicates a rather centralized management of errors.

R1 shows how many exceptions types from libraries (incl. JDK) are thrown from application code. For instance, IllegalArgumentException comes from the JDK but is used in many applications.

A1 measures the awareness of the application to library exceptions. A high value of A1 means either that the application is polluted with checked exceptions or that it is able to apply specific recovery depending on the library exception.

Exception Hierachy

Exception Map

Each exception that is used at least once in the project is a dot. A orange dot represents a domain exception that is defined in the application. A blue dot exception is defined in the JDK or in a library. The x-axis represents the number of times an exception is caught, the y-axis the number of times an exception is thrown.

Exceptions With State

State means fields. Number of exceptions with state: 12
IllegalFormatFlagsException
              package java.util;public class IllegalFormatFlagsException extends IllegalFormatException {

    private static final long serialVersionUID = 790824L;

    private String flags;

    /**
     * Constructs an instance of this class with the specified flags.
     *
     * @param  f
     *         The set of format flags which contain an illegal combination
     */
    public IllegalFormatFlagsException(String f) {
 	if (f == null)
 	    throw new NullPointerException();
	this.flags = f;
    }

    /**
     * Returns the set of flags which contains an illegal combination.
     *
     * @return  The flags
     */
    public String getFlags() {
	return flags;
    }

    public String getMessage() {
	return "Flags = '" + flags + "'";
    }
}
            
IllegalFormatWidthException
              package java.util;public class IllegalFormatWidthException extends IllegalFormatException {

    private static final long serialVersionUID = 16660902L;

    private int w;

    /**
     * Constructs an instance of this class with the specified width.
     *
     * @param  w
     *         The width
     */
    public IllegalFormatWidthException(int w) {
	this.w = w;
    }

    /**
     * Returns the width
     *
     * @return  The width
     */
    public int getWidth() {
	return w;
    }

    public String getMessage() {
	return Integer.toString(w);
    }
}
            
IllegalFormatPrecisionException
              package java.util;public class IllegalFormatPrecisionException extends IllegalFormatException {

    private static final long serialVersionUID = 18711008L;

    private int p;

    /**
     * Constructs an instance of this class with the specified precision.
     *
     * @param  p
     *         The precision
     */
    public IllegalFormatPrecisionException(int p) {
	this.p = p;
    }

    /**
     * Returns the precision
     *
     * @return  The precision
     */
    public int getPrecision() {
	return p;
    }

    public String getMessage() {
	return Integer.toString(p);
    }
}
            
IllegalFormatCodePointException
              package java.util;public class IllegalFormatCodePointException extends IllegalFormatException {

    private static final long serialVersionUID = 19080630L;

    private int c;

    /**
     * Constructs an instance of this class with the specified illegal code
     * point as defined by {@link Character#isValidCodePoint}.
     *
     * @param  c
     *         The illegal Unicode code point
     */
    public IllegalFormatCodePointException(int c) {
	this.c = c;
    }

    /**
     * Returns the illegal code point as defined by {@link
     * Character#isValidCodePoint}.
     *
     * @return  The illegal Unicode code point
     */
    public int getCodePoint() {
	return c;
    }

    public String getMessage() {
	return String.format("Code point = %#x", c);
    }
}
            
FormatFlagsConversionMismatchException
              package java.util;public class FormatFlagsConversionMismatchException
    extends IllegalFormatException
{
    private static final long serialVersionUID = 19120414L;

    private String f;

    private char c;

    /**
     * Constructs an instance of this class with the specified flag
     * and conversion.
     *
     * @param  f
     *         The flag
     *
     * @param  c
     *         The conversion
     */
    public FormatFlagsConversionMismatchException(String f, char c) {
 	if (f == null)
 	    throw new NullPointerException();
	this.f = f;
	this.c = c;
    }

    /**
     * Returns the incompatible flag.
     *
     * @return  The flag
     */
     public String getFlags() {
	return f;
    }

    /**
     * Returns the incompatible conversion.
     *
     * @return  The conversion
     */
    public char getConversion() {
	return c;
    }

    public String getMessage() {
	return "Conversion = " + c + ", Flags = " + f;
    }
}
            
MissingFormatWidthException
              package java.util;public class MissingFormatWidthException extends IllegalFormatException {

    private static final long serialVersionUID = 15560123L;

    private String s;

    /**
     * Constructs an instance of this class with the specified format
     * specifier. 
     *
     * @param  s
     *         The format specifier which does not have a width
     */
    public MissingFormatWidthException(String s) {
	if (s == null)
	    throw new NullPointerException();
	this.s = s;
    }

    /**
     * Returns the format specifier which does not have a width.
     *
     * @return  The format specifier which does not have a width
     */
    public String getFormatSpecifier() {
	return s;
    }

    public String getMessage() {
	return s;
    }
}
            
UnknownFormatConversionException
              package java.util;public class UnknownFormatConversionException extends IllegalFormatException {

    private static final long serialVersionUID = 19060418L;

    private String s;

    /**
     * Constructs an instance of this class with the unknown conversion.
     *
     * @param  s
     *         Unknown conversion
     */
    public UnknownFormatConversionException(String s) {
	if (s == null)
	    throw new NullPointerException();
	this.s = s;
    }

    /**
     * Returns the unknown conversion.
     *
     * @return  The unknown conversion.
     */
    public String getConversion() {
	return s;
    }

    // javadoc inherited from Throwable.java
    public String getMessage() {
	return String.format("Conversion = '%s'", s);
    }
}
            
DuplicateFormatFlagsException
              package java.util;public class DuplicateFormatFlagsException extends IllegalFormatException {

    private static final long serialVersionUID = 18890531L;

    private String flags;

    /**
     * Constructs an instance of this class with the specified flags.
     *
     * @param  f
     *         The set of format flags which contain a duplicate flag.
     */
    public DuplicateFormatFlagsException(String f) {
 	if (f == null)
 	    throw new NullPointerException();
	this.flags = f;
    }

    /**
     * Returns the set of flags which contains a duplicate flag.
     *
     * @return  The flags
     */
    public String getFlags() {
	return flags;
    }

    public String getMessage() {
	return String.format("Flags = '%s'", flags);
    }
}
            
IllegalFormatConversionException
              package java.util;public class IllegalFormatConversionException extends IllegalFormatException {

    private static final long serialVersionUID = 17000126L;

    private char c;
    private Class arg;

    /**
     * Constructs an instance of this class with the mismatched conversion and
     * the corresponding argument class.
     *
     * @param  c
     *         Inapplicable conversion
     *
     * @param  arg
     *         Class of the mismatched argument
     */
    public IllegalFormatConversionException(char c, Class<?> arg) {
	if (arg == null)
	    throw new NullPointerException();
	this.c = c;
	this.arg = arg;
    }

    /**
     * Returns the inapplicable conversion.
     *
     * @return  The inapplicable conversion
     */
    public char getConversion() {
	return c;
    }

    /**
     * Returns the class of the mismatched argument.
     *
     * @return   The class of the mismatched argument
     */
    public Class<?> getArgumentClass() {
	return arg;
    }

    // javadoc inherited from Throwable.java
    public String getMessage() {
	return String.format("%c != %s", c, arg.getName());
    }
}
            
MissingFormatArgumentException
              package java.util;public class MissingFormatArgumentException extends IllegalFormatException {

    private static final long serialVersionUID = 19190115L;

    private String s;

    /**
     * Constructs an instance of this class with the unmatched format
     * specifier.
     *
     * @param  s
     *         Format specifier which does not have a corresponding argument
     */
    public MissingFormatArgumentException(String s) {
	if (s == null)
	    throw new NullPointerException();
	this.s = s;
    }

    /**
     * Returns the unmatched format specifier.
     *
     * @return  The unmatched format specifier
     */
    public String getFormatSpecifier() {
	return s;
    }

    public String getMessage() {
	return "Format specifier '" + s + "'";
    }
}
            
UnknownFormatFlagsException
              package java.util;public class UnknownFormatFlagsException extends IllegalFormatException {

    private static final long serialVersionUID = 19370506L;

    private String flags;

    /**
     * Constructs an instance of this class with the specified flags.
     *
     * @param  f
     *         The set of format flags which contain an unknown flag
     */
    public UnknownFormatFlagsException(String f) {
 	if (f == null)
 	    throw new NullPointerException();
	this.flags = f;
    }

    /**
     * Returns the set of flags which contains an unknown flag.
     *
     * @return  The flags
     */
    public String getFlags() {
	return flags;
    }

    // javadoc inherited from Throwable.java
    public String getMessage() {
	return "Flags = " + flags;
    }
}
            
MissingResourceException
              package java.util;public
class MissingResourceException extends RuntimeException {

    /**
     * Constructs a MissingResourceException with the specified information.
     * A detail message is a String that describes this particular exception.
     * @param s the detail message
     * @param className the name of the resource class
     * @param key the key for the missing resource.
     */
    public MissingResourceException(String s, String className, String key) {
        super(s);
        this.className = className;
        this.key = key;
    }

    /**
     * Constructs a <code>MissingResourceException</code> with
     * <code>message</code>, <code>className</code>, <code>key</code>,
     * and <code>cause</code>. This constructor is package private for
     * use by <code>ResourceBundle.getBundle</code>.
     *
     * @param message
     *        the detail message
     * @param className
     *        the name of the resource class
     * @param key
     *        the key for the missing resource.
     * @param cause
     *        the cause (which is saved for later retrieval by the
     *        {@link Throwable.getCause()} method). (A null value is
     *        permitted, and indicates that the cause is nonexistent
     *        or unknown.)
     */
    MissingResourceException(String message, String className, String key, Throwable cause) {
	super(message, cause);
        this.className = className;
        this.key = key;
    }

    /**
     * Gets parameter passed by constructor.
     *
     * @return the name of the resource class
     */
    public String getClassName() {
        return className;
    }

    /**
     * Gets parameter passed by constructor.
     *
     * @return the key for the missing resource
     */
    public String getKey() {
        return key;
    }

    //============ privates ============

    // serialization compatibility with JDK1.1
    private static final long serialVersionUID = -4876345176062000401L;

    /**
     * The class name of the resource bundle requested by the user.
     * @serial
     */
    private String className;

    /**
     * The name of the specific resource requested by the user.
     * @serial
     */
    private String key;
}
            

Thrown Exceptions Summary

A (Domain) exception is defined in the application. A (Lib) exception is defined in the JDK or in a library. An exception can be thrown, thrown from within a catch, or declared in the signature of a method (usually for checked exceptions). Hovering over a number triggers showing code snippets from the application code.

Type Exception Thrown Thrown
from Catch
Declared
- Unknown 10
              
//in java-util/ResourceBundle.java
throw (IOException) e.getException();

              
//in java-util/ResourceBundle.java
throw npe;

              
//in java-util/Scanner.java
throw iae;

              
//in java-util/XMLUtils.java
throw ioe;

              
//in java-util/XMLUtils.java
throw x;

              
//in java-util/XMLUtils.java
throw x;

              
//in java-util/XMLUtils.java
throw x;

              
//in java-util/Calendar.java
throw (RuntimeException) e;

              
//in java-util/Calendar.java
throw (IOException) e;

              
//in java-util/Calendar.java
throw (ClassNotFoundException) e;

            
- -
- Builder 1
              
// in java-util/ResourceBundle.java
throw (IOException) e.getException();

            
- -
- Variable 10
              
// in java-util/ResourceBundle.java
throw (IOException) e.getException();

              
// in java-util/ResourceBundle.java
throw npe;

              
// in java-util/Scanner.java
throw iae;

              
// in java-util/XMLUtils.java
throw ioe;

              
// in java-util/XMLUtils.java
throw x;

              
// in java-util/XMLUtils.java
throw x;

              
// in java-util/XMLUtils.java
throw x;

              
// in java-util/Calendar.java
throw (RuntimeException) e;

              
// in java-util/Calendar.java
throw (IOException) e;

              
// in java-util/Calendar.java
throw (ClassNotFoundException) e;

            
- -
(Lib) IllegalArgumentException 97
              
// in java-util/JapaneseImperialCalendar.java
public void add(int field, int amount) { // If amount == 0, do nothing even the given field is out of // range. This is tested by JCK. if (amount == 0) { return; // Do nothing! } if (field < 0 || field >= ZONE_OFFSET) { throw new IllegalArgumentException(); } // Sync the time and calendar fields. complete(); if (field == YEAR) { LocalGregorianCalendar.Date d = (LocalGregorianCalendar.Date) jdate.clone(); d.addYear(amount); pinDayOfMonth(d); set(ERA, getEraIndex(d)); set(YEAR, d.getYear()); set(MONTH, d.getMonth() - 1); set(DAY_OF_MONTH, d.getDayOfMonth()); } else if (field == MONTH) { LocalGregorianCalendar.Date d = (LocalGregorianCalendar.Date) jdate.clone(); d.addMonth(amount); pinDayOfMonth(d); set(ERA, getEraIndex(d)); set(YEAR, d.getYear()); set(MONTH, d.getMonth() - 1); set(DAY_OF_MONTH, d.getDayOfMonth()); } else if (field == ERA) { int era = internalGet(ERA) + amount; if (era < 0) { era = 0; } else if (era > eras.length - 1) { era = eras.length - 1; } set(ERA, era); } else { long delta = amount; long timeOfDay = 0; switch (field) { // Handle the time fields here. Convert the given // amount to milliseconds and call setTimeInMillis. case HOUR: case HOUR_OF_DAY: delta *= 60 * 60 * 1000; // hours to milliseconds break; case MINUTE: delta *= 60 * 1000; // minutes to milliseconds break; case SECOND: delta *= 1000; // seconds to milliseconds break; case MILLISECOND: break; // Handle week, day and AM_PM fields which involves // time zone offset change adjustment. Convert the // given amount to the number of days. case WEEK_OF_YEAR: case WEEK_OF_MONTH: case DAY_OF_WEEK_IN_MONTH: delta *= 7; break; case DAY_OF_MONTH: // synonym of DATE case DAY_OF_YEAR: case DAY_OF_WEEK: break; case AM_PM: // Convert the amount to the number of days (delta) // and +12 or -12 hours (timeOfDay). delta = amount / 2; timeOfDay = 12 * (amount % 2); break; } // The time fields don't require time zone offset change // adjustment. if (field >= HOUR) { setTimeInMillis(time + delta); return; } // The rest of the fields (week, day or AM_PM fields) // require time zone offset (both GMT and DST) change // adjustment. // Translate the current time to the fixed date and time // of the day. long fd = cachedFixedDate; timeOfDay += internalGet(HOUR_OF_DAY); timeOfDay *= 60; timeOfDay += internalGet(MINUTE); timeOfDay *= 60; timeOfDay += internalGet(SECOND); timeOfDay *= 1000; timeOfDay += internalGet(MILLISECOND); if (timeOfDay >= ONE_DAY) { fd++; timeOfDay -= ONE_DAY; } else if (timeOfDay < 0) { fd--; timeOfDay += ONE_DAY; } fd += delta; // fd is the expected fixed date after the calculation int zoneOffset = internalGet(ZONE_OFFSET) + internalGet(DST_OFFSET); setTimeInMillis((fd - EPOCH_OFFSET) * ONE_DAY + timeOfDay - zoneOffset); zoneOffset -= internalGet(ZONE_OFFSET) + internalGet(DST_OFFSET); // If the time zone offset has changed, then adjust the difference. if (zoneOffset != 0) { setTimeInMillis(time + zoneOffset); long fd2 = cachedFixedDate; // If the adjustment has changed the date, then take // the previous one. if (fd2 != fd) { setTimeInMillis(time - zoneOffset); } } } }
// in java-util/JapaneseImperialCalendar.java
public void roll(int field, int amount) { // If amount == 0, do nothing even the given field is out of // range. This is tested by JCK. if (amount == 0) { return; } if (field < 0 || field >= ZONE_OFFSET) { throw new IllegalArgumentException(); } // Sync the time and calendar fields. complete(); int min = getMinimum(field); int max = getMaximum(field); switch (field) { case ERA: case AM_PM: case MINUTE: case SECOND: case MILLISECOND: // These fields are handled simply, since they have fixed // minima and maxima. Other fields are complicated, since // the range within they must roll varies depending on the // date, a time zone and the era transitions. break; case HOUR: case HOUR_OF_DAY: { int unit = max + 1; // 12 or 24 hours int h = internalGet(field); int nh = (h + amount) % unit; if (nh < 0) { nh += unit; } time += ONE_HOUR * (nh - h); // The day might have changed, which could happen if // the daylight saving time transition brings it to // the next day, although it's very unlikely. But we // have to make sure not to change the larger fields. CalendarDate d = jcal.getCalendarDate(time, getZone()); if (internalGet(DAY_OF_MONTH) != d.getDayOfMonth()) { d.setEra(jdate.getEra()); d.setDate(internalGet(YEAR), internalGet(MONTH) + 1, internalGet(DAY_OF_MONTH)); if (field == HOUR) { assert (internalGet(AM_PM) == PM); d.addHours(+12); // restore PM } time = jcal.getTime(d); } int hourOfDay = d.getHours(); internalSet(field, hourOfDay % unit); if (field == HOUR) { internalSet(HOUR_OF_DAY, hourOfDay); } else { internalSet(AM_PM, hourOfDay / 12); internalSet(HOUR, hourOfDay % 12); } // Time zone offset and/or daylight saving might have changed. int zoneOffset = d.getZoneOffset(); int saving = d.getDaylightSaving(); internalSet(ZONE_OFFSET, zoneOffset - saving); internalSet(DST_OFFSET, saving); return; } case YEAR: min = getActualMinimum(field); max = getActualMaximum(field); break; case MONTH: // Rolling the month involves both pinning the final value to [0, 11] // and adjusting the DAY_OF_MONTH if necessary. We only adjust the // DAY_OF_MONTH if, after updating the MONTH field, it is illegal. // E.g., <jan31>.roll(MONTH, 1) -> <feb28> or <feb29>. { if (!isTransitionYear(jdate.getNormalizedYear())) { int year = jdate.getYear(); if (year == getMaximum(YEAR)) { CalendarDate jd = jcal.getCalendarDate(time, getZone()); CalendarDate d = jcal.getCalendarDate(Long.MAX_VALUE, getZone()); max = d.getMonth() - 1; int n = getRolledValue(internalGet(field), amount, min, max); if (n == max) { // To avoid overflow, use an equivalent year. jd.addYear(-400); jd.setMonth(n + 1); if (jd.getDayOfMonth() > d.getDayOfMonth()) { jd.setDayOfMonth(d.getDayOfMonth()); jcal.normalize(jd); } if (jd.getDayOfMonth() == d.getDayOfMonth() && jd.getTimeOfDay() > d.getTimeOfDay()) { jd.setMonth(n + 1); jd.setDayOfMonth(d.getDayOfMonth() - 1); jcal.normalize(jd); // Month may have changed by the normalization. n = jd.getMonth() - 1; } set(DAY_OF_MONTH, jd.getDayOfMonth()); } set(MONTH, n); } else if (year == getMinimum(YEAR)) { CalendarDate jd = jcal.getCalendarDate(time, getZone()); CalendarDate d = jcal.getCalendarDate(Long.MIN_VALUE, getZone()); min = d.getMonth() - 1; int n = getRolledValue(internalGet(field), amount, min, max); if (n == min) { // To avoid underflow, use an equivalent year. jd.addYear(+400); jd.setMonth(n + 1); if (jd.getDayOfMonth() < d.getDayOfMonth()) { jd.setDayOfMonth(d.getDayOfMonth()); jcal.normalize(jd); } if (jd.getDayOfMonth() == d.getDayOfMonth() && jd.getTimeOfDay() < d.getTimeOfDay()) { jd.setMonth(n + 1); jd.setDayOfMonth(d.getDayOfMonth() + 1); jcal.normalize(jd); // Month may have changed by the normalization. n = jd.getMonth() - 1; } set(DAY_OF_MONTH, jd.getDayOfMonth()); } set(MONTH, n); } else { int mon = (internalGet(MONTH) + amount) % 12; if (mon < 0) { mon += 12; } set(MONTH, mon); // Keep the day of month in the range. We // don't want to spill over into the next // month; e.g., we don't want jan31 + 1 mo -> // feb31 -> mar3. int monthLen = monthLength(mon); if (internalGet(DAY_OF_MONTH) > monthLen) { set(DAY_OF_MONTH, monthLen); } } } else { int eraIndex = getEraIndex(jdate); CalendarDate transition = null; if (jdate.getYear() == 1) { transition = eras[eraIndex].getSinceDate(); min = transition.getMonth() - 1; } else { if (eraIndex < eras.length - 1) { transition = eras[eraIndex + 1].getSinceDate(); if (transition.getYear() == jdate.getNormalizedYear()) { max = transition.getMonth() - 1; if (transition.getDayOfMonth() == 1) { max--; } } } } if (min == max) { // The year has only one month. No need to // process further. (Showa Gan-nen (year 1) // and the last year have only one month.) return; } int n = getRolledValue(internalGet(field), amount, min, max); set(MONTH, n); if (n == min) { if (!(transition.getMonth() == BaseCalendar.JANUARY && transition.getDayOfMonth() == 1)) { if (jdate.getDayOfMonth() < transition.getDayOfMonth()) { set(DAY_OF_MONTH, transition.getDayOfMonth()); } } } else if (n == max && (transition.getMonth() - 1 == n)) { int dom = transition.getDayOfMonth(); if (jdate.getDayOfMonth() >= dom) { set(DAY_OF_MONTH, dom - 1); } } } return; } case WEEK_OF_YEAR: { int y = jdate.getNormalizedYear(); max = getActualMaximum(WEEK_OF_YEAR); set(DAY_OF_WEEK, internalGet(DAY_OF_WEEK)); // update stamp[field] int woy = internalGet(WEEK_OF_YEAR); int value = woy + amount; if (!isTransitionYear(jdate.getNormalizedYear())) { int year = jdate.getYear(); if (year == getMaximum(YEAR)) { max = getActualMaximum(WEEK_OF_YEAR); } else if (year == getMinimum(YEAR)) { min = getActualMinimum(WEEK_OF_YEAR); max = getActualMaximum(WEEK_OF_YEAR); if (value > min && value < max) { set(WEEK_OF_YEAR, value); return; } } // If the new value is in between min and max // (exclusive), then we can use the value. if (value > min && value < max) { set(WEEK_OF_YEAR, value); return; } long fd = cachedFixedDate; // Make sure that the min week has the current DAY_OF_WEEK long day1 = fd - (7 * (woy - min)); if (year != getMinimum(YEAR)) { if (gcal.getYearFromFixedDate(day1) != y) { min++; } } else { CalendarDate d = jcal.getCalendarDate(Long.MIN_VALUE, getZone()); if (day1 < jcal.getFixedDate(d)) { min++; } } // Make sure the same thing for the max week fd += 7 * (max - internalGet(WEEK_OF_YEAR)); if (gcal.getYearFromFixedDate(fd) != y) { max--; } break; } // Handle transition here. long fd = cachedFixedDate; long day1 = fd - (7 * (woy - min)); // Make sure that the min week has the current DAY_OF_WEEK LocalGregorianCalendar.Date d = getCalendarDate(day1); if (!(d.getEra() == jdate.getEra() && d.getYear() == jdate.getYear())) { min++; } // Make sure the same thing for the max week fd += 7 * (max - woy); jcal.getCalendarDateFromFixedDate(d, fd); if (!(d.getEra() == jdate.getEra() && d.getYear() == jdate.getYear())) { max--; } // value: the new WEEK_OF_YEAR which must be converted // to month and day of month. value = getRolledValue(woy, amount, min, max) - 1; d = getCalendarDate(day1 + value * 7); set(MONTH, d.getMonth() - 1); set(DAY_OF_MONTH, d.getDayOfMonth()); return; } case WEEK_OF_MONTH: { boolean isTransitionYear = isTransitionYear(jdate.getNormalizedYear()); // dow: relative day of week from the first day of week int dow = internalGet(DAY_OF_WEEK) - getFirstDayOfWeek(); if (dow < 0) { dow += 7; } long fd = cachedFixedDate; long month1; // fixed date of the first day (usually 1) of the month int monthLength; // actual month length if (isTransitionYear) { month1 = getFixedDateMonth1(jdate, fd); monthLength = actualMonthLength(); } else { month1 = fd - internalGet(DAY_OF_MONTH) + 1; monthLength = jcal.getMonthLength(jdate); } // the first day of week of the month. long monthDay1st = jcal.getDayOfWeekDateOnOrBefore(month1 + 6, getFirstDayOfWeek()); // if the week has enough days to form a week, the // week starts from the previous month. if ((int)(monthDay1st - month1) >= getMinimalDaysInFirstWeek()) { monthDay1st -= 7; } max = getActualMaximum(field); // value: the new WEEK_OF_MONTH value int value = getRolledValue(internalGet(field), amount, 1, max) - 1; // nfd: fixed date of the rolled date long nfd = monthDay1st + value * 7 + dow; // Unlike WEEK_OF_YEAR, we need to change day of week if the // nfd is out of the month. if (nfd < month1) { nfd = month1; } else if (nfd >= (month1 + monthLength)) { nfd = month1 + monthLength - 1; } set(DAY_OF_MONTH, (int)(nfd - month1) + 1); return; } case DAY_OF_MONTH: { if (!isTransitionYear(jdate.getNormalizedYear())) { max = jcal.getMonthLength(jdate); break; } // TODO: Need to change the spec to be usable DAY_OF_MONTH rolling... // Transition handling. We can't change year and era // values here due to the Calendar roll spec! long month1 = getFixedDateMonth1(jdate, cachedFixedDate); // It may not be a regular month. Convert the date and range to // the relative values, perform the roll, and // convert the result back to the rolled date. int value = getRolledValue((int)(cachedFixedDate - month1), amount, 0, actualMonthLength() - 1); LocalGregorianCalendar.Date d = getCalendarDate(month1 + value); assert getEraIndex(d) == internalGetEra() && d.getYear() == internalGet(YEAR) && d.getMonth()-1 == internalGet(MONTH); set(DAY_OF_MONTH, d.getDayOfMonth()); return; } case DAY_OF_YEAR: { max = getActualMaximum(field); if (!isTransitionYear(jdate.getNormalizedYear())) { break; } // Handle transition. We can't change year and era values // here due to the Calendar roll spec. int value = getRolledValue(internalGet(DAY_OF_YEAR), amount, min, max); long jan0 = cachedFixedDate - internalGet(DAY_OF_YEAR); LocalGregorianCalendar.Date d = getCalendarDate(jan0 + value); assert getEraIndex(d) == internalGetEra() && d.getYear() == internalGet(YEAR); set(MONTH, d.getMonth() - 1); set(DAY_OF_MONTH, d.getDayOfMonth()); return; } case DAY_OF_WEEK: { int normalizedYear = jdate.getNormalizedYear(); if (!isTransitionYear(normalizedYear) && !isTransitionYear(normalizedYear - 1)) { // If the week of year is in the same year, we can // just change DAY_OF_WEEK. int weekOfYear = internalGet(WEEK_OF_YEAR); if (weekOfYear > 1 && weekOfYear < 52) { set(WEEK_OF_YEAR, internalGet(WEEK_OF_YEAR)); max = SATURDAY; break; } } // We need to handle it in a different way around year // boundaries and in the transition year. Note that // changing era and year values violates the roll // rule: not changing larger calendar fields... amount %= 7; if (amount == 0) { return; } long fd = cachedFixedDate; long dowFirst = jcal.getDayOfWeekDateOnOrBefore(fd, getFirstDayOfWeek()); fd += amount; if (fd < dowFirst) { fd += 7; } else if (fd >= dowFirst + 7) { fd -= 7; } LocalGregorianCalendar.Date d = getCalendarDate(fd); set(ERA, getEraIndex(d)); set(d.getYear(), d.getMonth() - 1, d.getDayOfMonth()); return; } case DAY_OF_WEEK_IN_MONTH: { min = 1; // after having normalized, min should be 1. if (!isTransitionYear(jdate.getNormalizedYear())) { int dom = internalGet(DAY_OF_MONTH); int monthLength = jcal.getMonthLength(jdate); int lastDays = monthLength % 7; max = monthLength / 7; int x = (dom - 1) % 7; if (x < lastDays) { max++; } set(DAY_OF_WEEK, internalGet(DAY_OF_WEEK)); break; } // Transition year handling. long fd = cachedFixedDate; long month1 = getFixedDateMonth1(jdate, fd); int monthLength = actualMonthLength(); int lastDays = monthLength % 7; max = monthLength / 7; int x = (int)(fd - month1) % 7; if (x < lastDays) { max++; } int value = getRolledValue(internalGet(field), amount, min, max) - 1; fd = month1 + value * 7 + x; LocalGregorianCalendar.Date d = getCalendarDate(fd); set(DAY_OF_MONTH, d.getDayOfMonth()); return; } } set(field, getRolledValue(internalGet(field), amount, min, max)); }
// in java-util/JapaneseImperialCalendar.java
protected void computeTime() { // In non-lenient mode, perform brief checking of calendar // fields which have been set externally. Through this // checking, the field values are stored in originalFields[] // to see if any of them are normalized later. if (!isLenient()) { if (originalFields == null) { originalFields = new int[FIELD_COUNT]; } for (int field = 0; field < FIELD_COUNT; field++) { int value = internalGet(field); if (isExternallySet(field)) { // Quick validation for any out of range values if (value < getMinimum(field) || value > getMaximum(field)) { throw new IllegalArgumentException(getFieldName(field)); } } originalFields[field] = value; } } // Let the super class determine which calendar fields to be // used to calculate the time. int fieldMask = selectFields(); int year; int era; if (isSet(ERA)) { era = internalGet(ERA); year = isSet(YEAR) ? internalGet(YEAR) : 1; } else { if (isSet(YEAR)) { era = eras.length - 1; year = internalGet(YEAR); } else { // Equivalent to 1970 (Gregorian) era = SHOWA; year = 45; } } // Calculate the time of day. We rely on the convention that // an UNSET field has 0. long timeOfDay = 0; if (isFieldSet(fieldMask, HOUR_OF_DAY)) { timeOfDay += (long) internalGet(HOUR_OF_DAY); } else { timeOfDay += internalGet(HOUR); // The default value of AM_PM is 0 which designates AM. if (isFieldSet(fieldMask, AM_PM)) { timeOfDay += 12 * internalGet(AM_PM); } } timeOfDay *= 60; timeOfDay += internalGet(MINUTE); timeOfDay *= 60; timeOfDay += internalGet(SECOND); timeOfDay *= 1000; timeOfDay += internalGet(MILLISECOND); // Convert the time of day to the number of days and the // millisecond offset from midnight. long fixedDate = timeOfDay / ONE_DAY; timeOfDay %= ONE_DAY; while (timeOfDay < 0) { timeOfDay += ONE_DAY; --fixedDate; } // Calculate the fixed date since January 1, 1 (Gregorian). fixedDate += getFixedDate(era, year, fieldMask); // millis represents local wall-clock time in milliseconds. long millis = (fixedDate - EPOCH_OFFSET) * ONE_DAY + timeOfDay; // Compute the time zone offset and DST offset. There are two potential // ambiguities here. We'll assume a 2:00 am (wall time) switchover time // for discussion purposes here. // 1. The transition into DST. Here, a designated time of 2:00 am - 2:59 am // can be in standard or in DST depending. However, 2:00 am is an invalid // representation (the representation jumps from 1:59:59 am Std to 3:00:00 am DST). // We assume standard time. // 2. The transition out of DST. Here, a designated time of 1:00 am - 1:59 am // can be in standard or DST. Both are valid representations (the rep // jumps from 1:59:59 DST to 1:00:00 Std). // Again, we assume standard time. // We use the TimeZone object, unless the user has explicitly set the ZONE_OFFSET // or DST_OFFSET fields; then we use those fields. TimeZone zone = getZone(); if (zoneOffsets == null) { zoneOffsets = new int[2]; } int tzMask = fieldMask & (ZONE_OFFSET_MASK|DST_OFFSET_MASK); if (tzMask != (ZONE_OFFSET_MASK|DST_OFFSET_MASK)) { if (zone instanceof ZoneInfo) { ((ZoneInfo)zone).getOffsetsByWall(millis, zoneOffsets); } else { zone.getOffsets(millis - zone.getRawOffset(), zoneOffsets); } } if (tzMask != 0) { if (isFieldSet(tzMask, ZONE_OFFSET)) { zoneOffsets[0] = internalGet(ZONE_OFFSET); } if (isFieldSet(tzMask, DST_OFFSET)) { zoneOffsets[1] = internalGet(DST_OFFSET); } } // Adjust the time zone offset values to get the UTC time. millis -= zoneOffsets[0] + zoneOffsets[1]; // Set this calendar's time in milliseconds time = millis; int mask = computeFields(fieldMask | getSetStateFields(), tzMask); if (!isLenient()) { for (int field = 0; field < FIELD_COUNT; field++) { if (!isExternallySet(field)) { continue; } if (originalFields[field] != internalGet(field)) { int wrongValue = internalGet(field); // Restore the original field values System.arraycopy(originalFields, 0, fields, 0, fields.length); throw new IllegalArgumentException(getFieldName(field) + "=" + wrongValue + ", expected " + originalFields[field]); } } } setFieldsNormalized(mask); }
// in java-util/SimpleTimeZone.java
public int getOffset(int era, int year, int month, int day, int dayOfWeek, int millis) { if (era != GregorianCalendar.AD && era != GregorianCalendar.BC) { throw new IllegalArgumentException("Illegal era " + era); } int y = year; if (era == GregorianCalendar.BC) { // adjust y with the GregorianCalendar-style year numbering. y = 1 - y; } // If the year isn't representable with the 64-bit long // integer in milliseconds, convert the year to an // equivalent year. This is required to pass some JCK test cases // which are actually useless though because the specified years // can't be supported by the Java time system. if (y >= 292278994) { y = 2800 + y % 2800; } else if (y <= -292269054) { // y %= 28 also produces an equivalent year, but positive // year numbers would be convenient to use the UNIX cal // command. y = (int) CalendarUtils.mod((long) y, 28); } // convert year to its 1-based month value int m = month + 1; // First, calculate time as a Gregorian date. BaseCalendar cal = gcal; BaseCalendar.Date cdate = (BaseCalendar.Date) cal.newCalendarDate(TimeZone.NO_TIMEZONE); cdate.setDate(y, m, day); long time = cal.getTime(cdate); // normalize cdate time += millis - rawOffset; // UTC time // If the time value represents a time before the default // Gregorian cutover, recalculate time using the Julian // calendar system. For the Julian calendar system, the // normalized year numbering is ..., -2 (BCE 2), -1 (BCE 1), // 1, 2 ... which is different from the GregorianCalendar // style year numbering (..., -1, 0 (BCE 1), 1, 2, ...). if (time < GregorianCalendar.DEFAULT_GREGORIAN_CUTOVER) { cal = (BaseCalendar) CalendarSystem.forName("julian"); cdate = (BaseCalendar.Date) cal.newCalendarDate(TimeZone.NO_TIMEZONE); cdate.setNormalizedDate(y, m, day); time = cal.getTime(cdate) + millis - rawOffset; } if ((cdate.getNormalizedYear() != y) || (cdate.getMonth() != m) || (cdate.getDayOfMonth() != day) // The validation should be cdate.getDayOfWeek() == // dayOfWeek. However, we don't check dayOfWeek for // compatibility. || (dayOfWeek < Calendar.SUNDAY || dayOfWeek > Calendar.SATURDAY) || (millis < 0 || millis >= (24*60*60*1000))) { throw new IllegalArgumentException(); } if (!useDaylight || year < startYear || era != GregorianCalendar.CE) { return rawOffset; } return getOffset(cal, cdate, y, time); }
// in java-util/SimpleTimeZone.java
public void setDSTSavings(int millisSavedDuringDST) { if (millisSavedDuringDST <= 0) { throw new IllegalArgumentException("Illegal daylight saving value: " + millisSavedDuringDST); } dstSavings = millisSavedDuringDST; }
// in java-util/SimpleTimeZone.java
private void decodeStartRule() { useDaylight = (startDay != 0) && (endDay != 0); if (startDay != 0) { if (startMonth < Calendar.JANUARY || startMonth > Calendar.DECEMBER) { throw new IllegalArgumentException( "Illegal start month " + startMonth); } if (startTime < 0 || startTime > millisPerDay) { throw new IllegalArgumentException( "Illegal start time " + startTime); } if (startDayOfWeek == 0) { startMode = DOM_MODE; } else { if (startDayOfWeek > 0) { startMode = DOW_IN_MONTH_MODE; } else { startDayOfWeek = -startDayOfWeek; if (startDay > 0) { startMode = DOW_GE_DOM_MODE; } else { startDay = -startDay; startMode = DOW_LE_DOM_MODE; } } if (startDayOfWeek > Calendar.SATURDAY) { throw new IllegalArgumentException( "Illegal start day of week " + startDayOfWeek); } } if (startMode == DOW_IN_MONTH_MODE) { if (startDay < -5 || startDay > 5) { throw new IllegalArgumentException( "Illegal start day of week in month " + startDay); } } else if (startDay < 1 || startDay > staticMonthLength[startMonth]) { throw new IllegalArgumentException( "Illegal start day " + startDay); } } }
// in java-util/SimpleTimeZone.java
private void decodeEndRule() { useDaylight = (startDay != 0) && (endDay != 0); if (endDay != 0) { if (endMonth < Calendar.JANUARY || endMonth > Calendar.DECEMBER) { throw new IllegalArgumentException( "Illegal end month " + endMonth); } if (endTime < 0 || endTime > millisPerDay) { throw new IllegalArgumentException( "Illegal end time " + endTime); } if (endDayOfWeek == 0) { endMode = DOM_MODE; } else { if (endDayOfWeek > 0) { endMode = DOW_IN_MONTH_MODE; } else { endDayOfWeek = -endDayOfWeek; if (endDay > 0) { endMode = DOW_GE_DOM_MODE; } else { endDay = -endDay; endMode = DOW_LE_DOM_MODE; } } if (endDayOfWeek > Calendar.SATURDAY) { throw new IllegalArgumentException( "Illegal end day of week " + endDayOfWeek); } } if (endMode == DOW_IN_MONTH_MODE) { if (endDay < -5 || endDay > 5) { throw new IllegalArgumentException( "Illegal end day of week in month " + endDay); } } else if (endDay < 1 || endDay > staticMonthLength[endMonth]) { throw new IllegalArgumentException( "Illegal end day " + endDay); } } }
// in java-util/UUID.java
public static UUID fromString(String name) { String[] components = name.split("-"); if (components.length != 5) throw new IllegalArgumentException("Invalid UUID string: "+name); for (int i=0; i<5; i++) components[i] = "0x"+components[i]; long mostSigBits = Long.decode(components[0]).longValue(); mostSigBits <<= 16; mostSigBits |= Long.decode(components[1]).longValue(); mostSigBits <<= 16; mostSigBits |= Long.decode(components[2]).longValue(); long leastSigBits = Long.decode(components[3]).longValue(); leastSigBits <<= 48; leastSigBits |= Long.decode(components[4]).longValue(); return new UUID(mostSigBits, leastSigBits); }
// in java-util/ResourceBundle.java
private static ResourceBundle getBundleImpl(String baseName, Locale locale, ClassLoader loader, Control control) { if (locale == null || control == null) { throw new NullPointerException(); } // We create a CacheKey here for use by this call. The base // name and loader will never change during the bundle loading // process. We have to make sure that the locale is set before // using it as a cache key. CacheKey cacheKey = new CacheKey(baseName, locale, loader); ResourceBundle bundle = null; // Quick lookup of the cache. BundleReference bundleRef = cacheList.get(cacheKey); if (bundleRef != null) { bundle = bundleRef.get(); bundleRef = null; } // If this bundle and all of its parents are valid (not expired), // then return this bundle. If any of the bundles is expired, we // don't call control.needsReload here but instead drop into the // complete loading process below. if (isValidBundle(bundle) && hasValidParentChain(bundle)) { return bundle; } // No valid bundle was found in the cache, so we need to load the // resource bundle and its parents. boolean isKnownControl = (control == Control.INSTANCE) || (control instanceof SingleFormatControl); List<String> formats = control.getFormats(baseName); if (!isKnownControl && !checkList(formats)) { throw new IllegalArgumentException("Invalid Control: getFormats"); } ResourceBundle baseBundle = null; for (Locale targetLocale = locale; targetLocale != null; targetLocale = control.getFallbackLocale(baseName, targetLocale)) { List<Locale> candidateLocales = control.getCandidateLocales(baseName, targetLocale); if (!isKnownControl && !checkList(candidateLocales)) { throw new IllegalArgumentException("Invalid Control: getCandidateLocales"); } bundle = findBundle(cacheKey, candidateLocales, formats, 0, control, baseBundle); // If the loaded bundle is the base bundle and exactly for the // requested locale or the only candidate locale, then take the // bundle as the resulting one. If the loaded bundle is the base // bundle, it's put on hold until we finish processing all // fallback locales. if (isValidBundle(bundle)) { boolean isBaseBundle = Locale.ROOT.equals(bundle.locale); if (!isBaseBundle || bundle.locale.equals(locale) || (candidateLocales.size() == 1 && bundle.locale.equals(candidateLocales.get(0)))) { break; } // If the base bundle has been loaded, keep the reference in // baseBundle so that we can avoid any redundant loading in case // the control specify not to cache bundles. if (isBaseBundle && baseBundle == null) { baseBundle = bundle; } } } if (bundle == null) { if (baseBundle == null) { throwMissingResourceException(baseName, locale, cacheKey.getCause()); } bundle = baseBundle; } return bundle; }
// in java-util/ResourceBundle.java
private static final void setExpirationTime(CacheKey cacheKey, Control control) { long ttl = control.getTimeToLive(cacheKey.getName(), cacheKey.getLocale()); if (ttl >= 0) { // If any expiration time is specified, set the time to be // expired in the cache. long now = System.currentTimeMillis(); cacheKey.loadTime = now; cacheKey.expirationTime = now + ttl; } else if (ttl >= Control.TTL_NO_EXPIRATION_CONTROL) { cacheKey.expirationTime = ttl; } else { throw new IllegalArgumentException("Invalid Control: TTL=" + ttl); } }
// in java-util/ResourceBundle.java
public static final Control getControl(List<String> formats) { if (formats.equals(Control.FORMAT_PROPERTIES)) { return SingleFormatControl.PROPERTIES_ONLY; } if (formats.equals(Control.FORMAT_CLASS)) { return SingleFormatControl.CLASS_ONLY; } if (formats.equals(Control.FORMAT_DEFAULT)) { return Control.INSTANCE; } throw new IllegalArgumentException(); }
// in java-util/ResourceBundle.java
public static final Control getNoFallbackControl(List<String> formats) { if (formats.equals(Control.FORMAT_DEFAULT)) { return NoFallbackControl.NO_FALLBACK; } if (formats.equals(Control.FORMAT_PROPERTIES)) { return NoFallbackControl.PROPERTIES_ONLY_NO_FALLBACK; } if (formats.equals(Control.FORMAT_CLASS)) { return NoFallbackControl.CLASS_ONLY_NO_FALLBACK; } throw new IllegalArgumentException(); }
// in java-util/TreeMap.java
public final V put(K key, V value) { if (!inRange(key)) throw new IllegalArgumentException("key out of range"); return m.put(key, value); }
// in java-util/TreeMap.java
public NavigableMap<K,V> subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) { if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range"); if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey out of range"); return new AscendingSubMap(m, false, fromKey, fromInclusive, false, toKey, toInclusive); }
// in java-util/TreeMap.java
public NavigableMap<K,V> headMap(K toKey, boolean inclusive) { if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range"); return new AscendingSubMap(m, fromStart, lo, loInclusive, false, toKey, inclusive); }
// in java-util/TreeMap.java
public NavigableMap<K,V> tailMap(K fromKey, boolean inclusive){ if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range"); return new AscendingSubMap(m, false, fromKey, inclusive, toEnd, hi, hiInclusive); }
// in java-util/TreeMap.java
public NavigableMap<K,V> subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) { if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range"); if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey out of range"); return new DescendingSubMap(m, false, toKey, toInclusive, false, fromKey, fromInclusive); }
// in java-util/TreeMap.java
public NavigableMap<K,V> headMap(K toKey, boolean inclusive) { if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range"); return new DescendingSubMap(m, false, toKey, inclusive, toEnd, hi, hiInclusive); }
// in java-util/TreeMap.java
public NavigableMap<K,V> tailMap(K fromKey, boolean inclusive){ if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range"); return new DescendingSubMap(m, fromStart, lo, loInclusive, false, fromKey, inclusive); }
// in java-util/Currency.java
private static Currency getInstance(String currencyCode, int defaultFractionDigits) { synchronized (instances) { // Try to look up the currency code in the instances table. // This does the null pointer check as a side effect. // Also, if there already is an entry, the currencyCode must be valid. Currency instance = (Currency) instances.get(currencyCode); if (instance != null) { return instance; } if (defaultFractionDigits == Integer.MIN_VALUE) { // Currency code not internally generated, need to verify first // A currency code must have 3 characters and exist in the main table // or in the list of other currencies. if (currencyCode.length() != 3) { throw new IllegalArgumentException(); } char char1 = currencyCode.charAt(0); char char2 = currencyCode.charAt(1); int tableEntry = getMainTableEntry(char1, char2); if ((tableEntry & COUNTRY_TYPE_MASK) == SIMPLE_CASE_COUNTRY_MASK && tableEntry != INVALID_COUNTRY_ENTRY && currencyCode.charAt(2) - 'A' == (tableEntry & SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK)) { defaultFractionDigits = (tableEntry & SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK) >> SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT; } else { // Check for '-' separately so we don't get false hits in the table. if (currencyCode.charAt(2) == '-') { throw new IllegalArgumentException(); } int index = otherCurrencies.indexOf(currencyCode); if (index == -1) { throw new IllegalArgumentException(); } defaultFractionDigits = otherCurrenciesDFD[index / 4]; } } instance = new Currency(currencyCode, defaultFractionDigits); instances.put(currencyCode, instance); return instance; } }
// in java-util/Currency.java
public static Currency getInstance(Locale locale) { String country = locale.getCountry(); if (country == null) { throw new NullPointerException(); } if (country.length() != 2) { throw new IllegalArgumentException(); } char char1 = country.charAt(0); char char2 = country.charAt(1); int tableEntry = getMainTableEntry(char1, char2); if ((tableEntry & COUNTRY_TYPE_MASK) == SIMPLE_CASE_COUNTRY_MASK && tableEntry != INVALID_COUNTRY_ENTRY) { char finalChar = (char) ((tableEntry & SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK) + 'A'); int defaultFractionDigits = (tableEntry & SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK) >> SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT; StringBuffer sb = new StringBuffer(country); sb.append(finalChar); return getInstance(sb.toString(), defaultFractionDigits); } else { // special cases if (tableEntry == INVALID_COUNTRY_ENTRY) { throw new IllegalArgumentException(); } if (tableEntry == COUNTRY_WITHOUT_CURRENCY_ENTRY) { return null; } else { int index = (tableEntry & SPECIAL_CASE_COUNTRY_INDEX_MASK) - SPECIAL_CASE_COUNTRY_INDEX_DELTA; if (scCutOverTimes[index] == Long.MAX_VALUE || System.currentTimeMillis() < scCutOverTimes[index]) { return getInstance(scOldCurrencies[index], scOldCurrenciesDFD[index]); } else { return getInstance(scNewCurrencies[index], scNewCurrenciesDFD[index]); } } } }
// in java-util/Currency.java
private static int getMainTableEntry(char char1, char char2) { if (char1 < 'A' || char1 > 'Z' || char2 < 'A' || char2 > 'Z') { throw new IllegalArgumentException(); } return mainTable.charAt((char1 - 'A') * A_TO_Z + (char2 - 'A')); }
// in java-util/Scanner.java
private static Readable makeReadable(ReadableByteChannel source, String charsetName) { if (source == null) throw new NullPointerException("source"); if (!Charset.isSupported(charsetName)) throw new IllegalArgumentException(charsetName); return Channels.newReader(source, charsetName); }
// in java-util/Scanner.java
public Scanner useRadix(int radix) { if ((radix < Character.MIN_RADIX) || (radix > Character.MAX_RADIX)) throw new IllegalArgumentException("radix:"+radix); if (this.defaultRadix == radix) return this; this.defaultRadix = radix; // Force rebuilding and recompilation of radix dependent patterns integerPattern = null; return this; }
// in java-util/Scanner.java
public String findWithinHorizon(Pattern pattern, int horizon) { ensureOpen(); if (pattern == null) throw new NullPointerException(); if (horizon < 0) throw new IllegalArgumentException("horizon < 0"); clearCaches(); // Search for the pattern while (true) { String token = findPatternInBuffer(pattern, horizon); if (token != null) { matchValid = true; return token; } if (needInput) readInput(); else break; // up to end of input } return null; }
// in java-util/Timer.java
public void schedule(TimerTask task, long delay) { if (delay < 0) throw new IllegalArgumentException("Negative delay."); sched(task, System.currentTimeMillis()+delay, 0); }
// in java-util/Timer.java
public void schedule(TimerTask task, long delay, long period) { if (delay < 0) throw new IllegalArgumentException("Negative delay."); if (period <= 0) throw new IllegalArgumentException("Non-positive period."); sched(task, System.currentTimeMillis()+delay, -period); }
// in java-util/Timer.java
public void schedule(TimerTask task, Date firstTime, long period) { if (period <= 0) throw new IllegalArgumentException("Non-positive period."); sched(task, firstTime.getTime(), -period); }
// in java-util/Timer.java
public void scheduleAtFixedRate(TimerTask task, long delay, long period) { if (delay < 0) throw new IllegalArgumentException("Negative delay."); if (period <= 0) throw new IllegalArgumentException("Non-positive period."); sched(task, System.currentTimeMillis()+delay, period); }
// in java-util/Timer.java
public void scheduleAtFixedRate(TimerTask task, Date firstTime, long period) { if (period <= 0) throw new IllegalArgumentException("Non-positive period."); sched(task, firstTime.getTime(), period); }
// in java-util/Timer.java
private void sched(TimerTask task, long time, long period) { if (time < 0) throw new IllegalArgumentException("Illegal execution time."); synchronized(queue) { if (!thread.newTasksMayBeScheduled) throw new IllegalStateException("Timer already cancelled."); synchronized(task.lock) { if (task.state != TimerTask.VIRGIN) throw new IllegalStateException( "Task already scheduled or cancelled"); task.nextExecutionTime = time; task.period = period; task.state = TimerTask.SCHEDULED; } queue.add(task); if (queue.getMin() == task) queue.notify(); } }
// in java-util/Random.java
public int nextInt(int n) { if (n <= 0) throw new IllegalArgumentException("n must be positive"); if ((n & -n) == n) // i.e., n is a power of 2 return (int)((n * (long)next(31)) >> 31); int bits, val; do { bits = next(31); val = bits % n; } while (bits - val + (n-1) < 0); return val; }
// in java-util/AbstractQueue.java
public boolean addAll(Collection<? extends E> c) { if (c == null) throw new NullPointerException(); if (c == this) throw new IllegalArgumentException(); boolean modified = false; Iterator<? extends E> e = c.iterator(); while (e.hasNext()) { if (add(e.next())) modified = true; } return modified; }
// in java-util/Arrays.java
private static void rangeCheck(int arrayLen, int fromIndex, int toIndex) { if (fromIndex > toIndex) throw new IllegalArgumentException("fromIndex(" + fromIndex + ") > toIndex(" + toIndex+")"); if (fromIndex < 0) throw new ArrayIndexOutOfBoundsException(fromIndex); if (toIndex > arrayLen) throw new ArrayIndexOutOfBoundsException(toIndex); }
// in java-util/Arrays.java
public static <T,U> T[] copyOfRange(U[] original, int from, int to, Class<? extends T[]> newType) { int newLength = to - from; if (newLength < 0) throw new IllegalArgumentException(from + " > " + to); T[] copy = ((Object)newType == (Object)Object[].class) ? (T[]) new Object[newLength] : (T[]) Array.newInstance(newType.getComponentType(), newLength); System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength)); return copy; }
// in java-util/Arrays.java
public static byte[] copyOfRange(byte[] original, int from, int to) { int newLength = to - from; if (newLength < 0) throw new IllegalArgumentException(from + " > " + to); byte[] copy = new byte[newLength]; System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength)); return copy; }
// in java-util/Arrays.java
public static short[] copyOfRange(short[] original, int from, int to) { int newLength = to - from; if (newLength < 0) throw new IllegalArgumentException(from + " > " + to); short[] copy = new short[newLength]; System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength)); return copy; }
// in java-util/Arrays.java
public static int[] copyOfRange(int[] original, int from, int to) { int newLength = to - from; if (newLength < 0) throw new IllegalArgumentException(from + " > " + to); int[] copy = new int[newLength]; System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength)); return copy; }
// in java-util/Arrays.java
public static long[] copyOfRange(long[] original, int from, int to) { int newLength = to - from; if (newLength < 0) throw new IllegalArgumentException(from + " > " + to); long[] copy = new long[newLength]; System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength)); return copy; }
// in java-util/Arrays.java
public static char[] copyOfRange(char[] original, int from, int to) { int newLength = to - from; if (newLength < 0) throw new IllegalArgumentException(from + " > " + to); char[] copy = new char[newLength]; System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength)); return copy; }
// in java-util/Arrays.java
public static float[] copyOfRange(float[] original, int from, int to) { int newLength = to - from; if (newLength < 0) throw new IllegalArgumentException(from + " > " + to); float[] copy = new float[newLength]; System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength)); return copy; }
// in java-util/Arrays.java
public static double[] copyOfRange(double[] original, int from, int to) { int newLength = to - from; if (newLength < 0) throw new IllegalArgumentException(from + " > " + to); double[] copy = new double[newLength]; System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength)); return copy; }
// in java-util/Arrays.java
public static boolean[] copyOfRange(boolean[] original, int from, int to) { int newLength = to - from; if (newLength < 0) throw new IllegalArgumentException(from + " > " + to); boolean[] copy = new boolean[newLength]; System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength)); return copy; }
// in java-util/EnumSet.java
public static <E extends Enum<E>> EnumSet<E> copyOf(Collection<E> c) { if (c instanceof EnumSet) { return ((EnumSet<E>)c).clone(); } else { if (c.isEmpty()) throw new IllegalArgumentException("Collection is empty"); Iterator<E> i = c.iterator(); E first = i.next(); EnumSet<E> result = EnumSet.of(first); while (i.hasNext()) result.add(i.next()); return result; } }
// in java-util/EnumSet.java
public static <E extends Enum<E>> EnumSet<E> range(E from, E to) { if (from.compareTo(to) > 0) throw new IllegalArgumentException(from + " > " + to); EnumSet<E> result = noneOf(from.getDeclaringClass()); result.addRange(from, to); return result; }
// in java-util/TimeZone.java
public String getDisplayName(boolean daylight, int style, Locale locale) { if (style != SHORT && style != LONG) { throw new IllegalArgumentException("Illegal style: " + style); } String id = getID(); String[] names = getDisplayNames(id, locale); if (names == null) { if (id.startsWith("GMT")) { char sign = id.charAt(3); if (sign == '+' || sign == '-') { return id; } } int offset = getRawOffset(); if (daylight) { offset += getDSTSavings(); } return ZoneInfoFile.toCustomID(offset); } int index = daylight ? 3 : 1; if (style == SHORT) { index++; } return names[index]; }
// in java-util/Properties.java
private String loadConvert (char[] in, int off, int len, char[] convtBuf) { if (convtBuf.length < len) { int newLen = len * 2; if (newLen < 0) { newLen = Integer.MAX_VALUE; } convtBuf = new char[newLen]; } char aChar; char[] out = convtBuf; int outLen = 0; int end = off + len; while (off < end) { aChar = in[off++]; if (aChar == '\\') { aChar = in[off++]; if(aChar == 'u') { // Read the xxxx int value=0; for (int i=0; i<4; i++) { aChar = in[off++]; switch (aChar) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': value = (value << 4) + aChar - '0'; break; case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': value = (value << 4) + 10 + aChar - 'a'; break; case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': value = (value << 4) + 10 + aChar - 'A'; break; default: throw new IllegalArgumentException( "Malformed \\uxxxx encoding."); } } out[outLen++] = (char)value; } else { if (aChar == 't') aChar = '\t'; else if (aChar == 'r') aChar = '\r'; else if (aChar == 'n') aChar = '\n'; else if (aChar == 'f') aChar = '\f'; out[outLen++] = aChar; } } else { out[outLen++] = (char)aChar; } } return new String (out, 0, outLen); }
// in java-util/PropertyPermission.java
private void init(int mask) { if ((mask & ALL) != mask) throw new IllegalArgumentException("invalid actions mask"); if (mask == NONE) throw new IllegalArgumentException("invalid actions mask"); if (getName() == null) throw new NullPointerException("name can't be null"); this.mask = mask; }
// in java-util/PropertyPermission.java
private static int getMask(String actions) { int mask = NONE; if (actions == null) { return mask; } // Check against use of constants (used heavily within the JDK) if (actions == SecurityConstants.PROPERTY_READ_ACTION) { return READ; } if (actions == SecurityConstants.PROPERTY_WRITE_ACTION) { return WRITE; } else if (actions == SecurityConstants.PROPERTY_RW_ACTION) { return READ|WRITE; } char[] a = actions.toCharArray(); int i = a.length - 1; if (i < 0) return mask; while (i != -1) { char c; // skip whitespace while ((i!=-1) && ((c = a[i]) == ' ' || c == '\r' || c == '\n' || c == '\f' || c == '\t')) i--; // check for the known strings int matchlen; if (i >= 3 && (a[i-3] == 'r' || a[i-3] == 'R') && (a[i-2] == 'e' || a[i-2] == 'E') && (a[i-1] == 'a' || a[i-1] == 'A') && (a[i] == 'd' || a[i] == 'D')) { matchlen = 4; mask |= READ; } else if (i >= 4 && (a[i-4] == 'w' || a[i-4] == 'W') && (a[i-3] == 'r' || a[i-3] == 'R') && (a[i-2] == 'i' || a[i-2] == 'I') && (a[i-1] == 't' || a[i-1] == 'T') && (a[i] == 'e' || a[i] == 'E')) { matchlen = 5; mask |= WRITE; } else { // parse error throw new IllegalArgumentException( "invalid permission: " + actions); } // make sure we didn't just match the tail of a word // like "ackbarfaccept". Also, skip to the comma. boolean seencomma = false; while (i >= matchlen && !seencomma) { switch(a[i-matchlen]) { case ',': seencomma = true; /*FALLTHROUGH*/ case ' ': case '\r': case '\n': case '\f': case '\t': break; default: throw new IllegalArgumentException( "invalid permission: " + actions); } i--; } // point i at the location of the comma minus one (or -1). i -= matchlen; } return mask; }
// in java-util/PropertyPermission.java
public void add(Permission permission) { if (! (permission instanceof PropertyPermission)) throw new IllegalArgumentException("invalid permission: "+ permission); if (isReadOnly()) throw new SecurityException( "attempt to add a Permission to a readonly PermissionCollection"); PropertyPermission pp = (PropertyPermission) permission; String propName = pp.getName(); synchronized (this) { PropertyPermission existing = (PropertyPermission) perms.get(propName); if (existing != null) { int oldMask = existing.getMask(); int newMask = pp.getMask(); if (oldMask != newMask) { int effective = oldMask | newMask; String actions = PropertyPermission.getActions(effective); perms.put(propName, new PropertyPermission(propName, actions)); } } else { perms.put(propName, permission); } } if (!all_allowed) { if (propName.equals("*")) all_allowed = true; } }
// in java-util/Collections.java
public static <T> List<T> nCopies(int n, T o) { if (n < 0) throw new IllegalArgumentException("List length = " + n); return new CopiesList<T>(n, o); }
// in java-util/Collections.java
public List<E> subList(int fromIndex, int toIndex) { if (fromIndex < 0) throw new IndexOutOfBoundsException("fromIndex = " + fromIndex); if (toIndex > n) throw new IndexOutOfBoundsException("toIndex = " + toIndex); if (fromIndex > toIndex) throw new IllegalArgumentException("fromIndex(" + fromIndex + ") > toIndex(" + toIndex + ")"); return new CopiesList(toIndex - fromIndex, element); }
// in java-util/Calendar.java
boolean checkDisplayNameParams(int field, int style, int minStyle, int maxStyle, Locale locale, int fieldMask) { if (field < 0 || field >= fields.length || style < minStyle || style > maxStyle) { throw new IllegalArgumentException(); } if (locale == null) { throw new NullPointerException(); } return isFieldSet(fieldMask, field); }
// in java-util/GregorianCalendar.java
public void add(int field, int amount) { // If amount == 0, do nothing even the given field is out of // range. This is tested by JCK. if (amount == 0) { return; // Do nothing! } if (field < 0 || field >= ZONE_OFFSET) { throw new IllegalArgumentException(); } // Sync the time and calendar fields. complete(); if (field == YEAR) { int year = internalGet(YEAR); if (internalGetEra() == CE) { year += amount; if (year > 0) { set(YEAR, year); } else { // year <= 0 set(YEAR, 1 - year); // if year == 0, you get 1 BCE. set(ERA, BCE); } } else { // era == BCE year -= amount; if (year > 0) { set(YEAR, year); } else { // year <= 0 set(YEAR, 1 - year); // if year == 0, you get 1 CE set(ERA, CE); } } pinDayOfMonth(); } else if (field == MONTH) { int month = internalGet(MONTH) + amount; int year = internalGet(YEAR); int y_amount; if (month >= 0) { y_amount = month/12; } else { y_amount = (month+1)/12 - 1; } if (y_amount != 0) { if (internalGetEra() == CE) { year += y_amount; if (year > 0) { set(YEAR, year); } else { // year <= 0 set(YEAR, 1 - year); // if year == 0, you get 1 BCE set(ERA, BCE); } } else { // era == BCE year -= y_amount; if (year > 0) { set(YEAR, year); } else { // year <= 0 set(YEAR, 1 - year); // if year == 0, you get 1 CE set(ERA, CE); } } } if (month >= 0) { set(MONTH, (int) (month % 12)); } else { // month < 0 month %= 12; if (month < 0) { month += 12; } set(MONTH, JANUARY + month); } pinDayOfMonth(); } else if (field == ERA) { int era = internalGet(ERA) + amount; if (era < 0) { era = 0; } if (era > 1) { era = 1; } set(ERA, era); } else { long delta = amount; long timeOfDay = 0; switch (field) { // Handle the time fields here. Convert the given // amount to milliseconds and call setTimeInMillis. case HOUR: case HOUR_OF_DAY: delta *= 60 * 60 * 1000; // hours to minutes break; case MINUTE: delta *= 60 * 1000; // minutes to seconds break; case SECOND: delta *= 1000; // seconds to milliseconds break; case MILLISECOND: break; // Handle week, day and AM_PM fields which involves // time zone offset change adjustment. Convert the // given amount to the number of days. case WEEK_OF_YEAR: case WEEK_OF_MONTH: case DAY_OF_WEEK_IN_MONTH: delta *= 7; break; case DAY_OF_MONTH: // synonym of DATE case DAY_OF_YEAR: case DAY_OF_WEEK: break; case AM_PM: // Convert the amount to the number of days (delta) // and +12 or -12 hours (timeOfDay). delta = amount / 2; timeOfDay = 12 * (amount % 2); break; } // The time fields don't require time zone offset change // adjustment. if (field >= HOUR) { setTimeInMillis(time + delta); return; } // The rest of the fields (week, day or AM_PM fields) // require time zone offset (both GMT and DST) change // adjustment. // Translate the current time to the fixed date and time // of the day. long fd = getCurrentFixedDate(); timeOfDay += internalGet(HOUR_OF_DAY); timeOfDay *= 60; timeOfDay += internalGet(MINUTE); timeOfDay *= 60; timeOfDay += internalGet(SECOND); timeOfDay *= 1000; timeOfDay += internalGet(MILLISECOND); if (timeOfDay >= ONE_DAY) { fd++; timeOfDay -= ONE_DAY; } else if (timeOfDay < 0) { fd--; timeOfDay += ONE_DAY; } fd += delta; // fd is the expected fixed date after the calculation int zoneOffset = internalGet(ZONE_OFFSET) + internalGet(DST_OFFSET); setTimeInMillis((fd - EPOCH_OFFSET) * ONE_DAY + timeOfDay - zoneOffset); zoneOffset -= internalGet(ZONE_OFFSET) + internalGet(DST_OFFSET); // If the time zone offset has changed, then adjust the difference. if (zoneOffset != 0) { setTimeInMillis(time + zoneOffset); long fd2 = getCurrentFixedDate(); // If the adjustment has changed the date, then take // the previous one. if (fd2 != fd) { setTimeInMillis(time - zoneOffset); } } } }
// in java-util/GregorianCalendar.java
public void roll(int field, int amount) { // If amount == 0, do nothing even the given field is out of // range. This is tested by JCK. if (amount == 0) { return; } if (field < 0 || field >= ZONE_OFFSET) { throw new IllegalArgumentException(); } // Sync the time and calendar fields. complete(); int min = getMinimum(field); int max = getMaximum(field); switch (field) { case AM_PM: case ERA: case YEAR: case MINUTE: case SECOND: case MILLISECOND: // These fields are handled simply, since they have fixed minima // and maxima. The field DAY_OF_MONTH is almost as simple. Other // fields are complicated, since the range within they must roll // varies depending on the date. break; case HOUR: case HOUR_OF_DAY: { int unit = max + 1; // 12 or 24 hours int h = internalGet(field); int nh = (h + amount) % unit; if (nh < 0) { nh += unit; } time += ONE_HOUR * (nh - h); // The day might have changed, which could happen if // the daylight saving time transition brings it to // the next day, although it's very unlikely. But we // have to make sure not to change the larger fields. CalendarDate d = calsys.getCalendarDate(time, getZone()); if (internalGet(DAY_OF_MONTH) != d.getDayOfMonth()) { d.setDate(internalGet(YEAR), internalGet(MONTH) + 1, internalGet(DAY_OF_MONTH)); if (field == HOUR) { assert (internalGet(AM_PM) == PM); d.addHours(+12); // restore PM } time = calsys.getTime(d); } int hourOfDay = d.getHours(); internalSet(field, hourOfDay % unit); if (field == HOUR) { internalSet(HOUR_OF_DAY, hourOfDay); } else { internalSet(AM_PM, hourOfDay / 12); internalSet(HOUR, hourOfDay % 12); } // Time zone offset and/or daylight saving might have changed. int zoneOffset = d.getZoneOffset(); int saving = d.getDaylightSaving(); internalSet(ZONE_OFFSET, zoneOffset - saving); internalSet(DST_OFFSET, saving); return; } case MONTH: // Rolling the month involves both pinning the final value to [0, 11] // and adjusting the DAY_OF_MONTH if necessary. We only adjust the // DAY_OF_MONTH if, after updating the MONTH field, it is illegal. // E.g., <jan31>.roll(MONTH, 1) -> <feb28> or <feb29>. { if (!isCutoverYear(cdate.getNormalizedYear())) { int mon = (internalGet(MONTH) + amount) % 12; if (mon < 0) { mon += 12; } set(MONTH, mon); // Keep the day of month in the range. We don't want to spill over // into the next month; e.g., we don't want jan31 + 1 mo -> feb31 -> // mar3. int monthLen = monthLength(mon); if (internalGet(DAY_OF_MONTH) > monthLen) { set(DAY_OF_MONTH, monthLen); } } else { // We need to take care of different lengths in // year and month due to the cutover. int yearLength = getActualMaximum(MONTH) + 1; int mon = (internalGet(MONTH) + amount) % yearLength; if (mon < 0) { mon += yearLength; } set(MONTH, mon); int monthLen = getActualMaximum(DAY_OF_MONTH); if (internalGet(DAY_OF_MONTH) > monthLen) { set(DAY_OF_MONTH, monthLen); } } return; } case WEEK_OF_YEAR: { int y = cdate.getNormalizedYear(); max = getActualMaximum(WEEK_OF_YEAR); set(DAY_OF_WEEK, internalGet(DAY_OF_WEEK)); int woy = internalGet(WEEK_OF_YEAR); int value = woy + amount; if (!isCutoverYear(y)) { // If the new value is in between min and max // (exclusive), then we can use the value. if (value > min && value < max) { set(WEEK_OF_YEAR, value); return; } long fd = getCurrentFixedDate(); // Make sure that the min week has the current DAY_OF_WEEK long day1 = fd - (7 * (woy - min)); if (calsys.getYearFromFixedDate(day1) != y) { min++; } // Make sure the same thing for the max week fd += 7 * (max - internalGet(WEEK_OF_YEAR)); if (calsys.getYearFromFixedDate(fd) != y) { max--; } break; } // Handle cutover here. long fd = getCurrentFixedDate(); BaseCalendar cal; if (gregorianCutoverYear == gregorianCutoverYearJulian) { cal = getCutoverCalendarSystem(); } else if (y == gregorianCutoverYear) { cal = gcal; } else { cal = getJulianCalendarSystem(); } long day1 = fd - (7 * (woy - min)); // Make sure that the min week has the current DAY_OF_WEEK if (cal.getYearFromFixedDate(day1) != y) { min++; } // Make sure the same thing for the max week fd += 7 * (max - woy); cal = (fd >= gregorianCutoverDate) ? gcal : getJulianCalendarSystem(); if (cal.getYearFromFixedDate(fd) != y) { max--; } // value: the new WEEK_OF_YEAR which must be converted // to month and day of month. value = getRolledValue(woy, amount, min, max) - 1; BaseCalendar.Date d = getCalendarDate(day1 + value * 7); set(MONTH, d.getMonth() - 1); set(DAY_OF_MONTH, d.getDayOfMonth()); return; } case WEEK_OF_MONTH: { boolean isCutoverYear = isCutoverYear(cdate.getNormalizedYear()); // dow: relative day of week from first day of week int dow = internalGet(DAY_OF_WEEK) - getFirstDayOfWeek(); if (dow < 0) { dow += 7; } long fd = getCurrentFixedDate(); long month1; // fixed date of the first day (usually 1) of the month int monthLength; // actual month length if (isCutoverYear) { month1 = getFixedDateMonth1(cdate, fd); monthLength = actualMonthLength(); } else { month1 = fd - internalGet(DAY_OF_MONTH) + 1; monthLength = calsys.getMonthLength(cdate); } // the first day of week of the month. long monthDay1st = calsys.getDayOfWeekDateOnOrBefore(month1 + 6, getFirstDayOfWeek()); // if the week has enough days to form a week, the // week starts from the previous month. if ((int)(monthDay1st - month1) >= getMinimalDaysInFirstWeek()) { monthDay1st -= 7; } max = getActualMaximum(field); // value: the new WEEK_OF_MONTH value int value = getRolledValue(internalGet(field), amount, 1, max) - 1; // nfd: fixed date of the rolled date long nfd = monthDay1st + value * 7 + dow; // Unlike WEEK_OF_YEAR, we need to change day of week if the // nfd is out of the month. if (nfd < month1) { nfd = month1; } else if (nfd >= (month1 + monthLength)) { nfd = month1 + monthLength - 1; } int dayOfMonth; if (isCutoverYear) { // If we are in the cutover year, convert nfd to // its calendar date and use dayOfMonth. BaseCalendar.Date d = getCalendarDate(nfd); dayOfMonth = d.getDayOfMonth(); } else { dayOfMonth = (int)(nfd - month1) + 1; } set(DAY_OF_MONTH, dayOfMonth); return; } case DAY_OF_MONTH: { if (!isCutoverYear(cdate.getNormalizedYear())) { max = calsys.getMonthLength(cdate); break; } // Cutover year handling long fd = getCurrentFixedDate(); long month1 = getFixedDateMonth1(cdate, fd); // It may not be a regular month. Convert the date and range to // the relative values, perform the roll, and // convert the result back to the rolled date. int value = getRolledValue((int)(fd - month1), amount, 0, actualMonthLength() - 1); BaseCalendar.Date d = getCalendarDate(month1 + value); assert d.getMonth()-1 == internalGet(MONTH); set(DAY_OF_MONTH, d.getDayOfMonth()); return; } case DAY_OF_YEAR: { max = getActualMaximum(field); if (!isCutoverYear(cdate.getNormalizedYear())) { break; } // Handle cutover here. long fd = getCurrentFixedDate(); long jan1 = fd - internalGet(DAY_OF_YEAR) + 1; int value = getRolledValue((int)(fd - jan1) + 1, amount, min, max); BaseCalendar.Date d = getCalendarDate(jan1 + value - 1); set(MONTH, d.getMonth() - 1); set(DAY_OF_MONTH, d.getDayOfMonth()); return; } case DAY_OF_WEEK: { if (!isCutoverYear(cdate.getNormalizedYear())) { // If the week of year is in the same year, we can // just change DAY_OF_WEEK. int weekOfYear = internalGet(WEEK_OF_YEAR); if (weekOfYear > 1 && weekOfYear < 52) { set(WEEK_OF_YEAR, weekOfYear); // update stamp[WEEK_OF_YEAR] max = SATURDAY; break; } } // We need to handle it in a different way around year // boundaries and in the cutover year. Note that // changing era and year values violates the roll // rule: not changing larger calendar fields... amount %= 7; if (amount == 0) { return; } long fd = getCurrentFixedDate(); long dowFirst = calsys.getDayOfWeekDateOnOrBefore(fd, getFirstDayOfWeek()); fd += amount; if (fd < dowFirst) { fd += 7; } else if (fd >= dowFirst + 7) { fd -= 7; } BaseCalendar.Date d = getCalendarDate(fd); set(ERA, (d.getNormalizedYear() <= 0 ? BCE : CE)); set(d.getYear(), d.getMonth() - 1, d.getDayOfMonth()); return; } case DAY_OF_WEEK_IN_MONTH: { min = 1; // after normalized, min should be 1. if (!isCutoverYear(cdate.getNormalizedYear())) { int dom = internalGet(DAY_OF_MONTH); int monthLength = calsys.getMonthLength(cdate); int lastDays = monthLength % 7; max = monthLength / 7; int x = (dom - 1) % 7; if (x < lastDays) { max++; } set(DAY_OF_WEEK, internalGet(DAY_OF_WEEK)); break; } // Cutover year handling long fd = getCurrentFixedDate(); long month1 = getFixedDateMonth1(cdate, fd); int monthLength = actualMonthLength(); int lastDays = monthLength % 7; max = monthLength / 7; int x = (int)(fd - month1) % 7; if (x < lastDays) { max++; } int value = getRolledValue(internalGet(field), amount, min, max) - 1; fd = month1 + value * 7 + x; BaseCalendar cal = (fd >= gregorianCutoverDate) ? gcal : getJulianCalendarSystem(); BaseCalendar.Date d = (BaseCalendar.Date) cal.newCalendarDate(TimeZone.NO_TIMEZONE); cal.getCalendarDateFromFixedDate(d, fd); set(DAY_OF_MONTH, d.getDayOfMonth()); return; } } set(field, getRolledValue(internalGet(field), amount, min, max)); }
// in java-util/GregorianCalendar.java
protected void computeTime() { // In non-lenient mode, perform brief checking of calendar // fields which have been set externally. Through this // checking, the field values are stored in originalFields[] // to see if any of them are normalized later. if (!isLenient()) { if (originalFields == null) { originalFields = new int[FIELD_COUNT]; } for (int field = 0; field < FIELD_COUNT; field++) { int value = internalGet(field); if (isExternallySet(field)) { // Quick validation for any out of range values if (value < getMinimum(field) || value > getMaximum(field)) { throw new IllegalArgumentException(getFieldName(field)); } } originalFields[field] = value; } } // Let the super class determine which calendar fields to be // used to calculate the time. int fieldMask = selectFields(); // The year defaults to the epoch start. We don't check // fieldMask for YEAR because YEAR is a mandatory field to // determine the date. int year = isSet(YEAR) ? internalGet(YEAR) : EPOCH_YEAR; int era = internalGetEra(); if (era == BCE) { year = 1 - year; } else if (era != CE) { // Even in lenient mode we disallow ERA values other than CE & BCE. // (The same normalization rule as add()/roll() could be // applied here in lenient mode. But this checking is kept // unchanged for compatibility as of 1.5.) throw new IllegalArgumentException("Invalid era"); } // If year is 0 or negative, we need to set the ERA value later. if (year <= 0 && !isSet(ERA)) { fieldMask |= ERA_MASK; setFieldsComputed(ERA_MASK); } // Calculate the time of day. We rely on the convention that // an UNSET field has 0. long timeOfDay = 0; if (isFieldSet(fieldMask, HOUR_OF_DAY)) { timeOfDay += (long) internalGet(HOUR_OF_DAY); } else { timeOfDay += internalGet(HOUR); // The default value of AM_PM is 0 which designates AM. if (isFieldSet(fieldMask, AM_PM)) { timeOfDay += 12 * internalGet(AM_PM); } } timeOfDay *= 60; timeOfDay += internalGet(MINUTE); timeOfDay *= 60; timeOfDay += internalGet(SECOND); timeOfDay *= 1000; timeOfDay += internalGet(MILLISECOND); // Convert the time of day to the number of days and the // millisecond offset from midnight. long fixedDate = timeOfDay / ONE_DAY; timeOfDay %= ONE_DAY; while (timeOfDay < 0) { timeOfDay += ONE_DAY; --fixedDate; } // Calculate the fixed date since January 1, 1 (Gregorian). calculateFixedDate: { long gfd, jfd; if (year > gregorianCutoverYear && year > gregorianCutoverYearJulian) { gfd = fixedDate + getFixedDate(gcal, year, fieldMask); if (gfd >= gregorianCutoverDate) { fixedDate = gfd; break calculateFixedDate; } jfd = fixedDate + getFixedDate(getJulianCalendarSystem(), year, fieldMask); } else if (year < gregorianCutoverYear && year < gregorianCutoverYearJulian) { jfd = fixedDate + getFixedDate(getJulianCalendarSystem(), year, fieldMask); if (jfd < gregorianCutoverDate) { fixedDate = jfd; break calculateFixedDate; } gfd = fixedDate + getFixedDate(gcal, year, fieldMask); } else { gfd = fixedDate + getFixedDate(gcal, year, fieldMask); jfd = fixedDate + getFixedDate(getJulianCalendarSystem(), year, fieldMask); } // Now we have to determine which calendar date it is. if (gfd >= gregorianCutoverDate) { if (jfd >= gregorianCutoverDate) { fixedDate = gfd; } else { // The date is in an "overlapping" period. No way // to disambiguate it. Determine it using the // previous date calculation. if (calsys == gcal || calsys == null) { fixedDate = gfd; } else { fixedDate = jfd; } } } else { if (jfd < gregorianCutoverDate) { fixedDate = jfd; } else { // The date is in a "missing" period. if (!isLenient()) { throw new IllegalArgumentException("the specified date doesn't exist"); } // Take the Julian date for compatibility, which // will produce a Gregorian date. fixedDate = jfd; } } } // millis represents local wall-clock time in milliseconds. long millis = (fixedDate - EPOCH_OFFSET) * ONE_DAY + timeOfDay; // Compute the time zone offset and DST offset. There are two potential // ambiguities here. We'll assume a 2:00 am (wall time) switchover time // for discussion purposes here. // 1. The transition into DST. Here, a designated time of 2:00 am - 2:59 am // can be in standard or in DST depending. However, 2:00 am is an invalid // representation (the representation jumps from 1:59:59 am Std to 3:00:00 am DST). // We assume standard time. // 2. The transition out of DST. Here, a designated time of 1:00 am - 1:59 am // can be in standard or DST. Both are valid representations (the rep // jumps from 1:59:59 DST to 1:00:00 Std). // Again, we assume standard time. // We use the TimeZone object, unless the user has explicitly set the ZONE_OFFSET // or DST_OFFSET fields; then we use those fields. TimeZone zone = getZone(); if (zoneOffsets == null) { zoneOffsets = new int[2]; } int tzMask = fieldMask & (ZONE_OFFSET_MASK|DST_OFFSET_MASK); if (tzMask != (ZONE_OFFSET_MASK|DST_OFFSET_MASK)) { if (zone instanceof ZoneInfo) { ((ZoneInfo)zone).getOffsetsByWall(millis, zoneOffsets); } else { int gmtOffset = isFieldSet(fieldMask, ZONE_OFFSET) ? internalGet(ZONE_OFFSET) : zone.getRawOffset(); zone.getOffsets(millis - gmtOffset, zoneOffsets); } } if (tzMask != 0) { if (isFieldSet(tzMask, ZONE_OFFSET)) { zoneOffsets[0] = internalGet(ZONE_OFFSET); } if (isFieldSet(tzMask, DST_OFFSET)) { zoneOffsets[1] = internalGet(DST_OFFSET); } } // Adjust the time zone offset values to get the UTC time. millis -= zoneOffsets[0] + zoneOffsets[1]; // Set this calendar's time in milliseconds time = millis; int mask = computeFields(fieldMask | getSetStateFields(), tzMask); if (!isLenient()) { for (int field = 0; field < FIELD_COUNT; field++) { if (!isExternallySet(field)) { continue; } if (originalFields[field] != internalGet(field)) { // Restore the original field values System.arraycopy(originalFields, 0, fields, 0, fields.length); throw new IllegalArgumentException(getFieldName(field)); } } } setFieldsNormalized(mask); }
0 0
(Lib) NullPointerException 62
              
// in java-util/ResourceBundle.java
public static ResourceBundle getBundle(String baseName, Locale locale, ClassLoader loader) { if (loader == null) { throw new NullPointerException(); } return getBundleImpl(baseName, locale, loader, Control.INSTANCE); }
// in java-util/ResourceBundle.java
public static ResourceBundle getBundle(String baseName, Locale targetLocale, ClassLoader loader, Control control) { if (loader == null || control == null) { throw new NullPointerException(); } return getBundleImpl(baseName, targetLocale, loader, control); }
// in java-util/ResourceBundle.java
private static ResourceBundle getBundleImpl(String baseName, Locale locale, ClassLoader loader, Control control) { if (locale == null || control == null) { throw new NullPointerException(); } // We create a CacheKey here for use by this call. The base // name and loader will never change during the bundle loading // process. We have to make sure that the locale is set before // using it as a cache key. CacheKey cacheKey = new CacheKey(baseName, locale, loader); ResourceBundle bundle = null; // Quick lookup of the cache. BundleReference bundleRef = cacheList.get(cacheKey); if (bundleRef != null) { bundle = bundleRef.get(); bundleRef = null; } // If this bundle and all of its parents are valid (not expired), // then return this bundle. If any of the bundles is expired, we // don't call control.needsReload here but instead drop into the // complete loading process below. if (isValidBundle(bundle) && hasValidParentChain(bundle)) { return bundle; } // No valid bundle was found in the cache, so we need to load the // resource bundle and its parents. boolean isKnownControl = (control == Control.INSTANCE) || (control instanceof SingleFormatControl); List<String> formats = control.getFormats(baseName); if (!isKnownControl && !checkList(formats)) { throw new IllegalArgumentException("Invalid Control: getFormats"); } ResourceBundle baseBundle = null; for (Locale targetLocale = locale; targetLocale != null; targetLocale = control.getFallbackLocale(baseName, targetLocale)) { List<Locale> candidateLocales = control.getCandidateLocales(baseName, targetLocale); if (!isKnownControl && !checkList(candidateLocales)) { throw new IllegalArgumentException("Invalid Control: getCandidateLocales"); } bundle = findBundle(cacheKey, candidateLocales, formats, 0, control, baseBundle); // If the loaded bundle is the base bundle and exactly for the // requested locale or the only candidate locale, then take the // bundle as the resulting one. If the loaded bundle is the base // bundle, it's put on hold until we finish processing all // fallback locales. if (isValidBundle(bundle)) { boolean isBaseBundle = Locale.ROOT.equals(bundle.locale); if (!isBaseBundle || bundle.locale.equals(locale) || (candidateLocales.size() == 1 && bundle.locale.equals(candidateLocales.get(0)))) { break; } // If the base bundle has been loaded, keep the reference in // baseBundle so that we can avoid any redundant loading in case // the control specify not to cache bundles. if (isBaseBundle && baseBundle == null) { baseBundle = bundle; } } } if (bundle == null) { if (baseBundle == null) { throwMissingResourceException(baseName, locale, cacheKey.getCause()); } bundle = baseBundle; } return bundle; }
// in java-util/ResourceBundle.java
public static final void clearCache(ClassLoader loader) { if (loader == null) { throw new NullPointerException(); } Set<CacheKey> set = cacheList.keySet(); for (CacheKey key : set) { if (key.getLoader() == loader) { set.remove(key); } } }
// in java-util/ResourceBundle.java
public boolean containsKey(String key) { if (key == null) { throw new NullPointerException(); } for (ResourceBundle rb = this; rb != null; rb = rb.parent) { if (rb.handleKeySet().contains(key)) { return true; } } return false; }
// in java-util/ResourceBundle.java
public List<String> getFormats(String baseName) { if (baseName == null) { throw new NullPointerException(); } return FORMAT_DEFAULT; }
// in java-util/ResourceBundle.java
public List<Locale> getCandidateLocales(String baseName, Locale locale) { if (baseName == null) { throw new NullPointerException(); } String language = locale.getLanguage(); String country = locale.getCountry(); String variant = locale.getVariant(); List<Locale> locales = new ArrayList<Locale>(4); if (variant.length() > 0) { locales.add(locale); } if (country.length() > 0) { locales.add((locales.size() == 0) ? locale : Locale.getInstance(language, country, "")); } if (language.length() > 0) { locales.add((locales.size() == 0) ? locale : Locale.getInstance(language, "", "")); } locales.add(Locale.ROOT); return locales; }
// in java-util/ResourceBundle.java
public Locale getFallbackLocale(String baseName, Locale locale) { if (baseName == null) { throw new NullPointerException(); } Locale defaultLocale = Locale.getDefault(); return locale.equals(defaultLocale) ? null : defaultLocale; }
// in java-util/ResourceBundle.java
public long getTimeToLive(String baseName, Locale locale) { if (baseName == null || locale == null) { throw new NullPointerException(); } return TTL_NO_EXPIRATION_CONTROL; }
// in java-util/ResourceBundle.java
public boolean needsReload(String baseName, Locale locale, String format, ClassLoader loader, ResourceBundle bundle, long loadTime) { if (bundle == null) { throw new NullPointerException(); } if (format.equals("java.class") || format.equals("java.properties")) { format = format.substring(5); } boolean result = false; try { String resourceName = toResourceName(toBundleName(baseName, locale), format); URL url = loader.getResource(resourceName); if (url != null) { long lastModified = 0; URLConnection connection = url.openConnection(); if (connection != null) { // disable caches to get the correct data connection.setUseCaches(false); if (connection instanceof JarURLConnection) { JarEntry ent = ((JarURLConnection)connection).getJarEntry(); if (ent != null) { lastModified = ent.getTime(); if (lastModified == -1) { lastModified = 0; } } } else { lastModified = connection.getLastModified(); } } result = lastModified >= loadTime; } } catch (NullPointerException npe) { throw npe; } catch (Exception e) { // ignore other exceptions } return result; }
// in java-util/ResourceBundle.java
public List<String> getFormats(String baseName) { if (baseName == null) { throw new NullPointerException(); } return formats; }
// in java-util/ResourceBundle.java
public Locale getFallbackLocale(String baseName, Locale locale) { if (baseName == null || locale == null) { throw new NullPointerException(); } return null; }
// in java-util/TreeMap.java
final Entry<K,V> getEntry(Object key) { // Offload comparator-based version for sake of performance if (comparator != null) return getEntryUsingComparator(key); if (key == null) throw new NullPointerException(); Comparable<? super K> k = (Comparable<? super K>) key; Entry<K,V> p = root; while (p != null) { int cmp = k.compareTo(p.key); if (cmp < 0) p = p.left; else if (cmp > 0) p = p.right; else return p; } return null; }
// in java-util/TreeMap.java
public V put(K key, V value) { Entry<K,V> t = root; if (t == null) { // TBD: // 5045147: (coll) Adding null to an empty TreeSet should // throw NullPointerException // // compare(key, key); // type check root = new Entry<K,V>(key, value, null); size = 1; modCount++; return null; } int cmp; Entry<K,V> parent; // split comparator and comparable paths Comparator<? super K> cpr = comparator; if (cpr != null) { do { parent = t; cmp = cpr.compare(key, t.key); if (cmp < 0) t = t.left; else if (cmp > 0) t = t.right; else return t.setValue(value); } while (t != null); } else { if (key == null) throw new NullPointerException(); Comparable<? super K> k = (Comparable<? super K>) key; do { parent = t; cmp = k.compareTo(t.key); if (cmp < 0) t = t.left; else if (cmp > 0) t = t.right; else return t.setValue(value); } while (t != null); } Entry<K,V> e = new Entry<K,V>(key, value, parent); if (cmp < 0) parent.left = e; else parent.right = e; fixAfterInsertion(e); size++; modCount++; return null; }
// in java-util/Currency.java
public static Currency getInstance(Locale locale) { String country = locale.getCountry(); if (country == null) { throw new NullPointerException(); } if (country.length() != 2) { throw new IllegalArgumentException(); } char char1 = country.charAt(0); char char2 = country.charAt(1); int tableEntry = getMainTableEntry(char1, char2); if ((tableEntry & COUNTRY_TYPE_MASK) == SIMPLE_CASE_COUNTRY_MASK && tableEntry != INVALID_COUNTRY_ENTRY) { char finalChar = (char) ((tableEntry & SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK) + 'A'); int defaultFractionDigits = (tableEntry & SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK) >> SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT; StringBuffer sb = new StringBuffer(country); sb.append(finalChar); return getInstance(sb.toString(), defaultFractionDigits); } else { // special cases if (tableEntry == INVALID_COUNTRY_ENTRY) { throw new IllegalArgumentException(); } if (tableEntry == COUNTRY_WITHOUT_CURRENCY_ENTRY) { return null; } else { int index = (tableEntry & SPECIAL_CASE_COUNTRY_INDEX_MASK) - SPECIAL_CASE_COUNTRY_INDEX_DELTA; if (scCutOverTimes[index] == Long.MAX_VALUE || System.currentTimeMillis() < scCutOverTimes[index]) { return getInstance(scOldCurrencies[index], scOldCurrenciesDFD[index]); } else { return getInstance(scNewCurrencies[index], scNewCurrenciesDFD[index]); } } } }
// in java-util/ArrayDeque.java
public void addFirst(E e) { if (e == null) throw new NullPointerException(); elements[head = (head - 1) & (elements.length - 1)] = e; if (head == tail) doubleCapacity(); }
// in java-util/ArrayDeque.java
public void addLast(E e) { if (e == null) throw new NullPointerException(); elements[tail] = e; if ( (tail = (tail + 1) & (elements.length - 1)) == head) doubleCapacity(); }
// in java-util/Scanner.java
private static Readable makeReadable(InputStream source, String charsetName) { if (source == null) throw new NullPointerException("source"); InputStreamReader isr = null; try { isr = new InputStreamReader(source, charsetName); } catch (UnsupportedEncodingException uee) { IllegalArgumentException iae = new IllegalArgumentException(); iae.initCause(uee); throw iae; } return isr; }
// in java-util/Scanner.java
private static Readable makeReadable(ReadableByteChannel source) { if (source == null) throw new NullPointerException("source"); String defaultCharsetName = java.nio.charset.Charset.defaultCharset().name(); return Channels.newReader(source, java.nio.charset.Charset.defaultCharset().name()); }
// in java-util/Scanner.java
private static Readable makeReadable(ReadableByteChannel source, String charsetName) { if (source == null) throw new NullPointerException("source"); if (!Charset.isSupported(charsetName)) throw new IllegalArgumentException(charsetName); return Channels.newReader(source, charsetName); }
// in java-util/Scanner.java
public boolean hasNext(Pattern pattern) { ensureOpen(); if (pattern == null) throw new NullPointerException(); hasNextPattern = null; saveState(); while (true) { if (getCompleteTokenInBuffer(pattern) != null) { matchValid = true; cacheResult(); return revertState(true); } if (needInput) readInput(); else return revertState(false); } }
// in java-util/Scanner.java
public String next(Pattern pattern) { ensureOpen(); if (pattern == null) throw new NullPointerException(); // Did we already find this pattern? if (hasNextPattern == pattern) return getCachedResult(); clearCaches(); // Search for the pattern while (true) { String token = getCompleteTokenInBuffer(pattern); if (token != null) { matchValid = true; skipped = false; return token; } if (needInput) readInput(); else throwFor(); } }
// in java-util/Scanner.java
public String findInLine(Pattern pattern) { ensureOpen(); if (pattern == null) throw new NullPointerException(); clearCaches(); // Expand buffer to include the next newline or end of input int endPosition = 0; saveState(); while (true) { String token = findPatternInBuffer(separatorPattern(), 0); if (token != null) { endPosition = matcher.start(); break; // up to next newline } if (needInput) { readInput(); } else { endPosition = buf.limit(); break; // up to end of input } } revertState(); int horizonForLine = endPosition - position; // If there is nothing between the current pos and the next // newline simply return null, invoking findWithinHorizon // with "horizon=0" will scan beyond the line bound. if (horizonForLine == 0) return null; // Search for the pattern return findWithinHorizon(pattern, horizonForLine); }
// in java-util/Scanner.java
public String findWithinHorizon(Pattern pattern, int horizon) { ensureOpen(); if (pattern == null) throw new NullPointerException(); if (horizon < 0) throw new IllegalArgumentException("horizon < 0"); clearCaches(); // Search for the pattern while (true) { String token = findPatternInBuffer(pattern, horizon); if (token != null) { matchValid = true; return token; } if (needInput) readInput(); else break; // up to end of input } return null; }
// in java-util/Scanner.java
public Scanner skip(Pattern pattern) { ensureOpen(); if (pattern == null) throw new NullPointerException(); clearCaches(); // Search for the pattern while (true) { String token = matchPatternInBuffer(pattern); if (token != null) { matchValid = true; position = matcher.end(); return this; } if (needInput) readInput(); else throw new NoSuchElementException(); } }
// in java-util/Observable.java
public synchronized void addObserver(Observer o) { if (o == null) throw new NullPointerException(); if (!obs.contains(o)) { obs.addElement(o); } }
// in java-util/AbstractQueue.java
public boolean addAll(Collection<? extends E> c) { if (c == null) throw new NullPointerException(); if (c == this) throw new IllegalArgumentException(); boolean modified = false; Iterator<? extends E> e = c.iterator(); while (e.hasNext()) { if (add(e.next())) modified = true; } return modified; }
// in java-util/TimeZone.java
public void setID(String ID) { if (ID == null) { throw new NullPointerException(); } this.ID = ID; }
// in java-util/Properties.java
public synchronized void loadFromXML(InputStream in) throws IOException, InvalidPropertiesFormatException { if (in == null) throw new NullPointerException(); XMLUtils.load(this, in); in.close(); }
// in java-util/Properties.java
public synchronized void storeToXML(OutputStream os, String comment) throws IOException { if (os == null) throw new NullPointerException(); storeToXML(os, comment, "UTF-8"); }
// in java-util/Properties.java
public synchronized void storeToXML(OutputStream os, String comment, String encoding) throws IOException { if (os == null) throw new NullPointerException(); XMLUtils.save(this, os, comment, encoding); }
// in java-util/PriorityQueue.java
public boolean offer(E e) { if (e == null) throw new NullPointerException(); modCount++; int i = size; if (i >= queue.length) grow(i + 1); size = i + 1; if (i == 0) queue[0] = e; else siftUp(i, e); return true; }
// in java-util/PropertyPermission.java
private void init(int mask) { if ((mask & ALL) != mask) throw new IllegalArgumentException("invalid actions mask"); if (mask == NONE) throw new IllegalArgumentException("invalid actions mask"); if (getName() == null) throw new NullPointerException("name can't be null"); this.mask = mask; }
// in java-util/StringTokenizer.java
private int skipDelimiters(int startPos) { if (delimiters == null) throw new NullPointerException(); int position = startPos; while (!retDelims && position < maxPosition) { if (!hasSurrogates) { char c = str.charAt(position); if ((c > maxDelimCodePoint) || (delimiters.indexOf(c) < 0)) break; position++; } else { int c = str.codePointAt(position); if ((c > maxDelimCodePoint) || !isDelimiter(c)) { break; } position += Character.charCount(c); } } return position; }
// in java-util/Hashtable.java
public synchronized boolean contains(Object value) { if (value == null) { throw new NullPointerException(); } Entry tab[] = table; for (int i = tab.length ; i-- > 0 ;) { for (Entry<K,V> e = tab[i] ; e != null ; e = e.next) { if (e.value.equals(value)) { return true; } } } return false; }
// in java-util/Hashtable.java
public synchronized V put(K key, V value) { // Make sure the value is not null if (value == null) { throw new NullPointerException(); } // Makes sure the key is not already in the hashtable. Entry tab[] = table; int hash = key.hashCode(); int index = (hash & 0x7FFFFFFF) % tab.length; for (Entry<K,V> e = tab[index] ; e != null ; e = e.next) { if ((e.hash == hash) && e.key.equals(key)) { V old = e.value; e.value = value; return old; } } modCount++; if (count >= threshold) { // Rehash the table if the threshold is exceeded rehash(); tab = table; index = (hash & 0x7FFFFFFF) % tab.length; } // Creates the new entry. Entry<K,V> e = tab[index]; tab[index] = new Entry<K,V>(hash, key, value, e); count++; return null; }
// in java-util/Hashtable.java
public V setValue(V value) { if (value == null) throw new NullPointerException(); V oldValue = this.value; this.value = value; return oldValue; }
// in java-util/Calendar.java
boolean checkDisplayNameParams(int field, int style, int minStyle, int maxStyle, Locale locale, int fieldMask) { if (field < 0 || field >= fields.length || style < minStyle || style > maxStyle) { throw new IllegalArgumentException(); } if (locale == null) { throw new NullPointerException(); } return isFieldSet(fieldMask, field); }
// in java-util/ListResourceBundle.java
public final Object handleGetObject(String key) { // lazily load the lookup hashtable. if (lookup == null) { loadLookup(); } if (key == null) { throw new NullPointerException(); } return lookup.get(key); // this class ignores locales }
// in java-util/ListResourceBundle.java
private synchronized void loadLookup() { if (lookup != null) return; Object[][] contents = getContents(); HashMap<String,Object> temp = new HashMap<String,Object>(contents.length); for (int i = 0; i < contents.length; ++i) { // key must be non-null String, value must be non-null String key = (String) contents[i][0]; Object value = contents[i][1]; if (key == null || value == null) { throw new NullPointerException(); } temp.put(key, value); } lookup = temp; }
// in java-util/Locale.java
static Locale getInstance(String language, String country, String variant) { if (language== null || country == null || variant == null) { throw new NullPointerException(); } StringBuilder sb = new StringBuilder(); sb.append(language).append('_').append(country).append('_').append(variant); String key = sb.toString(); Locale locale = cache.get(key); if (locale == null) { locale = new Locale(language, country, variant); Locale l = cache.putIfAbsent(key, locale); if (l != null) { locale = l; } } return locale; }
// in java-util/Locale.java
public static synchronized void setDefault(Locale newLocale) { if (newLocale == null) throw new NullPointerException("Can't set default locale to NULL"); SecurityManager sm = System.getSecurityManager(); if (sm != null) sm.checkPermission(new PropertyPermission ("user.language", "write")); defaultLocale = newLocale; }
// in java-util/Locale.java
private String getDisplayString(String code, Locale inLocale, int type) { if (code.length() == 0) { return ""; } if (inLocale == null) { throw new NullPointerException(); } try { OpenListResourceBundle bundle = LocaleData.getLocaleNames(inLocale); String key = (type == DISPLAY_VARIANT ? "%%"+code : code); String result = null; // Check whether a provider can provide an implementation that's closer // to the requested locale than what the Java runtime itself can provide. LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(LocaleNameProvider.class); if (pool.hasProviders()) { result = pool.getLocalizedObject( LocaleNameGetter.INSTANCE, inLocale, bundle, key, type, code); } if (result == null) { result = bundle.getString(key); } if (result != null) { return result; } } catch (Exception e) { // just fall through } return code; }
// in java-util/PropertyResourceBundle.java
public Object handleGetObject(String key) { if (key == null) { throw new NullPointerException(); } return lookup.get(key); }
0 0
(Domain) NoSuchElementException 46
              
// in java-util/Vector.java
public E nextElement() { synchronized (Vector.this) { if (count < elementCount) { return (E)elementData[count++]; } } throw new NoSuchElementException("Vector Enumeration"); }
// in java-util/Vector.java
public synchronized E firstElement() { if (elementCount == 0) { throw new NoSuchElementException(); } return (E)elementData[0]; }
// in java-util/Vector.java
public synchronized E lastElement() { if (elementCount == 0) { throw new NoSuchElementException(); } return (E)elementData[elementCount - 1]; }
// in java-util/LinkedList.java
public E getFirst() { if (size==0) throw new NoSuchElementException(); return header.next.element; }
// in java-util/LinkedList.java
public E getLast() { if (size==0) throw new NoSuchElementException(); return header.previous.element; }
// in java-util/LinkedList.java
public E next() { checkForComodification(); if (nextIndex == size) throw new NoSuchElementException(); lastReturned = next; next = next.next; nextIndex++; return lastReturned.element; }
// in java-util/LinkedList.java
public E previous() { if (nextIndex == 0) throw new NoSuchElementException(); lastReturned = next = next.previous; nextIndex--; checkForComodification(); return lastReturned.element; }
// in java-util/LinkedList.java
private E remove(Entry<E> e) { if (e == header) throw new NoSuchElementException(); E result = e.element; e.previous.next = e.next; e.next.previous = e.previous; e.next = e.previous = null; e.element = null; size--; modCount++; return result; }
// in java-util/TreeMap.java
final Entry<K,V> nextEntry() { Entry<K,V> e = next; if (e == null) throw new NoSuchElementException(); if (modCount != expectedModCount) throw new ConcurrentModificationException(); next = successor(e); lastReturned = e; return e; }
// in java-util/TreeMap.java
final Entry<K,V> prevEntry() { Entry<K,V> e = next; if (e == null) throw new NoSuchElementException(); if (modCount != expectedModCount) throw new ConcurrentModificationException(); next = predecessor(e); lastReturned = e; return e; }
// in java-util/TreeMap.java
static <K> K key(Entry<K,?> e) { if (e==null) throw new NoSuchElementException(); return e.key; }
// in java-util/TreeMap.java
final TreeMap.Entry<K,V> nextEntry() { TreeMap.Entry<K,V> e = next; if (e == null || e.key == fenceKey) throw new NoSuchElementException(); if (m.modCount != expectedModCount) throw new ConcurrentModificationException(); next = successor(e); lastReturned = e; return e; }
// in java-util/TreeMap.java
final TreeMap.Entry<K,V> prevEntry() { TreeMap.Entry<K,V> e = next; if (e == null || e.key == fenceKey) throw new NoSuchElementException(); if (m.modCount != expectedModCount) throw new ConcurrentModificationException(); next = predecessor(e); lastReturned = e; return e; }
// in java-util/ArrayDeque.java
public E removeFirst() { E x = pollFirst(); if (x == null) throw new NoSuchElementException(); return x; }
// in java-util/ArrayDeque.java
public E removeLast() { E x = pollLast(); if (x == null) throw new NoSuchElementException(); return x; }
// in java-util/ArrayDeque.java
public E getFirst() { E x = elements[head]; if (x == null) throw new NoSuchElementException(); return x; }
// in java-util/ArrayDeque.java
public E getLast() { E x = elements[(tail - 1) & (elements.length - 1)]; if (x == null) throw new NoSuchElementException(); return x; }
// in java-util/ArrayDeque.java
public E next() { if (cursor == fence) throw new NoSuchElementException(); E result = elements[cursor]; // This check doesn't catch all possible comodifications, // but does catch the ones that corrupt traversal if (tail != fence || result == null) throw new ConcurrentModificationException(); lastRet = cursor; cursor = (cursor + 1) & (elements.length - 1); return result; }
// in java-util/ArrayDeque.java
public E next() { if (cursor == fence) throw new NoSuchElementException(); cursor = (cursor - 1) & (elements.length - 1); E result = elements[cursor]; if (head != fence || result == null) throw new ConcurrentModificationException(); lastRet = cursor; return result; }
// in java-util/WeakHashMap.java
protected Entry<K,V> nextEntry() { if (modCount != expectedModCount) throw new ConcurrentModificationException(); if (nextKey == null && !hasNext()) throw new NoSuchElementException(); lastReturned = entry; entry = entry.next; currentKey = nextKey; nextKey = null; return lastReturned; }
// in java-util/LinkedHashMap.java
Entry<K,V> nextEntry() { if (modCount != expectedModCount) throw new ConcurrentModificationException(); if (nextEntry == header) throw new NoSuchElementException(); Entry<K,V> e = lastReturned = nextEntry; nextEntry = e.after; return e; }
// in java-util/Scanner.java
private void throwFor() { skipped = false; if ((sourceClosed) && (position == buf.limit())) throw new NoSuchElementException(); else throw new InputMismatchException(); }
// in java-util/Scanner.java
public String nextLine() { if (hasNextPattern == linePattern()) return getCachedResult(); clearCaches(); String result = findWithinHorizon(linePattern, 0); if (result == null) throw new NoSuchElementException("No line found"); MatchResult mr = this.match(); String lineSep = mr.group(1); if (lineSep != null) result = result.substring(0, result.length() - lineSep.length()); if (result == null) throw new NoSuchElementException(); else return result; }
// in java-util/Scanner.java
public Scanner skip(Pattern pattern) { ensureOpen(); if (pattern == null) throw new NullPointerException(); clearCaches(); // Search for the pattern while (true) { String token = matchPatternInBuffer(pattern); if (token != null) { matchValid = true; position = matcher.end(); return this; } if (needInput) readInput(); else throw new NoSuchElementException(); } }
// in java-util/AbstractQueue.java
public E remove() { E x = poll(); if (x != null) return x; else throw new NoSuchElementException(); }
// in java-util/AbstractQueue.java
public E element() { E x = peek(); if (x != null) return x; else throw new NoSuchElementException(); }
// in java-util/AbstractList.java
public E next() { checkForComodification(); try { E next = get(cursor); lastRet = cursor++; return next; } catch (IndexOutOfBoundsException e) { checkForComodification(); throw new NoSuchElementException(); } }
// in java-util/AbstractList.java
public E previous() { checkForComodification(); try { int i = cursor - 1; E previous = get(i); lastRet = cursor = i; return previous; } catch (IndexOutOfBoundsException e) { checkForComodification(); throw new NoSuchElementException(); } }
// in java-util/AbstractList.java
public E next() { if (hasNext()) return i.next(); else throw new NoSuchElementException(); }
// in java-util/AbstractList.java
public E previous() { if (hasPrevious()) return i.previous(); else throw new NoSuchElementException(); }
// in java-util/HashMap.java
final Entry<K,V> nextEntry() { if (modCount != expectedModCount) throw new ConcurrentModificationException(); Entry<K,V> e = next; if (e == null) throw new NoSuchElementException(); if ((next = e.next) == null) { Entry[] t = table; while (index < t.length && (next = t[index++]) == null) ; } current = e; return e; }
// in java-util/RegularEnumSet.java
public E next() { if (unseen == 0) throw new NoSuchElementException(); lastReturned = unseen & -unseen; unseen -= lastReturned; return (E) universe[Long.numberOfTrailingZeros(lastReturned)]; }
// in java-util/ServiceLoader.java
public S next() { if (!hasNext()) { throw new NoSuchElementException(); } String cn = nextName; nextName = null; try { S p = service.cast(Class.forName(cn, true, loader) .newInstance()); providers.put(cn, p); return p; } catch (ClassNotFoundException x) { fail(service, "Provider " + cn + " not found"); } catch (Throwable x) { fail(service, "Provider " + cn + " could not be instantiated: " + x, x); } throw new Error(); // This cannot happen }
// in java-util/IdentityHashMap.java
protected int nextIndex() { if (modCount != expectedModCount) throw new ConcurrentModificationException(); if (!indexValid && !hasNext()) throw new NoSuchElementException(); indexValid = false; lastReturnedIndex = index; index += 2; return lastReturnedIndex; }
// in java-util/PriorityQueue.java
public E next() { if (expectedModCount != modCount) throw new ConcurrentModificationException(); if (cursor < size) return (E) queue[lastRet = cursor++]; if (forgetMeNot != null) { lastRet = -1; lastRetElt = forgetMeNot.poll(); if (lastRetElt != null) return lastRetElt; } throw new NoSuchElementException(); }
// in java-util/EnumMap.java
public K next() { if (!hasNext()) throw new NoSuchElementException(); lastReturnedIndex = index++; return keyUniverse[lastReturnedIndex]; }
// in java-util/EnumMap.java
public V next() { if (!hasNext()) throw new NoSuchElementException(); lastReturnedIndex = index++; return unmaskNull(vals[lastReturnedIndex]); }
// in java-util/EnumMap.java
public Map.Entry<K,V> next() { if (!hasNext()) throw new NoSuchElementException(); lastReturnedIndex = index++; return this; }
// in java-util/JumboEnumSet.java
public E next() { if (!hasNext()) throw new NoSuchElementException(); lastReturned = unseen & -unseen; lastReturnedIndex = unseenIndex; unseen -= lastReturned; return (E) universe[(lastReturnedIndex << 6) + Long.numberOfTrailingZeros(lastReturned)]; }
// in java-util/StringTokenizer.java
public String nextToken() { /* * If next position already computed in hasMoreElements() and * delimiters have changed between the computation and this invocation, * then use the computed value. */ currentPosition = (newPosition >= 0 && !delimsChanged) ? newPosition : skipDelimiters(currentPosition); /* Reset these anyway */ delimsChanged = false; newPosition = -1; if (currentPosition >= maxPosition) throw new NoSuchElementException(); int start = currentPosition; currentPosition = scanToken(currentPosition); return str.substring(start, currentPosition); }
// in java-util/Hashtable.java
public T nextElement() { Entry<K,V> et = entry; int i = index; Entry[] t = table; /* Use locals for faster loop iteration */ while (et == null && i > 0) { et = t[--i]; } entry = et; index = i; if (et != null) { Entry<K,V> e = lastReturned = entry; entry = e.next; return type == KEYS ? (T)e.key : (type == VALUES ? (T)e.value : (T)e); } throw new NoSuchElementException("Hashtable Enumerator"); }
// in java-util/Hashtable.java
public Object nextElement() { throw new NoSuchElementException("Hashtable Enumerator"); }
// in java-util/Hashtable.java
public Object next() { throw new NoSuchElementException("Hashtable Iterator"); }
// in java-util/Collections.java
public Object next() { throw new NoSuchElementException(); }
// in java-util/Collections.java
public E next() { if (hasNext) { hasNext = false; return element; } throw new NoSuchElementException(); }
2
              
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException e) { checkForComodification(); throw new NoSuchElementException(); }
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException e) { checkForComodification(); throw new NoSuchElementException(); }
0
(Lib) UnsupportedOperationException 37
              
// in java-util/UUID.java
public long timestamp() { if (version() != 1) { throw new UnsupportedOperationException("Not a time-based UUID"); } long result = timestamp; if (result < 0) { result = (mostSigBits & 0x0000000000000FFFL) << 48; result |= ((mostSigBits >> 16) & 0xFFFFL) << 32; result |= mostSigBits >>> 32; timestamp = result; } return result; }
// in java-util/UUID.java
public int clockSequence() { if (version() != 1) { throw new UnsupportedOperationException("Not a time-based UUID"); } if (sequence < 0) { sequence = (int)((leastSigBits & 0x3FFF000000000000L) >>> 48); } return sequence; }
// in java-util/UUID.java
public long node() { if (version() != 1) { throw new UnsupportedOperationException("Not a time-based UUID"); } if (node < 0) { node = leastSigBits & 0x0000FFFFFFFFFFFFL; } return node; }
// in java-util/Scanner.java
public void remove() { throw new UnsupportedOperationException(); }
// in java-util/AbstractList.java
public E set(int index, E element) { throw new UnsupportedOperationException(); }
// in java-util/AbstractList.java
public void add(int index, E element) { throw new UnsupportedOperationException(); }
// in java-util/AbstractList.java
public E remove(int index) { throw new UnsupportedOperationException(); }
// in java-util/AbstractCollection.java
public boolean add(E e) { throw new UnsupportedOperationException(); }
// in java-util/ServiceLoader.java
public void remove() { throw new UnsupportedOperationException(); }
// in java-util/ServiceLoader.java
public void remove() { throw new UnsupportedOperationException(); }
// in java-util/AbstractMap.java
public V put(K key, V value) { throw new UnsupportedOperationException(); }
// in java-util/AbstractMap.java
public V setValue(V value) { throw new UnsupportedOperationException(); }
// in java-util/Hashtable.java
public void remove() { if (!iterator) throw new UnsupportedOperationException(); if (lastReturned == null) throw new IllegalStateException("Hashtable Enumerator"); if (modCount != expectedModCount) throw new ConcurrentModificationException(); synchronized(Hashtable.this) { Entry[] tab = Hashtable.this.table; int index = (lastReturned.hash & 0x7FFFFFFF) % tab.length; for (Entry<K,V> e = tab[index], prev = null; e != null; prev = e, e = e.next) { if (e == lastReturned) { modCount++; expectedModCount++; if (prev == null) tab[index] = e.next; else prev.next = e.next; count--; lastReturned = null; return; } } throw new ConcurrentModificationException(); } }
// in java-util/Collections.java
public void remove() { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public boolean add(E e){ throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public boolean remove(Object o) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public boolean addAll(Collection<? extends E> coll) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public boolean removeAll(Collection<?> coll) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public boolean retainAll(Collection<?> coll) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public void clear() { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public E set(int index, E element) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public void add(int index, E element) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public E remove(int index) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public boolean addAll(int index, Collection<? extends E> c) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public void remove() { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public void set(E e) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public void add(E e) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public V put(K key, V value) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public V remove(Object key) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public void putAll(Map<? extends K, ? extends V> m) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public void clear() { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public void remove() { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public V setValue(V value) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public boolean add(Map.Entry<K, V> e){ throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public boolean addAll(Collection<? extends Map.Entry<K, V>> coll) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public void remove() { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public void remove() { throw new UnsupportedOperationException(); }
0 0
(Lib) IndexOutOfBoundsException 34
              
// in java-util/Vector.java
public synchronized int lastIndexOf(Object o, int index) { if (index >= elementCount) throw new IndexOutOfBoundsException(index + " >= "+ elementCount); if (o == null) { for (int i = index; i >= 0; i--) if (elementData[i]==null) return i; } else { for (int i = index; i >= 0; i--) if (o.equals(elementData[i])) return i; } return -1; }
// in java-util/LinkedList.java
public boolean addAll(int index, Collection<? extends E> c) { if (index < 0 || index > size) throw new IndexOutOfBoundsException("Index: "+index+ ", Size: "+size); Object[] a = c.toArray(); int numNew = a.length; if (numNew==0) return false; modCount++; Entry<E> successor = (index==size ? header : entry(index)); Entry<E> predecessor = successor.previous; for (int i=0; i<numNew; i++) { Entry<E> e = new Entry<E>((E)a[i], successor, predecessor); predecessor.next = e; predecessor = e; } successor.previous = predecessor; size += numNew; return true; }
// in java-util/LinkedList.java
private Entry<E> entry(int index) { if (index < 0 || index >= size) throw new IndexOutOfBoundsException("Index: "+index+ ", Size: "+size); Entry<E> e = header; if (index < (size >> 1)) { for (int i = 0; i <= index; i++) e = e.next; } else { for (int i = size; i > index; i--) e = e.previous; } return e; }
// in java-util/AbstractSequentialList.java
public E get(int index) { try { return listIterator(index).next(); } catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); } }
// in java-util/AbstractSequentialList.java
public E set(int index, E element) { try { ListIterator<E> e = listIterator(index); E oldVal = e.next(); e.set(element); return oldVal; } catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); } }
// in java-util/AbstractSequentialList.java
public void add(int index, E element) { try { listIterator(index).add(element); } catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); } }
// in java-util/AbstractSequentialList.java
public E remove(int index) { try { ListIterator<E> e = listIterator(index); E outCast = e.next(); e.remove(); return outCast; } catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); } }
// in java-util/AbstractSequentialList.java
public boolean addAll(int index, Collection<? extends E> c) { try { boolean modified = false; ListIterator<E> e1 = listIterator(index); Iterator<? extends E> e2 = c.iterator(); while (e2.hasNext()) { e1.add(e2.next()); modified = true; } return modified; } catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); } }
// in java-util/AbstractList.java
public ListIterator<E> listIterator(final int index) { if (index<0 || index>size()) throw new IndexOutOfBoundsException("Index: "+index); return new ListItr(index); }
// in java-util/AbstractList.java
public void add(int index, E element) { if (index<0 || index>size) throw new IndexOutOfBoundsException(); checkForComodification(); l.add(index+offset, element); expectedModCount = l.modCount; size++; modCount++; }
// in java-util/AbstractList.java
public boolean addAll(int index, Collection<? extends E> c) { if (index<0 || index>size) throw new IndexOutOfBoundsException( "Index: "+index+", Size: "+size); int cSize = c.size(); if (cSize==0) return false; checkForComodification(); l.addAll(offset+index, c); expectedModCount = l.modCount; size += cSize; modCount++; return true; }
// in java-util/AbstractList.java
public ListIterator<E> listIterator(final int index) { checkForComodification(); if (index<0 || index>size) throw new IndexOutOfBoundsException( "Index: "+index+", Size: "+size); return new ListIterator<E>() { private ListIterator<E> i = l.listIterator(index+offset); public boolean hasNext() { return nextIndex() < size; } public E next() { if (hasNext()) return i.next(); else throw new NoSuchElementException(); } public boolean hasPrevious() { return previousIndex() >= 0; } public E previous() { if (hasPrevious()) return i.previous(); else throw new NoSuchElementException(); } public int nextIndex() { return i.nextIndex() - offset; } public int previousIndex() { return i.previousIndex() - offset; } public void remove() { i.remove(); expectedModCount = l.modCount; size--; modCount++; } public void set(E e) { i.set(e); } public void add(E e) { i.add(e); expectedModCount = l.modCount; size++; modCount++; } }; }
// in java-util/AbstractList.java
private void rangeCheck(int index) { if (index<0 || index>=size) throw new IndexOutOfBoundsException("Index: "+index+ ",Size: "+size); }
// in java-util/ArrayList.java
public void add(int index, E element) { if (index > size || index < 0) throw new IndexOutOfBoundsException( "Index: "+index+", Size: "+size); ensureCapacity(size+1); // Increments modCount!! System.arraycopy(elementData, index, elementData, index + 1, size - index); elementData[index] = element; size++; }
// in java-util/ArrayList.java
public boolean addAll(int index, Collection<? extends E> c) { if (index > size || index < 0) throw new IndexOutOfBoundsException( "Index: " + index + ", Size: " + size); Object[] a = c.toArray(); int numNew = a.length; ensureCapacity(size + numNew); // Increments modCount int numMoved = size - index; if (numMoved > 0) System.arraycopy(elementData, index, elementData, index + numNew, numMoved); System.arraycopy(a, 0, elementData, index, numNew); size += numNew; return numNew != 0; }
// in java-util/ArrayList.java
private void RangeCheck(int index) { if (index >= size) throw new IndexOutOfBoundsException( "Index: "+index+", Size: "+size); }
// in java-util/BitSet.java
private static void checkRange(int fromIndex, int toIndex) { if (fromIndex < 0) throw new IndexOutOfBoundsException("fromIndex < 0: " + fromIndex); if (toIndex < 0) throw new IndexOutOfBoundsException("toIndex < 0: " + toIndex); if (fromIndex > toIndex) throw new IndexOutOfBoundsException("fromIndex: " + fromIndex + " > toIndex: " + toIndex); }
// in java-util/BitSet.java
public void flip(int bitIndex) { if (bitIndex < 0) throw new IndexOutOfBoundsException("bitIndex < 0: " + bitIndex); int wordIndex = wordIndex(bitIndex); expandTo(wordIndex); words[wordIndex] ^= (1L << bitIndex); recalculateWordsInUse(); checkInvariants(); }
// in java-util/BitSet.java
public void set(int bitIndex) { if (bitIndex < 0) throw new IndexOutOfBoundsException("bitIndex < 0: " + bitIndex); int wordIndex = wordIndex(bitIndex); expandTo(wordIndex); words[wordIndex] |= (1L << bitIndex); // Restores invariants checkInvariants(); }
// in java-util/BitSet.java
public void clear(int bitIndex) { if (bitIndex < 0) throw new IndexOutOfBoundsException("bitIndex < 0: " + bitIndex); int wordIndex = wordIndex(bitIndex); if (wordIndex >= wordsInUse) return; words[wordIndex] &= ~(1L << bitIndex); recalculateWordsInUse(); checkInvariants(); }
// in java-util/BitSet.java
public boolean get(int bitIndex) { if (bitIndex < 0) throw new IndexOutOfBoundsException("bitIndex < 0: " + bitIndex); checkInvariants(); int wordIndex = wordIndex(bitIndex); return (wordIndex < wordsInUse) && ((words[wordIndex] & (1L << bitIndex)) != 0); }
// in java-util/BitSet.java
public int nextSetBit(int fromIndex) { if (fromIndex < 0) throw new IndexOutOfBoundsException("fromIndex < 0: " + fromIndex); checkInvariants(); int u = wordIndex(fromIndex); if (u >= wordsInUse) return -1; long word = words[u] & (WORD_MASK << fromIndex); while (true) { if (word != 0) return (u * BITS_PER_WORD) + Long.numberOfTrailingZeros(word); if (++u == wordsInUse) return -1; word = words[u]; } }
// in java-util/BitSet.java
public int nextClearBit(int fromIndex) { // Neither spec nor implementation handle bitsets of maximal length. // See 4816253. if (fromIndex < 0) throw new IndexOutOfBoundsException("fromIndex < 0: " + fromIndex); checkInvariants(); int u = wordIndex(fromIndex); if (u >= wordsInUse) return fromIndex; long word = ~words[u] & (WORD_MASK << fromIndex); while (true) { if (word != 0) return (u * BITS_PER_WORD) + Long.numberOfTrailingZeros(word); if (++u == wordsInUse) return wordsInUse * BITS_PER_WORD; word = ~words[u]; } }
// in java-util/Collections.java
public static <T> void copy(List<? super T> dest, List<? extends T> src) { int srcSize = src.size(); if (srcSize > dest.size()) throw new IndexOutOfBoundsException("Source does not fit in dest"); if (srcSize < COPY_THRESHOLD || (src instanceof RandomAccess && dest instanceof RandomAccess)) { for (int i=0; i<srcSize; i++) dest.set(i, src.get(i)); } else { ListIterator<? super T> di=dest.listIterator(); ListIterator<? extends T> si=src.listIterator(); for (int i=0; i<srcSize; i++) { di.next(); di.set(si.next()); } } }
// in java-util/Collections.java
public Object get(int index) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/Collections.java
public E get(int index) { if (index != 0) throw new IndexOutOfBoundsException("Index: "+index+", Size: 1"); return element; }
// in java-util/Collections.java
public E get(int index) { if (index < 0 || index >= n) throw new IndexOutOfBoundsException("Index: "+index+ ", Size: "+n); return element; }
// in java-util/Collections.java
public List<E> subList(int fromIndex, int toIndex) { if (fromIndex < 0) throw new IndexOutOfBoundsException("fromIndex = " + fromIndex); if (toIndex > n) throw new IndexOutOfBoundsException("toIndex = " + toIndex); if (fromIndex > toIndex) throw new IllegalArgumentException("fromIndex(" + fromIndex + ") > toIndex(" + toIndex + ")"); return new CopiesList(toIndex - fromIndex, element); }
5
              
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
0
(Domain) ConcurrentModificationException 31
              
// in java-util/LinkedList.java
final void checkForComodification() { if (modCount != expectedModCount) throw new ConcurrentModificationException(); }
// in java-util/TreeMap.java
final Entry<K,V> nextEntry() { Entry<K,V> e = next; if (e == null) throw new NoSuchElementException(); if (modCount != expectedModCount) throw new ConcurrentModificationException(); next = successor(e); lastReturned = e; return e; }
// in java-util/TreeMap.java
final Entry<K,V> prevEntry() { Entry<K,V> e = next; if (e == null) throw new NoSuchElementException(); if (modCount != expectedModCount) throw new ConcurrentModificationException(); next = predecessor(e); lastReturned = e; return e; }
// in java-util/TreeMap.java
public void remove() { if (lastReturned == null) throw new IllegalStateException(); if (modCount != expectedModCount) throw new ConcurrentModificationException(); // deleted entries are replaced by their successors if (lastReturned.left != null && lastReturned.right != null) next = lastReturned; deleteEntry(lastReturned); expectedModCount = modCount; lastReturned = null; }
// in java-util/TreeMap.java
final TreeMap.Entry<K,V> nextEntry() { TreeMap.Entry<K,V> e = next; if (e == null || e.key == fenceKey) throw new NoSuchElementException(); if (m.modCount != expectedModCount) throw new ConcurrentModificationException(); next = successor(e); lastReturned = e; return e; }
// in java-util/TreeMap.java
final TreeMap.Entry<K,V> prevEntry() { TreeMap.Entry<K,V> e = next; if (e == null || e.key == fenceKey) throw new NoSuchElementException(); if (m.modCount != expectedModCount) throw new ConcurrentModificationException(); next = predecessor(e); lastReturned = e; return e; }
// in java-util/TreeMap.java
final void removeAscending() { if (lastReturned == null) throw new IllegalStateException(); if (m.modCount != expectedModCount) throw new ConcurrentModificationException(); // deleted entries are replaced by their successors if (lastReturned.left != null && lastReturned.right != null) next = lastReturned; m.deleteEntry(lastReturned); lastReturned = null; expectedModCount = m.modCount; }
// in java-util/TreeMap.java
final void removeDescending() { if (lastReturned == null) throw new IllegalStateException(); if (m.modCount != expectedModCount) throw new ConcurrentModificationException(); m.deleteEntry(lastReturned); lastReturned = null; expectedModCount = m.modCount; }
// in java-util/ArrayDeque.java
private boolean delete(int i) { checkInvariants(); final E[] elements = this.elements; final int mask = elements.length - 1; final int h = head; final int t = tail; final int front = (i - h) & mask; final int back = (t - i) & mask; // Invariant: head <= i < tail mod circularity if (front >= ((t - h) & mask)) throw new ConcurrentModificationException(); // Optimize for least element motion if (front < back) { if (h <= i) { System.arraycopy(elements, h, elements, h + 1, front); } else { // Wrap around System.arraycopy(elements, 0, elements, 1, i); elements[0] = elements[mask]; System.arraycopy(elements, h, elements, h + 1, mask - h); } elements[h] = null; head = (h + 1) & mask; return false; } else { if (i < t) { // Copy the null tail as well System.arraycopy(elements, i + 1, elements, i, back); tail = t - 1; } else { // Wrap around System.arraycopy(elements, i + 1, elements, i, mask - i); elements[mask] = elements[0]; System.arraycopy(elements, 1, elements, 0, t); tail = (t - 1) & mask; } return true; } }
// in java-util/ArrayDeque.java
public E next() { if (cursor == fence) throw new NoSuchElementException(); E result = elements[cursor]; // This check doesn't catch all possible comodifications, // but does catch the ones that corrupt traversal if (tail != fence || result == null) throw new ConcurrentModificationException(); lastRet = cursor; cursor = (cursor + 1) & (elements.length - 1); return result; }
// in java-util/ArrayDeque.java
public E next() { if (cursor == fence) throw new NoSuchElementException(); cursor = (cursor - 1) & (elements.length - 1); E result = elements[cursor]; if (head != fence || result == null) throw new ConcurrentModificationException(); lastRet = cursor; return result; }
// in java-util/WeakHashMap.java
protected Entry<K,V> nextEntry() { if (modCount != expectedModCount) throw new ConcurrentModificationException(); if (nextKey == null && !hasNext()) throw new NoSuchElementException(); lastReturned = entry; entry = entry.next; currentKey = nextKey; nextKey = null; return lastReturned; }
// in java-util/WeakHashMap.java
public void remove() { if (lastReturned == null) throw new IllegalStateException(); if (modCount != expectedModCount) throw new ConcurrentModificationException(); WeakHashMap.this.remove(currentKey); expectedModCount = modCount; lastReturned = null; currentKey = null; }
// in java-util/LinkedHashMap.java
public void remove() { if (lastReturned == null) throw new IllegalStateException(); if (modCount != expectedModCount) throw new ConcurrentModificationException(); LinkedHashMap.this.remove(lastReturned.key); lastReturned = null; expectedModCount = modCount; }
// in java-util/LinkedHashMap.java
Entry<K,V> nextEntry() { if (modCount != expectedModCount) throw new ConcurrentModificationException(); if (nextEntry == header) throw new NoSuchElementException(); Entry<K,V> e = lastReturned = nextEntry; nextEntry = e.after; return e; }
// in java-util/AbstractList.java
public void remove() { if (lastRet == -1) throw new IllegalStateException(); checkForComodification(); try { AbstractList.this.remove(lastRet); if (lastRet < cursor) cursor--; lastRet = -1; expectedModCount = modCount; } catch (IndexOutOfBoundsException e) { throw new ConcurrentModificationException(); } }
// in java-util/AbstractList.java
final void checkForComodification() { if (modCount != expectedModCount) throw new ConcurrentModificationException(); }
// in java-util/AbstractList.java
public void set(E e) { if (lastRet == -1) throw new IllegalStateException(); checkForComodification(); try { AbstractList.this.set(lastRet, e); expectedModCount = modCount; } catch (IndexOutOfBoundsException ex) { throw new ConcurrentModificationException(); } }
// in java-util/AbstractList.java
public void add(E e) { checkForComodification(); try { AbstractList.this.add(cursor++, e); lastRet = -1; expectedModCount = modCount; } catch (IndexOutOfBoundsException ex) { throw new ConcurrentModificationException(); } }
// in java-util/AbstractList.java
private void checkForComodification() { if (l.modCount != expectedModCount) throw new ConcurrentModificationException(); }
// in java-util/HashMap.java
final Entry<K,V> nextEntry() { if (modCount != expectedModCount) throw new ConcurrentModificationException(); Entry<K,V> e = next; if (e == null) throw new NoSuchElementException(); if ((next = e.next) == null) { Entry[] t = table; while (index < t.length && (next = t[index++]) == null) ; } current = e; return e; }
// in java-util/HashMap.java
public void remove() { if (current == null) throw new IllegalStateException(); if (modCount != expectedModCount) throw new ConcurrentModificationException(); Object k = current.key; current = null; HashMap.this.removeEntryForKey(k); expectedModCount = modCount; }
// in java-util/ArrayList.java
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException{ // Write out element count, and any hidden stuff int expectedModCount = modCount; s.defaultWriteObject(); // Write out array length s.writeInt(elementData.length); // Write out all elements in the proper order. for (int i=0; i<size; i++) s.writeObject(elementData[i]); if (modCount != expectedModCount) { throw new ConcurrentModificationException(); } }
// in java-util/IdentityHashMap.java
protected int nextIndex() { if (modCount != expectedModCount) throw new ConcurrentModificationException(); if (!indexValid && !hasNext()) throw new NoSuchElementException(); indexValid = false; lastReturnedIndex = index; index += 2; return lastReturnedIndex; }
// in java-util/IdentityHashMap.java
public void remove() { if (lastReturnedIndex == -1) throw new IllegalStateException(); if (modCount != expectedModCount) throw new ConcurrentModificationException(); expectedModCount = ++modCount; int deletedSlot = lastReturnedIndex; lastReturnedIndex = -1; size--; // back up index to revisit new contents after deletion index = deletedSlot; indexValid = false; // Removal code proceeds as in closeDeletion except that // it must catch the rare case where an element already // seen is swapped into a vacant slot that will be later // traversed by this iterator. We cannot allow future // next() calls to return it again. The likelihood of // this occurring under 2/3 load factor is very slim, but // when it does happen, we must make a copy of the rest of // the table to use for the rest of the traversal. Since // this can only happen when we are near the end of the table, // even in these rare cases, this is not very expensive in // time or space. Object[] tab = traversalTable; int len = tab.length; int d = deletedSlot; K key = (K) tab[d]; tab[d] = null; // vacate the slot tab[d + 1] = null; // If traversing a copy, remove in real table. // We can skip gap-closure on copy. if (tab != IdentityHashMap.this.table) { IdentityHashMap.this.remove(key); expectedModCount = modCount; return; } Object item; for (int i = nextKeyIndex(d, len); (item = tab[i]) != null; i = nextKeyIndex(i, len)) { int r = hash(item, len); // See closeDeletion for explanation of this conditional if ((i < r && (r <= d || d <= i)) || (r <= d && d <= i)) { // If we are about to swap an already-seen element // into a slot that may later be returned by next(), // then clone the rest of table for use in future // next() calls. It is OK that our copy will have // a gap in the "wrong" place, since it will never // be used for searching anyway. if (i < deletedSlot && d >= deletedSlot && traversalTable == IdentityHashMap.this.table) { int remaining = len - deletedSlot; Object[] newTable = new Object[remaining]; System.arraycopy(tab, deletedSlot, newTable, 0, remaining); traversalTable = newTable; index = 0; } tab[d] = item; tab[d + 1] = tab[i + 1]; tab[i] = null; tab[i + 1] = null; d = i; } }
// in java-util/PriorityQueue.java
public E next() { if (expectedModCount != modCount) throw new ConcurrentModificationException(); if (cursor < size) return (E) queue[lastRet = cursor++]; if (forgetMeNot != null) { lastRet = -1; lastRetElt = forgetMeNot.poll(); if (lastRetElt != null) return lastRetElt; } throw new NoSuchElementException(); }
// in java-util/PriorityQueue.java
public void remove() { if (expectedModCount != modCount) throw new ConcurrentModificationException(); if (lastRet != -1) { E moved = PriorityQueue.this.removeAt(lastRet); lastRet = -1; if (moved == null) cursor--; else { if (forgetMeNot == null) forgetMeNot = new ArrayDeque<E>(); forgetMeNot.add(moved); } } else if (lastRetElt != null) { PriorityQueue.this.removeEq(lastRetElt); lastRetElt = null; } else { throw new IllegalStateException(); } expectedModCount = modCount; }
// in java-util/Hashtable.java
public T next() { if (modCount != expectedModCount) throw new ConcurrentModificationException(); return nextElement(); }
// in java-util/Hashtable.java
public void remove() { if (!iterator) throw new UnsupportedOperationException(); if (lastReturned == null) throw new IllegalStateException("Hashtable Enumerator"); if (modCount != expectedModCount) throw new ConcurrentModificationException(); synchronized(Hashtable.this) { Entry[] tab = Hashtable.this.table; int index = (lastReturned.hash & 0x7FFFFFFF) % tab.length; for (Entry<K,V> e = tab[index], prev = null; e != null; prev = e, e = e.next) { if (e == lastReturned) { modCount++; expectedModCount++; if (prev == null) tab[index] = e.next; else prev.next = e.next; count--; lastReturned = null; return; } } throw new ConcurrentModificationException(); } }
// in java-util/Collections.java
public void putAll(Map<? extends K, ? extends V> t) { // See CheckCollection.addAll, above, for an explanation K[] keys = null; try { keys = t.keySet().toArray(zeroLengthKeyArray()); } catch (ArrayStoreException e) { throw new ClassCastException(); } V[] values = null; try { values = t.values().toArray(zeroLengthValueArray()); } catch (ArrayStoreException e) { throw new ClassCastException(); } if (keys.length != values.length) throw new ConcurrentModificationException(); for (int i = 0; i < keys.length; i++) m.put(keys[i], values[i]); }
3
              
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException e) { throw new ConcurrentModificationException(); }
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException ex) { throw new ConcurrentModificationException(); }
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException ex) { throw new ConcurrentModificationException(); }
0
(Lib) IllegalStateException 31
              
// in java-util/LinkedList.java
public void remove() { checkForComodification(); Entry<E> lastNext = lastReturned.next; try { LinkedList.this.remove(lastReturned); } catch (NoSuchElementException e) { throw new IllegalStateException(); } if (next==lastReturned) next = lastNext; else nextIndex--; lastReturned = header; expectedModCount++; }
// in java-util/LinkedList.java
public void set(E e) { if (lastReturned == header) throw new IllegalStateException(); checkForComodification(); lastReturned.element = e; }
// in java-util/TreeMap.java
public void remove() { if (lastReturned == null) throw new IllegalStateException(); if (modCount != expectedModCount) throw new ConcurrentModificationException(); // deleted entries are replaced by their successors if (lastReturned.left != null && lastReturned.right != null) next = lastReturned; deleteEntry(lastReturned); expectedModCount = modCount; lastReturned = null; }
// in java-util/TreeMap.java
final void removeAscending() { if (lastReturned == null) throw new IllegalStateException(); if (m.modCount != expectedModCount) throw new ConcurrentModificationException(); // deleted entries are replaced by their successors if (lastReturned.left != null && lastReturned.right != null) next = lastReturned; m.deleteEntry(lastReturned); lastReturned = null; expectedModCount = m.modCount; }
// in java-util/TreeMap.java
final void removeDescending() { if (lastReturned == null) throw new IllegalStateException(); if (m.modCount != expectedModCount) throw new ConcurrentModificationException(); m.deleteEntry(lastReturned); lastReturned = null; expectedModCount = m.modCount; }
// in java-util/ArrayDeque.java
private void doubleCapacity() { assert head == tail; int p = head; int n = elements.length; int r = n - p; // number of elements to the right of p int newCapacity = n << 1; if (newCapacity < 0) throw new IllegalStateException("Sorry, deque too big"); Object[] a = new Object[newCapacity]; System.arraycopy(elements, p, a, 0, r); System.arraycopy(elements, 0, a, r, p); elements = (E[])a; head = 0; tail = n; }
// in java-util/ArrayDeque.java
public void remove() { if (lastRet < 0) throw new IllegalStateException(); if (delete(lastRet)) { // if left-shifted, undo increment in next() cursor = (cursor - 1) & (elements.length - 1); fence = tail; } lastRet = -1; }
// in java-util/ArrayDeque.java
public void remove() { if (lastRet < 0) throw new IllegalStateException(); if (!delete(lastRet)) { cursor = (cursor + 1) & (elements.length - 1); fence = head; } lastRet = -1; }
// in java-util/WeakHashMap.java
public void remove() { if (lastReturned == null) throw new IllegalStateException(); if (modCount != expectedModCount) throw new ConcurrentModificationException(); WeakHashMap.this.remove(currentKey); expectedModCount = modCount; lastReturned = null; currentKey = null; }
// in java-util/LinkedHashMap.java
public void remove() { if (lastReturned == null) throw new IllegalStateException(); if (modCount != expectedModCount) throw new ConcurrentModificationException(); LinkedHashMap.this.remove(lastReturned.key); lastReturned = null; expectedModCount = modCount; }
// in java-util/Scanner.java
private void useTypeCache() { if (closed) throw new IllegalStateException("Scanner closed"); position = hasNextPosition; hasNextPattern = null; typeCache = null; }
// in java-util/Scanner.java
private void ensureOpen() { if (closed) throw new IllegalStateException("Scanner closed"); }
// in java-util/Scanner.java
public MatchResult match() { if (!matchValid) throw new IllegalStateException("No match result available"); return matcher.toMatchResult(); }
// in java-util/Timer.java
private void sched(TimerTask task, long time, long period) { if (time < 0) throw new IllegalArgumentException("Illegal execution time."); synchronized(queue) { if (!thread.newTasksMayBeScheduled) throw new IllegalStateException("Timer already cancelled."); synchronized(task.lock) { if (task.state != TimerTask.VIRGIN) throw new IllegalStateException( "Task already scheduled or cancelled"); task.nextExecutionTime = time; task.period = period; task.state = TimerTask.SCHEDULED; } queue.add(task); if (queue.getMin() == task) queue.notify(); } }
// in java-util/AbstractQueue.java
public boolean add(E e) { if (offer(e)) return true; else throw new IllegalStateException("Queue full"); }
// in java-util/AbstractList.java
public void remove() { if (lastRet == -1) throw new IllegalStateException(); checkForComodification(); try { AbstractList.this.remove(lastRet); if (lastRet < cursor) cursor--; lastRet = -1; expectedModCount = modCount; } catch (IndexOutOfBoundsException e) { throw new ConcurrentModificationException(); } }
// in java-util/AbstractList.java
public void set(E e) { if (lastRet == -1) throw new IllegalStateException(); checkForComodification(); try { AbstractList.this.set(lastRet, e); expectedModCount = modCount; } catch (IndexOutOfBoundsException ex) { throw new ConcurrentModificationException(); } }
// in java-util/HashMap.java
public void remove() { if (current == null) throw new IllegalStateException(); if (modCount != expectedModCount) throw new ConcurrentModificationException(); Object k = current.key; current = null; HashMap.this.removeEntryForKey(k); expectedModCount = modCount; }
// in java-util/RegularEnumSet.java
public void remove() { if (lastReturned == 0) throw new IllegalStateException(); elements -= lastReturned; lastReturned = 0; }
// in java-util/IdentityHashMap.java
private void resize(int newCapacity) { // assert (newCapacity & -newCapacity) == newCapacity; // power of 2 int newLength = newCapacity * 2; Object[] oldTable = table; int oldLength = oldTable.length; if (oldLength == 2*MAXIMUM_CAPACITY) { // can't expand any further if (threshold == MAXIMUM_CAPACITY-1) throw new IllegalStateException("Capacity exhausted."); threshold = MAXIMUM_CAPACITY-1; // Gigantic map! return; } if (oldLength >= newLength) return; Object[] newTable = new Object[newLength]; threshold = newLength / 3; for (int j = 0; j < oldLength; j += 2) { Object key = oldTable[j]; if (key != null) { Object value = oldTable[j+1]; oldTable[j] = null; oldTable[j+1] = null; int i = hash(key, newLength); while (newTable[i] != null) i = nextKeyIndex(i, newLength); newTable[i] = key; newTable[i + 1] = value; } } table = newTable; }
// in java-util/IdentityHashMap.java
public void remove() { if (lastReturnedIndex == -1) throw new IllegalStateException(); if (modCount != expectedModCount) throw new ConcurrentModificationException(); expectedModCount = ++modCount; int deletedSlot = lastReturnedIndex; lastReturnedIndex = -1; size--; // back up index to revisit new contents after deletion index = deletedSlot; indexValid = false; // Removal code proceeds as in closeDeletion except that // it must catch the rare case where an element already // seen is swapped into a vacant slot that will be later // traversed by this iterator. We cannot allow future // next() calls to return it again. The likelihood of // this occurring under 2/3 load factor is very slim, but // when it does happen, we must make a copy of the rest of // the table to use for the rest of the traversal. Since // this can only happen when we are near the end of the table, // even in these rare cases, this is not very expensive in // time or space. Object[] tab = traversalTable; int len = tab.length; int d = deletedSlot; K key = (K) tab[d]; tab[d] = null; // vacate the slot tab[d + 1] = null; // If traversing a copy, remove in real table. // We can skip gap-closure on copy. if (tab != IdentityHashMap.this.table) { IdentityHashMap.this.remove(key); expectedModCount = modCount; return; } Object item; for (int i = nextKeyIndex(d, len); (item = tab[i]) != null; i = nextKeyIndex(i, len)) { int r = hash(item, len); // See closeDeletion for explanation of this conditional if ((i < r && (r <= d || d <= i)) || (r <= d && d <= i)) { // If we are about to swap an already-seen element // into a slot that may later be returned by next(), // then clone the rest of table for use in future // next() calls. It is OK that our copy will have // a gap in the "wrong" place, since it will never // be used for searching anyway. if (i < deletedSlot && d >= deletedSlot && traversalTable == IdentityHashMap.this.table) { int remaining = len - deletedSlot; Object[] newTable = new Object[remaining]; System.arraycopy(tab, deletedSlot, newTable, 0, remaining); traversalTable = newTable; index = 0; } tab[d] = item; tab[d + 1] = tab[i + 1]; tab[i] = null; tab[i + 1] = null; d = i; } }
// in java-util/IdentityHashMap.java
public K getKey() { // Provide a better exception than out of bounds index if (lastReturnedIndex < 0) throw new IllegalStateException("Entry was removed"); return (K) unmaskNull(traversalTable[lastReturnedIndex]); }
// in java-util/IdentityHashMap.java
public V getValue() { // Provide a better exception than out of bounds index if (lastReturnedIndex < 0) throw new IllegalStateException("Entry was removed"); return (V) traversalTable[lastReturnedIndex+1]; }
// in java-util/IdentityHashMap.java
public V setValue(V value) { // It would be mean-spirited to proceed here if remove() called if (lastReturnedIndex < 0) throw new IllegalStateException("Entry was removed"); V oldValue = (V) traversalTable[lastReturnedIndex+1]; traversalTable[lastReturnedIndex+1] = value; // if shadowing, force into main table if (traversalTable != IdentityHashMap.this.table) put((K) traversalTable[lastReturnedIndex], value); return oldValue; }
// in java-util/PriorityQueue.java
public void remove() { if (expectedModCount != modCount) throw new ConcurrentModificationException(); if (lastRet != -1) { E moved = PriorityQueue.this.removeAt(lastRet); lastRet = -1; if (moved == null) cursor--; else { if (forgetMeNot == null) forgetMeNot = new ArrayDeque<E>(); forgetMeNot.add(moved); } } else if (lastRetElt != null) { PriorityQueue.this.removeEq(lastRetElt); lastRetElt = null; } else { throw new IllegalStateException(); } expectedModCount = modCount; }
// in java-util/EnumMap.java
private void checkLastReturnedIndex() { if (lastReturnedIndex < 0) throw new IllegalStateException(); }
// in java-util/EnumMap.java
private void checkLastReturnedIndexForEntryUse() { if (lastReturnedIndex < 0) throw new IllegalStateException("Entry was removed"); }
// in java-util/JumboEnumSet.java
public void remove() { if (lastReturned == 0) throw new IllegalStateException(); elements[lastReturnedIndex] -= lastReturned; size--; lastReturned = 0; }
// in java-util/Hashtable.java
public void remove() { if (!iterator) throw new UnsupportedOperationException(); if (lastReturned == null) throw new IllegalStateException("Hashtable Enumerator"); if (modCount != expectedModCount) throw new ConcurrentModificationException(); synchronized(Hashtable.this) { Entry[] tab = Hashtable.this.table; int index = (lastReturned.hash & 0x7FFFFFFF) % tab.length; for (Entry<K,V> e = tab[index], prev = null; e != null; prev = e, e = e.next) { if (e == lastReturned) { modCount++; expectedModCount++; if (prev == null) tab[index] = e.next; else prev.next = e.next; count--; lastReturned = null; return; } } throw new ConcurrentModificationException(); } }
// in java-util/Hashtable.java
public void remove() { throw new IllegalStateException("Hashtable Iterator"); }
1
              
// in java-util/LinkedList.java
catch (NoSuchElementException e) { throw new IllegalStateException(); }
0
(Lib) InternalError 24
              
// in java-util/Vector.java
public synchronized Object clone() { try { Vector<E> v = (Vector<E>) super.clone(); v.elementData = Arrays.copyOf(elementData, elementCount); v.modCount = 0; return v; } catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); } }
// in java-util/UUID.java
public static UUID nameUUIDFromBytes(byte[] name) { MessageDigest md; try { md = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException nsae) { throw new InternalError("MD5 not supported"); } byte[] md5Bytes = md.digest(name); md5Bytes[6] &= 0x0f; /* clear version */ md5Bytes[6] |= 0x30; /* set to version 3 */ md5Bytes[8] &= 0x3f; /* clear variant */ md5Bytes[8] |= 0x80; /* set to IETF variant */ return new UUID(md5Bytes); }
// in java-util/ResourceBundle.java
public Object clone() { try { CacheKey clone = (CacheKey) super.clone(); if (loaderRef != null) { clone.loaderRef = new LoaderReference(loaderRef.get(), referenceQueue, clone); } // Clear the reference to a Throwable clone.cause = null; return clone; } catch (CloneNotSupportedException e) { //this should never happen throw new InternalError(); } }
// in java-util/LinkedList.java
public Object clone() { LinkedList<E> clone = null; try { clone = (LinkedList<E>) super.clone(); } catch (CloneNotSupportedException e) { throw new InternalError(); } // Put clone into "virgin" state clone.header = new Entry<E>(null, null, null); clone.header.next = clone.header.previous = clone.header; clone.size = 0; clone.modCount = 0; // Initialize clone with our elements for (Entry<E> e = header.next; e != header; e = e.next) clone.add(e.element); return clone; }
// in java-util/TreeMap.java
public Object clone() { TreeMap<K,V> clone = null; try { clone = (TreeMap<K,V>) super.clone(); } catch (CloneNotSupportedException e) { throw new InternalError(); } // Put clone into "virgin" state (except for comparator) clone.root = null; clone.size = 0; clone.modCount = 0; clone.entrySet = null; clone.navigableKeySet = null; clone.descendingMap = null; // Initialize clone with our mappings try { clone.buildFromSorted(size, entrySet().iterator(), null, null); } catch (java.io.IOException cannotHappen) { } catch (ClassNotFoundException cannotHappen) { } return clone; }
// in java-util/TreeMap.java
public Set<Map.Entry<K,V>> entrySet() { throw new InternalError(); }
// in java-util/TreeMap.java
public K lastKey() { throw new InternalError(); }
// in java-util/TreeMap.java
public K firstKey() { throw new InternalError(); }
// in java-util/TreeMap.java
public SortedMap<K,V> subMap(K fromKey, K toKey) { throw new InternalError(); }
// in java-util/TreeMap.java
public SortedMap<K,V> headMap(K toKey) { throw new InternalError(); }
// in java-util/TreeMap.java
public SortedMap<K,V> tailMap(K fromKey) { throw new InternalError(); }
// in java-util/TreeMap.java
public Comparator<? super K> comparator() { throw new InternalError(); }
// in java-util/Currency.java
public Object run() { try { Class data = Class.forName("java.util.CurrencyData"); mainTable = (String) data.getDeclaredField("mainTable").get(data); scCutOverTimes = (long[]) data.getDeclaredField("scCutOverTimes").get(data); scOldCurrencies = (String[]) data.getDeclaredField("scOldCurrencies").get(data); scNewCurrencies = (String[]) data.getDeclaredField("scNewCurrencies").get(data); scOldCurrenciesDFD = (int[]) data.getDeclaredField("scOldCurrenciesDFD").get(data); scNewCurrenciesDFD = (int[]) data.getDeclaredField("scNewCurrenciesDFD").get(data); otherCurrencies = (String) data.getDeclaredField("otherCurrencies").get(data); otherCurrenciesDFD = (int[]) data.getDeclaredField("otherCurrenciesDFD").get(data); } catch (ClassNotFoundException e) { throw new InternalError(); } catch (NoSuchFieldException e) { throw new InternalError(); } catch (IllegalAccessException e) { throw new InternalError(); } return null; }
// in java-util/HashSet.java
public Object clone() { try { HashSet<E> newSet = (HashSet<E>) super.clone(); newSet.map = (HashMap<E, Object>) map.clone(); return newSet; } catch (CloneNotSupportedException e) { throw new InternalError(); } }
// in java-util/ArrayList.java
public Object clone() { try { ArrayList<E> v = (ArrayList<E>) super.clone(); v.elementData = Arrays.copyOf(elementData, size); v.modCount = 0; return v; } catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); } }
// in java-util/TimeZone.java
public Object clone() { try { TimeZone other = (TimeZone) super.clone(); other.ID = ID; return other; } catch (CloneNotSupportedException e) { throw new InternalError(); } }
// in java-util/IdentityHashMap.java
public Object clone() { try { IdentityHashMap<K,V> m = (IdentityHashMap<K,V>) super.clone(); m.entrySet = null; m.table = (Object[])table.clone(); return m; } catch (CloneNotSupportedException e) { throw new InternalError(); } }
// in java-util/BitSet.java
public Object clone() { if (! sizeIsSticky) trimToSize(); try { BitSet result = (BitSet) super.clone(); result.words = words.clone(); result.checkInvariants(); return result; } catch (CloneNotSupportedException e) { throw new InternalError(); } }
// in java-util/Hashtable.java
public synchronized Object clone() { try { Hashtable<K,V> t = (Hashtable<K,V>) super.clone(); t.table = new Entry[table.length]; for (int i = table.length ; i-- > 0 ; ) { t.table[i] = (table[i] != null) ? (Entry<K,V>) table[i].clone() : null; } t.keySet = null; t.entrySet = null; t.values = null; t.modCount = 0; return t; } catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); } }
// in java-util/Calendar.java
public Object clone() { try { Calendar other = (Calendar) super.clone(); other.fields = new int[FIELD_COUNT]; other.isSet = new boolean[FIELD_COUNT]; other.stamp = new int[FIELD_COUNT]; for (int i = 0; i < FIELD_COUNT; i++) { other.fields[i] = fields[i]; other.stamp[i] = stamp[i]; other.isSet[i] = isSet[i]; } other.zone = (TimeZone) zone.clone(); return other; } catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); } }
// in java-util/Locale.java
public Object clone() { try { Locale that = (Locale)super.clone(); return that; } catch (CloneNotSupportedException e) { throw new InternalError(); } }
// in java-util/TreeSet.java
public Object clone() { TreeSet<E> clone = null; try { clone = (TreeSet<E>) super.clone(); } catch (CloneNotSupportedException e) { throw new InternalError(); } clone.m = new TreeMap<E,Object>(m); return clone; }
17
              
// in java-util/Vector.java
catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); }
// in java-util/UUID.java
catch (NoSuchAlgorithmException nsae) { throw new InternalError("MD5 not supported"); }
// in java-util/ResourceBundle.java
catch (CloneNotSupportedException e) { //this should never happen throw new InternalError(); }
// in java-util/LinkedList.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/TreeMap.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/Currency.java
catch (ClassNotFoundException e) { throw new InternalError(); }
// in java-util/Currency.java
catch (NoSuchFieldException e) { throw new InternalError(); }
// in java-util/Currency.java
catch (IllegalAccessException e) { throw new InternalError(); }
// in java-util/HashSet.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/ArrayList.java
catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); }
// in java-util/TimeZone.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/IdentityHashMap.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/BitSet.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/Hashtable.java
catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); }
// in java-util/Calendar.java
catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); }
// in java-util/Locale.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/TreeSet.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
0
(Lib) ClassCastException 15
              
// in java-util/ResourceBundle.java
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException { String bundleName = toBundleName(baseName, locale); ResourceBundle bundle = null; if (format.equals("java.class")) { try { Class<? extends ResourceBundle> bundleClass = (Class<? extends ResourceBundle>)loader.loadClass(bundleName); // If the class isn't a ResourceBundle subclass, throw a // ClassCastException. if (ResourceBundle.class.isAssignableFrom(bundleClass)) { bundle = bundleClass.newInstance(); } else { throw new ClassCastException(bundleClass.getName() + " cannot be cast to ResourceBundle"); } } catch (ClassNotFoundException e) { } } else if (format.equals("java.properties")) { final String resourceName = toResourceName(bundleName, "properties"); final ClassLoader classLoader = loader; final boolean reloadFlag = reload; InputStream stream = null; try { stream = AccessController.doPrivileged( new PrivilegedExceptionAction<InputStream>() { public InputStream run() throws IOException { InputStream is = null; if (reloadFlag) { URL url = classLoader.getResource(resourceName); if (url != null) { URLConnection connection = url.openConnection(); if (connection != null) { // Disable caches to get fresh data for // reloading. connection.setUseCaches(false); is = connection.getInputStream(); } } } else { is = classLoader.getResourceAsStream(resourceName); } return is; } }); } catch (PrivilegedActionException e) { throw (IOException) e.getException(); } if (stream != null) { try { bundle = new PropertyResourceBundle(stream); } finally { stream.close(); } } }
// in java-util/EnumSet.java
public static <E extends Enum<E>> EnumSet<E> noneOf(Class<E> elementType) { Enum[] universe = getUniverse(elementType); if (universe == null) throw new ClassCastException(elementType + " not an enum"); if (universe.length <= 64) return new RegularEnumSet<E>(elementType, universe); else return new JumboEnumSet<E>(elementType, universe); }
// in java-util/EnumSet.java
final void typeCheck(E e) { Class eClass = e.getClass(); if (eClass != elementType && eClass.getSuperclass() != elementType) throw new ClassCastException(eClass + " != " + elementType); }
// in java-util/RegularEnumSet.java
public boolean addAll(Collection<? extends E> c) { if (!(c instanceof RegularEnumSet)) return super.addAll(c); RegularEnumSet es = (RegularEnumSet)c; if (es.elementType != elementType) { if (es.isEmpty()) return false; else throw new ClassCastException( es.elementType + " != " + elementType); } long oldElements = elements; elements |= es.elements; return elements != oldElements; }
// in java-util/EnumMap.java
public void putAll(Map<? extends K, ? extends V> m) { if (m instanceof EnumMap) { EnumMap<? extends K, ? extends V> em = (EnumMap<? extends K, ? extends V>)m; if (em.keyType != keyType) { if (em.isEmpty()) return; throw new ClassCastException(em.keyType + " != " + keyType); } for (int i = 0; i < keyUniverse.length; i++) { Object emValue = em.vals[i]; if (emValue != null) { if (vals[i] == null) size++; vals[i] = emValue; } } } else { super.putAll(m); } }
// in java-util/EnumMap.java
private void typeCheck(K key) { Class keyClass = key.getClass(); if (keyClass != keyType && keyClass.getSuperclass() != keyType) throw new ClassCastException(keyClass + " != " + keyType); }
// in java-util/JumboEnumSet.java
public boolean addAll(Collection<? extends E> c) { if (!(c instanceof JumboEnumSet)) return super.addAll(c); JumboEnumSet es = (JumboEnumSet)c; if (es.elementType != elementType) { if (es.isEmpty()) return false; else throw new ClassCastException( es.elementType + " != " + elementType); } for (int i = 0; i < elements.length; i++) elements[i] |= es.elements[i]; return recalculateSize(); }
// in java-util/Collections.java
void typeCheck(Object o) { if (!type.isInstance(o)) throw new ClassCastException("Attempt to insert " + o.getClass() + " element into collection with element type " + type); }
// in java-util/Collections.java
public boolean addAll(Collection<? extends E> coll) { /* * Dump coll into an array of the required type. This serves * three purposes: it insulates us from concurrent changes in * the contents of coll, it type-checks all of the elements in * coll, and it provides all-or-nothing semantics (which we * wouldn't get if we type-checked each element as we added it). */ E[] a = null; try { a = coll.toArray(zeroLengthElementArray()); } catch (ArrayStoreException e) { throw new ClassCastException(); } boolean result = false; for (E e : a) result |= c.add(e); return result; }
// in java-util/Collections.java
public boolean addAll(int index, Collection<? extends E> c) { // See CheckCollection.addAll, above, for an explanation E[] a = null; try { a = c.toArray(zeroLengthElementArray()); } catch (ArrayStoreException e) { throw new ClassCastException(); } return list.addAll(index, Arrays.asList(a)); }
// in java-util/Collections.java
private void typeCheck(Object key, Object value) { if (!keyType.isInstance(key)) throw new ClassCastException("Attempt to insert " + key.getClass() + " key into collection with key type " + keyType); if (!valueType.isInstance(value)) throw new ClassCastException("Attempt to insert " + value.getClass() +" value into collection with value type " + valueType); }
// in java-util/Collections.java
public void putAll(Map<? extends K, ? extends V> t) { // See CheckCollection.addAll, above, for an explanation K[] keys = null; try { keys = t.keySet().toArray(zeroLengthKeyArray()); } catch (ArrayStoreException e) { throw new ClassCastException(); } V[] values = null; try { values = t.values().toArray(zeroLengthValueArray()); } catch (ArrayStoreException e) { throw new ClassCastException(); } if (keys.length != values.length) throw new ConcurrentModificationException(); for (int i = 0; i < keys.length; i++) m.put(keys[i], values[i]); }
// in java-util/Collections.java
public V setValue(V value) { if (!valueType.isInstance(value)) throw new ClassCastException("Attempt to insert " + value.getClass() + " value into collection with value type " + valueType); return e.setValue(value); }
4
              
// in java-util/Collections.java
catch (ArrayStoreException e) { throw new ClassCastException(); }
// in java-util/Collections.java
catch (ArrayStoreException e) { throw new ClassCastException(); }
// in java-util/Collections.java
catch (ArrayStoreException e) { throw new ClassCastException(); }
// in java-util/Collections.java
catch (ArrayStoreException e) { throw new ClassCastException(); }
0
(Lib) ArrayIndexOutOfBoundsException 13
              
// in java-util/JapaneseImperialCalendar.java
public int getActualMaximum(int field) { final int fieldsForFixedMax = ERA_MASK|DAY_OF_WEEK_MASK|HOUR_MASK|AM_PM_MASK| HOUR_OF_DAY_MASK|MINUTE_MASK|SECOND_MASK|MILLISECOND_MASK| ZONE_OFFSET_MASK|DST_OFFSET_MASK; if ((fieldsForFixedMax & (1<<field)) != 0) { return getMaximum(field); } JapaneseImperialCalendar jc = getNormalizedCalendar(); LocalGregorianCalendar.Date date = jc.jdate; int normalizedYear = date.getNormalizedYear(); int value = -1; switch (field) { case MONTH: { value = DECEMBER; if (isTransitionYear(date.getNormalizedYear())) { // TODO: there may be multiple transitions in a year. int eraIndex = getEraIndex(date); if (date.getYear() != 1) { eraIndex++; assert eraIndex < eras.length; } long transition = sinceFixedDates[eraIndex]; long fd = jc.cachedFixedDate; if (fd < transition) { LocalGregorianCalendar.Date ldate = (LocalGregorianCalendar.Date) date.clone(); jcal.getCalendarDateFromFixedDate(ldate, transition - 1); value = ldate.getMonth() - 1; } } else { LocalGregorianCalendar.Date d = jcal.getCalendarDate(Long.MAX_VALUE, getZone()); if (date.getEra() == d.getEra() && date.getYear() == d.getYear()) { value = d.getMonth() - 1; } } } break; case DAY_OF_MONTH: value = jcal.getMonthLength(date); break; case DAY_OF_YEAR: { if (isTransitionYear(date.getNormalizedYear())) { // Handle transition year. // TODO: there may be multiple transitions in a year. int eraIndex = getEraIndex(date); if (date.getYear() != 1) { eraIndex++; assert eraIndex < eras.length; } long transition = sinceFixedDates[eraIndex]; long fd = jc.cachedFixedDate; CalendarDate d = gcal.newCalendarDate(TimeZone.NO_TIMEZONE); d.setDate(date.getNormalizedYear(), BaseCalendar.JANUARY, 1); if (fd < transition) { value = (int)(transition - gcal.getFixedDate(d)); } else { d.addYear(+1); value = (int)(gcal.getFixedDate(d) - transition); } } else { LocalGregorianCalendar.Date d = jcal.getCalendarDate(Long.MAX_VALUE, getZone()); if (date.getEra() == d.getEra() && date.getYear() == d.getYear()) { long fd = jcal.getFixedDate(d); long jan1 = getFixedDateJan1(d, fd); value = (int)(fd - jan1) + 1; } else if (date.getYear() == getMinimum(YEAR)) { CalendarDate d1 = jcal.getCalendarDate(Long.MIN_VALUE, getZone()); long fd1 = jcal.getFixedDate(d1); d1.addYear(1); d1.setMonth(BaseCalendar.JANUARY).setDayOfMonth(1); jcal.normalize(d1); long fd2 = jcal.getFixedDate(d1); value = (int)(fd2 - fd1); } else { value = jcal.getYearLength(date); } } } break; case WEEK_OF_YEAR: { if (!isTransitionYear(date.getNormalizedYear())) { LocalGregorianCalendar.Date jd = jcal.getCalendarDate(Long.MAX_VALUE, getZone()); if (date.getEra() == jd.getEra() && date.getYear() == jd.getYear()) { long fd = jcal.getFixedDate(jd); long jan1 = getFixedDateJan1(jd, fd); value = getWeekNumber(jan1, fd); } else if (date.getEra() == null && date.getYear() == getMinimum(YEAR)) { CalendarDate d = jcal.getCalendarDate(Long.MIN_VALUE, getZone()); // shift 400 years to avoid underflow d.addYear(+400); jcal.normalize(d); jd.setEra(d.getEra()); jd.setDate(d.getYear() + 1, BaseCalendar.JANUARY, 1); jcal.normalize(jd); long jan1 = jcal.getFixedDate(d); long nextJan1 = jcal.getFixedDate(jd); long nextJan1st = jcal.getDayOfWeekDateOnOrBefore(nextJan1 + 6, getFirstDayOfWeek()); int ndays = (int)(nextJan1st - nextJan1); if (ndays >= getMinimalDaysInFirstWeek()) { nextJan1st -= 7; } value = getWeekNumber(jan1, nextJan1st); } else { // Get the day of week of January 1 of the year CalendarDate d = gcal.newCalendarDate(TimeZone.NO_TIMEZONE); d.setDate(date.getNormalizedYear(), BaseCalendar.JANUARY, 1); int dayOfWeek = gcal.getDayOfWeek(d); // Normalize the day of week with the firstDayOfWeek value dayOfWeek -= getFirstDayOfWeek(); if (dayOfWeek < 0) { dayOfWeek += 7; } value = 52; int magic = dayOfWeek + getMinimalDaysInFirstWeek() - 1; if ((magic == 6) || (date.isLeapYear() && (magic == 5 || magic == 12))) { value++; } } break; } if (jc == this) { jc = (JapaneseImperialCalendar) jc.clone(); } int max = getActualMaximum(DAY_OF_YEAR); jc.set(DAY_OF_YEAR, max); value = jc.get(WEEK_OF_YEAR); if (value == 1 && max > 7) { jc.add(WEEK_OF_YEAR, -1); value = jc.get(WEEK_OF_YEAR); } } break; case WEEK_OF_MONTH: { LocalGregorianCalendar.Date jd = jcal.getCalendarDate(Long.MAX_VALUE, getZone()); if (!(date.getEra() == jd.getEra() && date.getYear() == jd.getYear())) { CalendarDate d = gcal.newCalendarDate(TimeZone.NO_TIMEZONE); d.setDate(date.getNormalizedYear(), date.getMonth(), 1); int dayOfWeek = gcal.getDayOfWeek(d); int monthLength = gcal.getMonthLength(d); dayOfWeek -= getFirstDayOfWeek(); if (dayOfWeek < 0) { dayOfWeek += 7; } int nDaysFirstWeek = 7 - dayOfWeek; // # of days in the first week value = 3; if (nDaysFirstWeek >= getMinimalDaysInFirstWeek()) { value++; } monthLength -= nDaysFirstWeek + 7 * 3; if (monthLength > 0) { value++; if (monthLength > 7) { value++; } } } else { long fd = jcal.getFixedDate(jd); long month1 = fd - jd.getDayOfMonth() + 1; value = getWeekNumber(month1, fd); } } break; case DAY_OF_WEEK_IN_MONTH: { int ndays, dow1; int dow = date.getDayOfWeek(); BaseCalendar.Date d = (BaseCalendar.Date) date.clone(); ndays = jcal.getMonthLength(d); d.setDayOfMonth(1); jcal.normalize(d); dow1 = d.getDayOfWeek(); int x = dow - dow1; if (x < 0) { x += 7; } ndays -= x; value = (ndays + 6) / 7; } break; case YEAR: { CalendarDate jd = jcal.getCalendarDate(jc.getTimeInMillis(), getZone()); CalendarDate d; int eraIndex = getEraIndex(date); if (eraIndex == eras.length - 1) { d = jcal.getCalendarDate(Long.MAX_VALUE, getZone()); value = d.getYear(); // Use an equivalent year for the // getYearOffsetInMillis call to avoid overflow. if (value > 400) { jd.setYear(value - 400); } } else { d = jcal.getCalendarDate(eras[eraIndex + 1].getSince(getZone()) - 1, getZone()); value = d.getYear(); // Use the same year as d.getYear() to be // consistent with leap and common years. jd.setYear(value); } jcal.normalize(jd); if (getYearOffsetInMillis(jd) > getYearOffsetInMillis(d)) { value--; } } break; default: throw new ArrayIndexOutOfBoundsException(field); } return value; }
// in java-util/Vector.java
public synchronized E elementAt(int index) { if (index >= elementCount) { throw new ArrayIndexOutOfBoundsException(index + " >= " + elementCount); } return (E)elementData[index]; }
// in java-util/Vector.java
public synchronized void setElementAt(E obj, int index) { if (index >= elementCount) { throw new ArrayIndexOutOfBoundsException(index + " >= " + elementCount); } elementData[index] = obj; }
// in java-util/Vector.java
public synchronized void removeElementAt(int index) { modCount++; if (index >= elementCount) { throw new ArrayIndexOutOfBoundsException(index + " >= " + elementCount); } else if (index < 0) { throw new ArrayIndexOutOfBoundsException(index); } int j = elementCount - index - 1; if (j > 0) { System.arraycopy(elementData, index + 1, elementData, index, j); } elementCount--; elementData[elementCount] = null; /* to let gc do its work */ }
// in java-util/Vector.java
public synchronized void insertElementAt(E obj, int index) { modCount++; if (index > elementCount) { throw new ArrayIndexOutOfBoundsException(index + " > " + elementCount); } ensureCapacityHelper(elementCount + 1); System.arraycopy(elementData, index, elementData, index + 1, elementCount - index); elementData[index] = obj; elementCount++; }
// in java-util/Vector.java
public synchronized E get(int index) { if (index >= elementCount) throw new ArrayIndexOutOfBoundsException(index); return (E)elementData[index]; }
// in java-util/Vector.java
public synchronized E set(int index, E element) { if (index >= elementCount) throw new ArrayIndexOutOfBoundsException(index); Object oldValue = elementData[index]; elementData[index] = element; return (E)oldValue; }
// in java-util/Vector.java
public synchronized E remove(int index) { modCount++; if (index >= elementCount) throw new ArrayIndexOutOfBoundsException(index); Object oldValue = elementData[index]; int numMoved = elementCount - index - 1; if (numMoved > 0) System.arraycopy(elementData, index+1, elementData, index, numMoved); elementData[--elementCount] = null; // Let gc do its work return (E)oldValue; }
// in java-util/Vector.java
public synchronized boolean addAll(int index, Collection<? extends E> c) { modCount++; if (index < 0 || index > elementCount) throw new ArrayIndexOutOfBoundsException(index); Object[] a = c.toArray(); int numNew = a.length; ensureCapacityHelper(elementCount + numNew); int numMoved = elementCount - index; if (numMoved > 0) System.arraycopy(elementData, index, elementData, index + numNew, numMoved); System.arraycopy(a, 0, elementData, index, numNew); elementCount += numNew; return numNew != 0; }
// in java-util/Arrays.java
private static void rangeCheck(int arrayLen, int fromIndex, int toIndex) { if (fromIndex > toIndex) throw new IllegalArgumentException("fromIndex(" + fromIndex + ") > toIndex(" + toIndex+")"); if (fromIndex < 0) throw new ArrayIndexOutOfBoundsException(fromIndex); if (toIndex > arrayLen) throw new ArrayIndexOutOfBoundsException(toIndex); }
// in java-util/GregorianCalendar.java
public int getActualMaximum(int field) { final int fieldsForFixedMax = ERA_MASK|DAY_OF_WEEK_MASK|HOUR_MASK|AM_PM_MASK| HOUR_OF_DAY_MASK|MINUTE_MASK|SECOND_MASK|MILLISECOND_MASK| ZONE_OFFSET_MASK|DST_OFFSET_MASK; if ((fieldsForFixedMax & (1<<field)) != 0) { return getMaximum(field); } GregorianCalendar gc = getNormalizedCalendar(); BaseCalendar.Date date = gc.cdate; BaseCalendar cal = gc.calsys; int normalizedYear = date.getNormalizedYear(); int value = -1; switch (field) { case MONTH: { if (!gc.isCutoverYear(normalizedYear)) { value = DECEMBER; break; } // January 1 of the next year may or may not exist. long nextJan1; do { nextJan1 = gcal.getFixedDate(++normalizedYear, BaseCalendar.JANUARY, 1, null); } while (nextJan1 < gregorianCutoverDate); BaseCalendar.Date d = (BaseCalendar.Date) date.clone(); cal.getCalendarDateFromFixedDate(d, nextJan1 - 1); value = d.getMonth() - 1; } break; case DAY_OF_MONTH: { value = cal.getMonthLength(date); if (!gc.isCutoverYear(normalizedYear) || date.getDayOfMonth() == value) { break; } // Handle cutover year. long fd = gc.getCurrentFixedDate(); if (fd >= gregorianCutoverDate) { break; } int monthLength = gc.actualMonthLength(); long monthEnd = gc.getFixedDateMonth1(gc.cdate, fd) + monthLength - 1; // Convert the fixed date to its calendar date. BaseCalendar.Date d = gc.getCalendarDate(monthEnd); value = d.getDayOfMonth(); } break; case DAY_OF_YEAR: { if (!gc.isCutoverYear(normalizedYear)) { value = cal.getYearLength(date); break; } // Handle cutover year. long jan1; if (gregorianCutoverYear == gregorianCutoverYearJulian) { BaseCalendar cocal = gc.getCutoverCalendarSystem(); jan1 = cocal.getFixedDate(normalizedYear, 1, 1, null); } else if (normalizedYear == gregorianCutoverYearJulian) { jan1 = cal.getFixedDate(normalizedYear, 1, 1, null); } else { jan1 = gregorianCutoverDate; } // January 1 of the next year may or may not exist. long nextJan1 = gcal.getFixedDate(++normalizedYear, 1, 1, null); if (nextJan1 < gregorianCutoverDate) { nextJan1 = gregorianCutoverDate; } assert jan1 <= cal.getFixedDate(date.getNormalizedYear(), date.getMonth(), date.getDayOfMonth(), date); assert nextJan1 >= cal.getFixedDate(date.getNormalizedYear(), date.getMonth(), date.getDayOfMonth(), date); value = (int)(nextJan1 - jan1); } break; case WEEK_OF_YEAR: { if (!gc.isCutoverYear(normalizedYear)) { // Get the day of week of January 1 of the year CalendarDate d = cal.newCalendarDate(TimeZone.NO_TIMEZONE); d.setDate(date.getYear(), BaseCalendar.JANUARY, 1); int dayOfWeek = cal.getDayOfWeek(d); // Normalize the day of week with the firstDayOfWeek value dayOfWeek -= getFirstDayOfWeek(); if (dayOfWeek < 0) { dayOfWeek += 7; } value = 52; int magic = dayOfWeek + getMinimalDaysInFirstWeek() - 1; if ((magic == 6) || (date.isLeapYear() && (magic == 5 || magic == 12))) { value++; } break; } if (gc == this) { gc = (GregorianCalendar) gc.clone(); } gc.set(DAY_OF_YEAR, getActualMaximum(DAY_OF_YEAR)); value = gc.get(WEEK_OF_YEAR); } break; case WEEK_OF_MONTH: { if (!gc.isCutoverYear(normalizedYear)) { CalendarDate d = cal.newCalendarDate(null); d.setDate(date.getYear(), date.getMonth(), 1); int dayOfWeek = cal.getDayOfWeek(d); int monthLength = cal.getMonthLength(d); dayOfWeek -= getFirstDayOfWeek(); if (dayOfWeek < 0) { dayOfWeek += 7; } int nDaysFirstWeek = 7 - dayOfWeek; // # of days in the first week value = 3; if (nDaysFirstWeek >= getMinimalDaysInFirstWeek()) { value++; } monthLength -= nDaysFirstWeek + 7 * 3; if (monthLength > 0) { value++; if (monthLength > 7) { value++; } } break; } // Cutover year handling if (gc == this) { gc = (GregorianCalendar) gc.clone(); } int y = gc.internalGet(YEAR); int m = gc.internalGet(MONTH); do { value = gc.get(WEEK_OF_MONTH); gc.add(WEEK_OF_MONTH, +1); } while (gc.get(YEAR) == y && gc.get(MONTH) == m); } break; case DAY_OF_WEEK_IN_MONTH: { // may be in the Gregorian cutover month int ndays, dow1; int dow = date.getDayOfWeek(); if (!gc.isCutoverYear(normalizedYear)) { BaseCalendar.Date d = (BaseCalendar.Date) date.clone(); ndays = cal.getMonthLength(d); d.setDayOfMonth(1); cal.normalize(d); dow1 = d.getDayOfWeek(); } else { // Let a cloned GregorianCalendar take care of the cutover cases. if (gc == this) { gc = (GregorianCalendar) clone(); } ndays = gc.actualMonthLength(); gc.set(DAY_OF_MONTH, gc.getActualMinimum(DAY_OF_MONTH)); dow1 = gc.get(DAY_OF_WEEK); } int x = dow - dow1; if (x < 0) { x += 7; } ndays -= x; value = (ndays + 6) / 7; } break; case YEAR: /* The year computation is no different, in principle, from the * others, however, the range of possible maxima is large. In * addition, the way we know we've exceeded the range is different. * For these reasons, we use the special case code below to handle * this field. * * The actual maxima for YEAR depend on the type of calendar: * * Gregorian = May 17, 292275056 BCE - Aug 17, 292278994 CE * Julian = Dec 2, 292269055 BCE - Jan 3, 292272993 CE * Hybrid = Dec 2, 292269055 BCE - Aug 17, 292278994 CE * * We know we've exceeded the maximum when either the month, date, * time, or era changes in response to setting the year. We don't * check for month, date, and time here because the year and era are * sufficient to detect an invalid year setting. NOTE: If code is * added to check the month and date in the future for some reason, * Feb 29 must be allowed to shift to Mar 1 when setting the year. */ { if (gc == this) { gc = (GregorianCalendar) clone(); } // Calculate the millisecond offset from the beginning // of the year of this calendar and adjust the max // year value if we are beyond the limit in the max // year. long current = gc.getYearOffsetInMillis(); if (gc.internalGetEra() == CE) { gc.setTimeInMillis(Long.MAX_VALUE); value = gc.get(YEAR); long maxEnd = gc.getYearOffsetInMillis(); if (current > maxEnd) { value--; } } else { CalendarSystem mincal = gc.getTimeInMillis() >= gregorianCutover ? gcal : getJulianCalendarSystem(); CalendarDate d = mincal.getCalendarDate(Long.MIN_VALUE, getZone()); long maxEnd = (cal.getDayOfYear(d) - 1) * 24 + d.getHours(); maxEnd *= 60; maxEnd += d.getMinutes(); maxEnd *= 60; maxEnd += d.getSeconds(); maxEnd *= 1000; maxEnd += d.getMillis(); value = d.getYear(); if (value <= 0) { assert mincal == gcal; value = 1 - value; } if (current < maxEnd) { value--; } } } break; default: throw new ArrayIndexOutOfBoundsException(field); } return value; }
0 0
(Domain) InputMismatchException 9
              
// in java-util/Scanner.java
private void throwFor() { skipped = false; if ((sourceClosed) && (position == buf.limit())) throw new NoSuchElementException(); else throw new InputMismatchException(); }
// in java-util/Scanner.java
public byte nextByte(int radix) { // Check cached result if ((typeCache != null) && (typeCache instanceof Byte) && this.radix == radix) { byte val = ((Byte)typeCache).byteValue(); useTypeCache(); return val; } setRadix(radix); clearCaches(); // Search for next byte try { String s = next(integerPattern()); if (matcher.group(SIMPLE_GROUP_INDEX) == null) s = processIntegerToken(s); return Byte.parseByte(s, radix); } catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); } }
// in java-util/Scanner.java
public short nextShort(int radix) { // Check cached result if ((typeCache != null) && (typeCache instanceof Short) && this.radix == radix) { short val = ((Short)typeCache).shortValue(); useTypeCache(); return val; } setRadix(radix); clearCaches(); // Search for next short try { String s = next(integerPattern()); if (matcher.group(SIMPLE_GROUP_INDEX) == null) s = processIntegerToken(s); return Short.parseShort(s, radix); } catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); } }
// in java-util/Scanner.java
public int nextInt(int radix) { // Check cached result if ((typeCache != null) && (typeCache instanceof Integer) && this.radix == radix) { int val = ((Integer)typeCache).intValue(); useTypeCache(); return val; } setRadix(radix); clearCaches(); // Search for next int try { String s = next(integerPattern()); if (matcher.group(SIMPLE_GROUP_INDEX) == null) s = processIntegerToken(s); return Integer.parseInt(s, radix); } catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); } }
// in java-util/Scanner.java
public long nextLong(int radix) { // Check cached result if ((typeCache != null) && (typeCache instanceof Long) && this.radix == radix) { long val = ((Long)typeCache).longValue(); useTypeCache(); return val; } setRadix(radix); clearCaches(); try { String s = next(integerPattern()); if (matcher.group(SIMPLE_GROUP_INDEX) == null) s = processIntegerToken(s); return Long.parseLong(s, radix); } catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); } }
// in java-util/Scanner.java
public float nextFloat() { // Check cached result if ((typeCache != null) && (typeCache instanceof Float)) { float val = ((Float)typeCache).floatValue(); useTypeCache(); return val; } setRadix(10); clearCaches(); try { return Float.parseFloat(processFloatToken(next(floatPattern()))); } catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); } }
// in java-util/Scanner.java
public double nextDouble() { // Check cached result if ((typeCache != null) && (typeCache instanceof Double)) { double val = ((Double)typeCache).doubleValue(); useTypeCache(); return val; } setRadix(10); clearCaches(); // Search for next float try { return Double.parseDouble(processFloatToken(next(floatPattern()))); } catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); } }
// in java-util/Scanner.java
public BigInteger nextBigInteger(int radix) { // Check cached result if ((typeCache != null) && (typeCache instanceof BigInteger) && this.radix == radix) { BigInteger val = (BigInteger)typeCache; useTypeCache(); return val; } setRadix(radix); clearCaches(); // Search for next int try { String s = next(integerPattern()); if (matcher.group(SIMPLE_GROUP_INDEX) == null) s = processIntegerToken(s); return new BigInteger(s, radix); } catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); } }
// in java-util/Scanner.java
public BigDecimal nextBigDecimal() { // Check cached result if ((typeCache != null) && (typeCache instanceof BigDecimal)) { BigDecimal val = (BigDecimal)typeCache; useTypeCache(); return val; } setRadix(10); clearCaches(); // Search for next float try { String s = processFloatToken(next(decimalPattern())); return new BigDecimal(s); } catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); } }
8
              
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
0
(Domain) IllegalFormatPrecisionException 6
              
// in java-util/Formatter.java
private int precision(String s) { precision = -1; if (s != null) { try { // remove the '.' precision = Integer.parseInt(s.substring(1)); if (precision < 0) throw new IllegalFormatPrecisionException(precision); } catch (NumberFormatException x) { assert(false); } } return precision; }
// in java-util/Formatter.java
private void checkDateTime() { if (precision != -1) throw new IllegalFormatPrecisionException(precision); if (!DateTime.isValid(c)) throw new UnknownFormatConversionException("t" + c); checkBadFlags(Flags.ALTERNATE, Flags.PLUS, Flags.LEADING_SPACE, Flags.ZERO_PAD, Flags.GROUP, Flags.PARENTHESES); // '-' requires a width if (width == -1 && f.contains(Flags.LEFT_JUSTIFY)) throw new MissingFormatWidthException(toString()); }
// in java-util/Formatter.java
private void checkCharacter() { if (precision != -1) throw new IllegalFormatPrecisionException(precision); checkBadFlags(Flags.ALTERNATE, Flags.PLUS, Flags.LEADING_SPACE, Flags.ZERO_PAD, Flags.GROUP, Flags.PARENTHESES); // '-' requires a width if (width == -1 && f.contains(Flags.LEFT_JUSTIFY)) throw new MissingFormatWidthException(toString()); }
// in java-util/Formatter.java
private void checkInteger() { checkNumeric(); if (precision != -1) throw new IllegalFormatPrecisionException(precision); if (c == Conversion.DECIMAL_INTEGER) checkBadFlags(Flags.ALTERNATE); else if (c == Conversion.OCTAL_INTEGER) checkBadFlags(Flags.GROUP); else checkBadFlags(Flags.GROUP); }
// in java-util/Formatter.java
private void checkNumeric() { if (width != -1 && width < 0) throw new IllegalFormatWidthException(width); if (precision != -1 && precision < 0) throw new IllegalFormatPrecisionException(precision); // '-' and '0' require a width if (width == -1 && (f.contains(Flags.LEFT_JUSTIFY) || f.contains(Flags.ZERO_PAD))) throw new MissingFormatWidthException(toString()); // bad combination if ((f.contains(Flags.PLUS) && f.contains(Flags.LEADING_SPACE)) || (f.contains(Flags.LEFT_JUSTIFY) && f.contains(Flags.ZERO_PAD))) throw new IllegalFormatFlagsException(f.toString()); }
// in java-util/Formatter.java
private void checkText() { if (precision != -1) throw new IllegalFormatPrecisionException(precision); switch (c) { case Conversion.PERCENT_SIGN: if (f.valueOf() != Flags.LEFT_JUSTIFY.valueOf() && f.valueOf() != Flags.NONE.valueOf()) throw new IllegalFormatFlagsException(f.toString()); // '-' requires a width if (width == -1 && f.contains(Flags.LEFT_JUSTIFY)) throw new MissingFormatWidthException(toString()); break; case Conversion.LINE_SEPARATOR: if (width != -1) throw new IllegalFormatWidthException(width); if (f.valueOf() != Flags.NONE.valueOf()) throw new IllegalFormatFlagsException(f.toString()); break; default: assert false; } }
0 0
(Domain) MissingFormatWidthException 5
              
// in java-util/Formatter.java
private void checkGeneral() { if ((c == Conversion.BOOLEAN || c == Conversion.HASHCODE) && f.contains(Flags.ALTERNATE)) failMismatch(Flags.ALTERNATE, c); // '-' requires a width if (width == -1 && f.contains(Flags.LEFT_JUSTIFY)) throw new MissingFormatWidthException(toString()); checkBadFlags(Flags.PLUS, Flags.LEADING_SPACE, Flags.ZERO_PAD, Flags.GROUP, Flags.PARENTHESES); }
// in java-util/Formatter.java
private void checkDateTime() { if (precision != -1) throw new IllegalFormatPrecisionException(precision); if (!DateTime.isValid(c)) throw new UnknownFormatConversionException("t" + c); checkBadFlags(Flags.ALTERNATE, Flags.PLUS, Flags.LEADING_SPACE, Flags.ZERO_PAD, Flags.GROUP, Flags.PARENTHESES); // '-' requires a width if (width == -1 && f.contains(Flags.LEFT_JUSTIFY)) throw new MissingFormatWidthException(toString()); }
// in java-util/Formatter.java
private void checkCharacter() { if (precision != -1) throw new IllegalFormatPrecisionException(precision); checkBadFlags(Flags.ALTERNATE, Flags.PLUS, Flags.LEADING_SPACE, Flags.ZERO_PAD, Flags.GROUP, Flags.PARENTHESES); // '-' requires a width if (width == -1 && f.contains(Flags.LEFT_JUSTIFY)) throw new MissingFormatWidthException(toString()); }
// in java-util/Formatter.java
private void checkNumeric() { if (width != -1 && width < 0) throw new IllegalFormatWidthException(width); if (precision != -1 && precision < 0) throw new IllegalFormatPrecisionException(precision); // '-' and '0' require a width if (width == -1 && (f.contains(Flags.LEFT_JUSTIFY) || f.contains(Flags.ZERO_PAD))) throw new MissingFormatWidthException(toString()); // bad combination if ((f.contains(Flags.PLUS) && f.contains(Flags.LEADING_SPACE)) || (f.contains(Flags.LEFT_JUSTIFY) && f.contains(Flags.ZERO_PAD))) throw new IllegalFormatFlagsException(f.toString()); }
// in java-util/Formatter.java
private void checkText() { if (precision != -1) throw new IllegalFormatPrecisionException(precision); switch (c) { case Conversion.PERCENT_SIGN: if (f.valueOf() != Flags.LEFT_JUSTIFY.valueOf() && f.valueOf() != Flags.NONE.valueOf()) throw new IllegalFormatFlagsException(f.toString()); // '-' requires a width if (width == -1 && f.contains(Flags.LEFT_JUSTIFY)) throw new MissingFormatWidthException(toString()); break; case Conversion.LINE_SEPARATOR: if (width != -1) throw new IllegalFormatWidthException(width); if (f.valueOf() != Flags.NONE.valueOf()) throw new IllegalFormatFlagsException(f.toString()); break; default: assert false; } }
0 0
(Domain) MissingResourceException 4
              
// in java-util/ResourceBundle.java
public final Object getObject(String key) { Object obj = handleGetObject(key); if (obj == null) { if (parent != null) { obj = parent.getObject(key); } if (obj == null) throw new MissingResourceException("Can't find resource for bundle " +this.getClass().getName() +", key "+key, this.getClass().getName(), key); } return obj; }
// in java-util/ResourceBundle.java
private static final void throwMissingResourceException(String baseName, Locale locale, Throwable cause) { // If the cause is a MissingResourceException, avoid creating // a long chain. (6355009) if (cause instanceof MissingResourceException) { cause = null; } throw new MissingResourceException("Can't find bundle for base name " + baseName + ", locale " + locale, baseName + "_" + locale, // className "", // key cause); }
// in java-util/Locale.java
public String getISO3Language() throws MissingResourceException { String language3 = getISO3Code(language, LocaleISOData.isoLanguageTable); if (language3 == null) { throw new MissingResourceException("Couldn't find 3-letter language code for " + language, "FormatData_" + toString(), "ShortLanguage"); } return language3; }
// in java-util/Locale.java
public String getISO3Country() throws MissingResourceException { String country3 = getISO3Code(country, LocaleISOData.isoCountryTable); if (country3 == null) { throw new MissingResourceException("Couldn't find 3-letter country code for " + country, "FormatData_" + toString(), "ShortCountry"); } return country3; }
0 2
              
// in java-util/Locale.java
public String getISO3Language() throws MissingResourceException { String language3 = getISO3Code(language, LocaleISOData.isoLanguageTable); if (language3 == null) { throw new MissingResourceException("Couldn't find 3-letter language code for " + language, "FormatData_" + toString(), "ShortLanguage"); } return language3; }
// in java-util/Locale.java
public String getISO3Country() throws MissingResourceException { String country3 = getISO3Code(country, LocaleISOData.isoCountryTable); if (country3 == null) { throw new MissingResourceException("Couldn't find 3-letter country code for " + country, "FormatData_" + toString(), "ShortCountry"); } return country3; }
(Domain) UnknownFormatConversionException 4
              
// in java-util/Formatter.java
private void checkText(String s) { int idx; // If there are any '%' in the given string, we got a bad format // specifier. if ((idx = s.indexOf('%')) != -1) { char c = (idx > s.length() - 2 ? '%' : s.charAt(idx + 1)); throw new UnknownFormatConversionException(String.valueOf(c)); } }
// in java-util/Formatter.java
private char conversion(String s) { c = s.charAt(0); if (!dt) { if (!Conversion.isValid(c)) throw new UnknownFormatConversionException(String.valueOf(c)); if (Character.isUpperCase(c)) f.add(Flags.UPPERCASE); c = Character.toLowerCase(c); if (Conversion.isText(c)) index = -2; } return c; }
// in java-util/Formatter.java
private void checkDateTime() { if (precision != -1) throw new IllegalFormatPrecisionException(precision); if (!DateTime.isValid(c)) throw new UnknownFormatConversionException("t" + c); checkBadFlags(Flags.ALTERNATE, Flags.PLUS, Flags.LEADING_SPACE, Flags.ZERO_PAD, Flags.GROUP, Flags.PARENTHESES); // '-' requires a width if (width == -1 && f.contains(Flags.LEFT_JUSTIFY)) throw new MissingFormatWidthException(toString()); }
0 0
(Lib) AssertionError 3
              
// in java-util/ArrayDeque.java
public ArrayDeque<E> clone() { try { ArrayDeque<E> result = (ArrayDeque<E>) super.clone(); result.elements = Arrays.copyOf(elements, elements.length); return result; } catch (CloneNotSupportedException e) { throw new AssertionError(); } }
// in java-util/EnumSet.java
public EnumSet<E> clone() { try { return (EnumSet<E>) super.clone(); } catch(CloneNotSupportedException e) { throw new AssertionError(e); } }
// in java-util/EnumMap.java
public EnumMap<K, V> clone() { EnumMap<K, V> result = null; try { result = (EnumMap<K, V>) super.clone(); } catch(CloneNotSupportedException e) { throw new AssertionError(); } result.vals = (Object[]) result.vals.clone(); return result; }
3
              
// in java-util/ArrayDeque.java
catch (CloneNotSupportedException e) { throw new AssertionError(); }
// in java-util/EnumSet.java
catch(CloneNotSupportedException e) { throw new AssertionError(e); }
// in java-util/EnumMap.java
catch(CloneNotSupportedException e) { throw new AssertionError(); }
0
(Lib) Error 3
              
// in java-util/ServiceLoader.java
public S next() { if (!hasNext()) { throw new NoSuchElementException(); } String cn = nextName; nextName = null; try { S p = service.cast(Class.forName(cn, true, loader) .newInstance()); providers.put(cn, p); return p; } catch (ClassNotFoundException x) { fail(service, "Provider " + cn + " not found"); } catch (Throwable x) { fail(service, "Provider " + cn + " could not be instantiated: " + x, x); } throw new Error(); // This cannot happen }
// in java-util/XMLUtils.java
static Document getLoadingDoc(InputStream in) throws SAXException, IOException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setIgnoringElementContentWhitespace(true); dbf.setValidating(true); dbf.setCoalescing(true); dbf.setIgnoringComments(true); try { DocumentBuilder db = dbf.newDocumentBuilder(); db.setEntityResolver(new Resolver()); db.setErrorHandler(new EH()); InputSource is = new InputSource(in); return db.parse(is); } catch (ParserConfigurationException x) { throw new Error(x); } }
2
              
// in java-util/Random.java
catch (Exception ex) { throw new Error(ex); }
// in java-util/XMLUtils.java
catch (ParserConfigurationException x) { throw new Error(x); }
0
(Domain) IllegalFormatCodePointException 3
              
// in java-util/Formatter.java
private void printCharacter(Object arg) throws IOException { if (arg == null) { print("null"); return; } String s = null; if (arg instanceof Character) { s = ((Character)arg).toString(); } else if (arg instanceof Byte) { byte i = ((Byte)arg).byteValue(); if (Character.isValidCodePoint(i)) s = new String(Character.toChars(i)); else throw new IllegalFormatCodePointException(i); } else if (arg instanceof Short) { short i = ((Short)arg).shortValue(); if (Character.isValidCodePoint(i)) s = new String(Character.toChars(i)); else throw new IllegalFormatCodePointException(i); } else if (arg instanceof Integer) { int i = ((Integer)arg).intValue(); if (Character.isValidCodePoint(i)) s = new String(Character.toChars(i)); else throw new IllegalFormatCodePointException(i); } else { failConversion(c, arg); } print(s); }
0 0
(Domain) IllegalFormatFlagsException 3
              
// in java-util/Formatter.java
private void checkNumeric() { if (width != -1 && width < 0) throw new IllegalFormatWidthException(width); if (precision != -1 && precision < 0) throw new IllegalFormatPrecisionException(precision); // '-' and '0' require a width if (width == -1 && (f.contains(Flags.LEFT_JUSTIFY) || f.contains(Flags.ZERO_PAD))) throw new MissingFormatWidthException(toString()); // bad combination if ((f.contains(Flags.PLUS) && f.contains(Flags.LEADING_SPACE)) || (f.contains(Flags.LEFT_JUSTIFY) && f.contains(Flags.ZERO_PAD))) throw new IllegalFormatFlagsException(f.toString()); }
// in java-util/Formatter.java
private void checkText() { if (precision != -1) throw new IllegalFormatPrecisionException(precision); switch (c) { case Conversion.PERCENT_SIGN: if (f.valueOf() != Flags.LEFT_JUSTIFY.valueOf() && f.valueOf() != Flags.NONE.valueOf()) throw new IllegalFormatFlagsException(f.toString()); // '-' requires a width if (width == -1 && f.contains(Flags.LEFT_JUSTIFY)) throw new MissingFormatWidthException(toString()); break; case Conversion.LINE_SEPARATOR: if (width != -1) throw new IllegalFormatWidthException(width); if (f.valueOf() != Flags.NONE.valueOf()) throw new IllegalFormatFlagsException(f.toString()); break; default: assert false; } }
0 0
(Domain) IllegalFormatWidthException 3
              
// in java-util/Formatter.java
private int width(String s) { width = -1; if (s != null) { try { width = Integer.parseInt(s); if (width < 0) throw new IllegalFormatWidthException(width); } catch (NumberFormatException x) { assert(false); } } return width; }
// in java-util/Formatter.java
private void checkNumeric() { if (width != -1 && width < 0) throw new IllegalFormatWidthException(width); if (precision != -1 && precision < 0) throw new IllegalFormatPrecisionException(precision); // '-' and '0' require a width if (width == -1 && (f.contains(Flags.LEFT_JUSTIFY) || f.contains(Flags.ZERO_PAD))) throw new MissingFormatWidthException(toString()); // bad combination if ((f.contains(Flags.PLUS) && f.contains(Flags.LEADING_SPACE)) || (f.contains(Flags.LEFT_JUSTIFY) && f.contains(Flags.ZERO_PAD))) throw new IllegalFormatFlagsException(f.toString()); }
// in java-util/Formatter.java
private void checkText() { if (precision != -1) throw new IllegalFormatPrecisionException(precision); switch (c) { case Conversion.PERCENT_SIGN: if (f.valueOf() != Flags.LEFT_JUSTIFY.valueOf() && f.valueOf() != Flags.NONE.valueOf()) throw new IllegalFormatFlagsException(f.toString()); // '-' requires a width if (width == -1 && f.contains(Flags.LEFT_JUSTIFY)) throw new MissingFormatWidthException(toString()); break; case Conversion.LINE_SEPARATOR: if (width != -1) throw new IllegalFormatWidthException(width); if (f.valueOf() != Flags.NONE.valueOf()) throw new IllegalFormatFlagsException(f.toString()); break; default: assert false; } }
0 0
(Domain) MissingFormatArgumentException 3
              
// in java-util/Formatter.java
public Formatter format(Locale l, String format, Object ... args) { ensureOpen(); // index of last argument referenced int last = -1; // last ordinary index int lasto = -1; FormatString[] fsa = parse(format); for (int i = 0; i < fsa.length; i++) { FormatString fs = fsa[i]; int index = fs.index(); try { switch (index) { case -2: // fixed string, "%n", or "%%" fs.print(null, l); break; case -1: // relative index if (last < 0 || (args != null && last > args.length - 1)) throw new MissingFormatArgumentException(fs.toString()); fs.print((args == null ? null : args[last]), l); break; case 0: // ordinary index lasto++; last = lasto; if (args != null && lasto > args.length - 1) throw new MissingFormatArgumentException(fs.toString()); fs.print((args == null ? null : args[lasto]), l); break; default: // explicit index last = index - 1; if (args != null && last > args.length - 1) throw new MissingFormatArgumentException(fs.toString()); fs.print((args == null ? null : args[last]), l); break; } } catch (IOException x) { lastException = x; } } return this; }
0 0
(Domain) InvalidPropertiesFormatException 2
              
// in java-util/XMLUtils.java
static void load(Properties props, InputStream in) throws IOException, InvalidPropertiesFormatException { Document doc = null; try { doc = getLoadingDoc(in); } catch (SAXException saxe) { throw new InvalidPropertiesFormatException(saxe); } Element propertiesElement = (Element)doc.getChildNodes().item(1); String xmlVersion = propertiesElement.getAttribute("version"); if (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0) throw new InvalidPropertiesFormatException( "Exported Properties file format version " + xmlVersion + " is not supported. This java installation can read" + " versions " + EXTERNAL_XML_VERSION + " or older. You" + " may need to install a newer version of JDK."); importProperties(props, propertiesElement); }
1
              
// in java-util/XMLUtils.java
catch (SAXException saxe) { throw new InvalidPropertiesFormatException(saxe); }
2
              
// in java-util/Properties.java
public synchronized void loadFromXML(InputStream in) throws IOException, InvalidPropertiesFormatException { if (in == null) throw new NullPointerException(); XMLUtils.load(this, in); in.close(); }
// in java-util/XMLUtils.java
static void load(Properties props, InputStream in) throws IOException, InvalidPropertiesFormatException { Document doc = null; try { doc = getLoadingDoc(in); } catch (SAXException saxe) { throw new InvalidPropertiesFormatException(saxe); } Element propertiesElement = (Element)doc.getChildNodes().item(1); String xmlVersion = propertiesElement.getAttribute("version"); if (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0) throw new InvalidPropertiesFormatException( "Exported Properties file format version " + xmlVersion + " is not supported. This java installation can read" + " versions " + EXTERNAL_XML_VERSION + " or older. You" + " may need to install a newer version of JDK."); importProperties(props, propertiesElement); }
(Lib) NotSerializableException 2
              
// in java-util/InvalidPropertiesFormatException.java
private void writeObject(java.io.ObjectOutputStream out) throws NotSerializableException { throw new NotSerializableException("Not serializable."); }
// in java-util/InvalidPropertiesFormatException.java
private void readObject(java.io.ObjectInputStream in) throws NotSerializableException { throw new NotSerializableException("Not serializable."); }
0 2
              
// in java-util/InvalidPropertiesFormatException.java
private void writeObject(java.io.ObjectOutputStream out) throws NotSerializableException { throw new NotSerializableException("Not serializable."); }
// in java-util/InvalidPropertiesFormatException.java
private void readObject(java.io.ObjectInputStream in) throws NotSerializableException { throw new NotSerializableException("Not serializable."); }
(Lib) OutOfMemoryError 2
              
// in java-util/AbstractCollection.java
private static <T> T[] finishToArray(T[] r, Iterator<?> it) { int i = r.length; while (it.hasNext()) { int cap = r.length; if (i == cap) { int newCap = ((cap / 2) + 1) * 3; if (newCap <= cap) { // integer overflow if (cap == Integer.MAX_VALUE) throw new OutOfMemoryError ("Required array size too large"); newCap = Integer.MAX_VALUE; } r = Arrays.copyOf(r, newCap); } r[i++] = (T)it.next(); } // trim if overallocated return (i == r.length) ? r : Arrays.copyOf(r, i); }
// in java-util/PriorityQueue.java
private void grow(int minCapacity) { if (minCapacity < 0) // overflow throw new OutOfMemoryError(); int oldCapacity = queue.length; // Double size if small; else grow by 50% int newCapacity = ((oldCapacity < 64)? ((oldCapacity + 1) * 2): ((oldCapacity / 2) * 3)); if (newCapacity < 0) // overflow newCapacity = Integer.MAX_VALUE; if (newCapacity < minCapacity) newCapacity = minCapacity; queue = Arrays.copyOf(queue, newCapacity); }
0 0
(Domain) ServiceConfigurationError 2
              
// in java-util/ServiceLoader.java
private static void fail(Class service, String msg, Throwable cause) throws ServiceConfigurationError { throw new ServiceConfigurationError(service.getName() + ": " + msg, cause); }
// in java-util/ServiceLoader.java
private static void fail(Class service, String msg) throws ServiceConfigurationError { throw new ServiceConfigurationError(service.getName() + ": " + msg); }
0 5
              
// in java-util/ServiceLoader.java
private static void fail(Class service, String msg, Throwable cause) throws ServiceConfigurationError { throw new ServiceConfigurationError(service.getName() + ": " + msg, cause); }
// in java-util/ServiceLoader.java
private static void fail(Class service, String msg) throws ServiceConfigurationError { throw new ServiceConfigurationError(service.getName() + ": " + msg); }
// in java-util/ServiceLoader.java
private static void fail(Class service, URL u, int line, String msg) throws ServiceConfigurationError { fail(service, u + ":" + line + ": " + msg); }
// in java-util/ServiceLoader.java
private int parseLine(Class service, URL u, BufferedReader r, int lc, List<String> names) throws IOException, ServiceConfigurationError { String ln = r.readLine(); if (ln == null) { return -1; } int ci = ln.indexOf('#'); if (ci >= 0) ln = ln.substring(0, ci); ln = ln.trim(); int n = ln.length(); if (n != 0) { if ((ln.indexOf(' ') >= 0) || (ln.indexOf('\t') >= 0)) fail(service, u, lc, "Illegal configuration-file syntax"); int cp = ln.codePointAt(0); if (!Character.isJavaIdentifierStart(cp)) fail(service, u, lc, "Illegal provider-class name: " + ln); for (int i = Character.charCount(cp); i < n; i += Character.charCount(cp)) { cp = ln.codePointAt(i); if (!Character.isJavaIdentifierPart(cp) && (cp != '.')) fail(service, u, lc, "Illegal provider-class name: " + ln); } if (!providers.containsKey(ln) && !names.contains(ln)) names.add(ln); } return lc + 1; }
// in java-util/ServiceLoader.java
private Iterator<String> parse(Class service, URL u) throws ServiceConfigurationError { InputStream in = null; BufferedReader r = null; ArrayList<String> names = new ArrayList<String>(); try { in = u.openStream(); r = new BufferedReader(new InputStreamReader(in, "utf-8")); int lc = 1; while ((lc = parseLine(service, u, r, lc, names)) >= 0); } catch (IOException x) { fail(service, "Error reading configuration file", x); } finally { try { if (r != null) r.close(); if (in != null) in.close(); } catch (IOException y) { fail(service, "Error closing configuration file", y); } } return names.iterator(); }
(Domain) DuplicateFormatFlagsException 1
              
// in java-util/Formatter.java
public static Flags parse(String s) { char[] ca = s.toCharArray(); Flags f = new Flags(0); for (int i = 0; i < ca.length; i++) { Flags v = parse(ca[i]); if (f.contains(v)) throw new DuplicateFormatFlagsException(v.toString()); f.add(v); } return f; }
0 0
(Domain) EmptyStackException 1
              
// in java-util/Stack.java
public synchronized E peek() { int len = size(); if (len == 0) throw new EmptyStackException(); return elementAt(len - 1); }
0 0
(Domain) FormatFlagsConversionMismatchException 1
              
// in java-util/Formatter.java
private void failMismatch(Flags f, char c) { String fs = f.toString(); throw new FormatFlagsConversionMismatchException(fs, c); }
0 0
(Domain) FormatterClosedException 1
              
// in java-util/Formatter.java
private void ensureOpen() { if (a == null) throw new FormatterClosedException(); }
0 0
(Domain) IllegalFormatConversionException 1
              
// in java-util/Formatter.java
private void failConversion(char c, Object arg) { throw new IllegalFormatConversionException(c, arg.getClass()); }
0 0
(Lib) NegativeArraySizeException 1 0 0
(Lib) RuntimeException 1
              
// in java-util/Calendar.java
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { final ObjectInputStream input = stream; input.defaultReadObject(); stamp = new int[FIELD_COUNT]; // Starting with version 2 (not implemented yet), we expect that // fields[], isSet[], isTimeSet, and areFieldsSet may not be // streamed out anymore. We expect 'time' to be correct. if (serialVersionOnStream >= 2) { isTimeSet = true; if (fields == null) fields = new int[FIELD_COUNT]; if (isSet == null) isSet = new boolean[FIELD_COUNT]; } else if (serialVersionOnStream >= 0) { for (int i=0; i<FIELD_COUNT; ++i) stamp[i] = isSet[i] ? COMPUTED : UNSET; } serialVersionOnStream = currentSerialVersion; // If there's a ZoneInfo object, use it for zone. ZoneInfo zi = null; try { zi = AccessController.doPrivileged( new PrivilegedExceptionAction<ZoneInfo>() { public ZoneInfo run() throws Exception { return (ZoneInfo) input.readObject(); } }, CalendarAccessControlContext.INSTANCE); } catch (PrivilegedActionException pae) { Exception e = pae.getException(); if (!(e instanceof OptionalDataException)) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } else if (e instanceof IOException) { throw (IOException) e; } else if (e instanceof ClassNotFoundException) { throw (ClassNotFoundException) e; } throw new RuntimeException(e); } } if (zi != null) { zone = zi; } // If the deserialized object has a SimpleTimeZone, try to // replace it with a ZoneInfo equivalent (as of 1.4) in order // to be compatible with the SimpleTimeZone-based // implementation as much as possible. if (zone instanceof SimpleTimeZone) { String id = zone.getID(); TimeZone tz = TimeZone.getTimeZone(id); if (tz != null && tz.hasSameRules(zone) && tz.getID().equals(id)) { zone = tz; } } }
1
              
// in java-util/Calendar.java
catch (PrivilegedActionException pae) { Exception e = pae.getException(); if (!(e instanceof OptionalDataException)) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } else if (e instanceof IOException) { throw (IOException) e; } else if (e instanceof ClassNotFoundException) { throw (ClassNotFoundException) e; } throw new RuntimeException(e); } }
0
(Lib) SAXException 1
              
// in java-util/XMLUtils.java
public InputSource resolveEntity(String pid, String sid) throws SAXException { if (sid.equals(PROPS_DTD_URI)) { InputSource is; is = new InputSource(new StringReader(PROPS_DTD)); is.setSystemId(PROPS_DTD_URI); return is; } throw new SAXException("Invalid system identifier: " + sid); }
0 5
              
// in java-util/XMLUtils.java
static Document getLoadingDoc(InputStream in) throws SAXException, IOException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setIgnoringElementContentWhitespace(true); dbf.setValidating(true); dbf.setCoalescing(true); dbf.setIgnoringComments(true); try { DocumentBuilder db = dbf.newDocumentBuilder(); db.setEntityResolver(new Resolver()); db.setErrorHandler(new EH()); InputSource is = new InputSource(in); return db.parse(is); } catch (ParserConfigurationException x) { throw new Error(x); } }
// in java-util/XMLUtils.java
public InputSource resolveEntity(String pid, String sid) throws SAXException { if (sid.equals(PROPS_DTD_URI)) { InputSource is; is = new InputSource(new StringReader(PROPS_DTD)); is.setSystemId(PROPS_DTD_URI); return is; } throw new SAXException("Invalid system identifier: " + sid); }
// in java-util/XMLUtils.java
public void error(SAXParseException x) throws SAXException { throw x; }
// in java-util/XMLUtils.java
public void fatalError(SAXParseException x) throws SAXException { throw x; }
// in java-util/XMLUtils.java
public void warning(SAXParseException x) throws SAXException { throw x; }
(Lib) SecurityException 1
              
// in java-util/PropertyPermission.java
public void add(Permission permission) { if (! (permission instanceof PropertyPermission)) throw new IllegalArgumentException("invalid permission: "+ permission); if (isReadOnly()) throw new SecurityException( "attempt to add a Permission to a readonly PermissionCollection"); PropertyPermission pp = (PropertyPermission) permission; String propName = pp.getName(); synchronized (this) { PropertyPermission existing = (PropertyPermission) perms.get(propName); if (existing != null) { int oldMask = existing.getMask(); int newMask = pp.getMask(); if (oldMask != newMask) { int effective = oldMask | newMask; String actions = PropertyPermission.getActions(effective); perms.put(propName, new PropertyPermission(propName, actions)); } } else { perms.put(propName, permission); } } if (!all_allowed) { if (propName.equals("*")) all_allowed = true; } }
0 0
(Domain) UnknownFormatFlagsException 1
              
// in java-util/Formatter.java
private static Flags parse(char c) { switch (c) { case '-': return LEFT_JUSTIFY; case '#': return ALTERNATE; case '+': return PLUS; case ' ': return LEADING_SPACE; case '0': return ZERO_PAD; case ',': return GROUP; case '(': return PARENTHESES; case '<': return PREVIOUS; default: throw new UnknownFormatFlagsException(String.valueOf(c)); } }
0 0
Explicit thrown (throw new...): 454/468
Explicit thrown ratio: 97%
Builder thrown ratio: 0.2%
Variable thrown ratio: 2.1%
Checked Runtime Total
Domain 2 125 127
Lib 0 231 231
Total 2 356

Caught Exceptions Summary

A (Domain) exception is defined in the application. A (Lib) exception is defined in the JDK or in a library. An exception can be caught, and it happens that the catch block contains a throw (e.g. for wrapping a low-level exception). Hovering over a number triggers showing code snippets from the application code.

Type Exception Caught
(directly)
Caught
with Thrown
(Lib) NumberFormatException 19
            
// in java-util/Scanner.java
catch (NumberFormatException nfe) { result = false; }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { result = false; }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { result = false; }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { result = false; }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { result = false; }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { result = false; }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { result = false; }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { result = false; }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Formatter.java
catch (NumberFormatException x) { assert(false); }
// in java-util/Formatter.java
catch (NumberFormatException x) { assert(false); }
// in java-util/Formatter.java
catch (NumberFormatException x) { assert(false); }
8
            
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
(Lib) CloneNotSupportedException 18
            
// in java-util/Vector.java
catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); }
// in java-util/ResourceBundle.java
catch (CloneNotSupportedException e) { //this should never happen throw new InternalError(); }
// in java-util/LinkedList.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/TreeMap.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/ArrayDeque.java
catch (CloneNotSupportedException e) { throw new AssertionError(); }
// in java-util/HashSet.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/Date.java
catch (CloneNotSupportedException e) {}
// in java-util/EnumSet.java
catch(CloneNotSupportedException e) { throw new AssertionError(e); }
// in java-util/HashMap.java
catch (CloneNotSupportedException e) { // assert false; }
// in java-util/ArrayList.java
catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); }
// in java-util/TimeZone.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/IdentityHashMap.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/BitSet.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/EnumMap.java
catch(CloneNotSupportedException e) { throw new AssertionError(); }
// in java-util/Hashtable.java
catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); }
// in java-util/Calendar.java
catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); }
// in java-util/Locale.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/TreeSet.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
16
            
// in java-util/Vector.java
catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); }
// in java-util/ResourceBundle.java
catch (CloneNotSupportedException e) { //this should never happen throw new InternalError(); }
// in java-util/LinkedList.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/TreeMap.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/ArrayDeque.java
catch (CloneNotSupportedException e) { throw new AssertionError(); }
// in java-util/HashSet.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/EnumSet.java
catch(CloneNotSupportedException e) { throw new AssertionError(e); }
// in java-util/ArrayList.java
catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); }
// in java-util/TimeZone.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/IdentityHashMap.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/BitSet.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/EnumMap.java
catch(CloneNotSupportedException e) { throw new AssertionError(); }
// in java-util/Hashtable.java
catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); }
// in java-util/Calendar.java
catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); }
// in java-util/Locale.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/TreeSet.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
(Lib) IOException 13
            
// in java-util/TreeMap.java
catch (java.io.IOException cannotHappen) { }
// in java-util/TreeMap.java
catch (java.io.IOException cannotHappen) { }
// in java-util/TreeMap.java
catch (java.io.IOException cannotHappen) { }
// in java-util/TreeMap.java
catch (java.io.IOException cannotHappen) { }
// in java-util/Scanner.java
catch (IOException ioe) { lastException = ioe; n = -1; }
// in java-util/Scanner.java
catch (IOException ioe) { lastException = ioe; }
// in java-util/Properties.java
catch (IOException e) { }
// in java-util/Formatter.java
catch (IOException ioe) { lastException = ioe; }
// in java-util/Formatter.java
catch (IOException ioe) { lastException = ioe; }
// in java-util/Formatter.java
catch (IOException x) { lastException = x; }
// in java-util/ServiceLoader.java
catch (IOException x) { fail(service, "Error reading configuration file", x); }
// in java-util/ServiceLoader.java
catch (IOException y) { fail(service, "Error closing configuration file", y); }
// in java-util/ServiceLoader.java
catch (IOException x) { fail(service, "Error locating configuration files", x); }
0
(Lib) ClassNotFoundException 7
            
// in java-util/ResourceBundle.java
catch (ClassNotFoundException e) { }
// in java-util/TreeMap.java
catch (ClassNotFoundException cannotHappen) { }
// in java-util/TreeMap.java
catch (ClassNotFoundException cannotHappen) { }
// in java-util/TreeMap.java
catch (ClassNotFoundException cannotHappen) { }
// in java-util/TreeMap.java
catch (ClassNotFoundException cannotHappen) { }
// in java-util/Currency.java
catch (ClassNotFoundException e) { throw new InternalError(); }
// in java-util/ServiceLoader.java
catch (ClassNotFoundException x) { fail(service, "Provider " + cn + " not found"); }
1
            
// in java-util/Currency.java
catch (ClassNotFoundException e) { throw new InternalError(); }
(Lib) Exception 6
            
// in java-util/ResourceBundle.java
catch (Exception cause) { cacheKey.setCause(cause); }
// in java-util/ResourceBundle.java
catch (Exception e) { cacheKey.setCause(e); }
// in java-util/ResourceBundle.java
catch (Exception e) { // ignore other exceptions }
// in java-util/Random.java
catch (Exception ex) { throw new Error(ex); }
// in java-util/Calendar.java
catch (Exception e) { // Note: GregorianCalendar.computeTime throws // IllegalArgumentException if the ERA value is invalid // even it's in lenient mode. }
// in java-util/Locale.java
catch (Exception e) { // just fall through }
1
            
// in java-util/Random.java
catch (Exception ex) { throw new Error(ex); }
(Domain) NoSuchElementException 6
            
// in java-util/LinkedList.java
catch (NoSuchElementException e) { throw new IllegalStateException(); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
6
            
// in java-util/LinkedList.java
catch (NoSuchElementException e) { throw new IllegalStateException(); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
(Lib) NullPointerException 6
            
// in java-util/ResourceBundle.java
catch (NullPointerException e) { }
// in java-util/ResourceBundle.java
catch (NullPointerException npe) { throw npe; }
// in java-util/TimeZone.java
catch (NullPointerException e) { zoneID = GMT_ID; }
// in java-util/AbstractSet.java
catch (NullPointerException unused) { return false; }
// in java-util/AbstractMap.java
catch (NullPointerException unused) { return false; }
// in java-util/Hashtable.java
catch (NullPointerException unused) { return false; }
1
            
// in java-util/ResourceBundle.java
catch (NullPointerException npe) { throw npe; }
(Lib) IndexOutOfBoundsException 5
            
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException e) { checkForComodification(); throw new NoSuchElementException(); }
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException e) { throw new ConcurrentModificationException(); }
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException e) { checkForComodification(); throw new NoSuchElementException(); }
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException ex) { throw new ConcurrentModificationException(); }
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException ex) { throw new ConcurrentModificationException(); }
5
            
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException e) { checkForComodification(); throw new NoSuchElementException(); }
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException e) { throw new ConcurrentModificationException(); }
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException e) { checkForComodification(); throw new NoSuchElementException(); }
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException ex) { throw new ConcurrentModificationException(); }
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException ex) { throw new ConcurrentModificationException(); }
(Lib) ArrayStoreException 4
            
// in java-util/Collections.java
catch (ArrayStoreException e) { throw new ClassCastException(); }
// in java-util/Collections.java
catch (ArrayStoreException e) { throw new ClassCastException(); }
// in java-util/Collections.java
catch (ArrayStoreException e) { throw new ClassCastException(); }
// in java-util/Collections.java
catch (ArrayStoreException e) { throw new ClassCastException(); }
4
            
// in java-util/Collections.java
catch (ArrayStoreException e) { throw new ClassCastException(); }
// in java-util/Collections.java
catch (ArrayStoreException e) { throw new ClassCastException(); }
// in java-util/Collections.java
catch (ArrayStoreException e) { throw new ClassCastException(); }
// in java-util/Collections.java
catch (ArrayStoreException e) { throw new ClassCastException(); }
(Lib) ClassCastException 4
            
// in java-util/ResourceBundle.java
catch (ClassCastException e) { }
// in java-util/AbstractSet.java
catch (ClassCastException unused) { return false; }
// in java-util/AbstractMap.java
catch (ClassCastException unused) { return false; }
// in java-util/Hashtable.java
catch (ClassCastException unused) { return false; }
0
(Domain) MissingResourceException 3
            
// in java-util/Currency.java
catch (MissingResourceException e) { // use currency code as symbol of last resort return currencyCode; }
// in java-util/Locale.java
catch (MissingResourceException e) { }
// in java-util/Locale.java
catch (MissingResourceException e) { }
0
(Lib) ParserConfigurationException 2
            
// in java-util/XMLUtils.java
catch (ParserConfigurationException x) { throw new Error(x); }
// in java-util/XMLUtils.java
catch (ParserConfigurationException pce) { assert(false); }
1
            
// in java-util/XMLUtils.java
catch (ParserConfigurationException x) { throw new Error(x); }
(Lib) PrivilegedActionException 2
            
// in java-util/ResourceBundle.java
catch (PrivilegedActionException e) { throw (IOException) e.getException(); }
// in java-util/Calendar.java
catch (PrivilegedActionException pae) { Exception e = pae.getException(); if (!(e instanceof OptionalDataException)) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } else if (e instanceof IOException) { throw (IOException) e; } else if (e instanceof ClassNotFoundException) { throw (ClassNotFoundException) e; } throw new RuntimeException(e); } }
5
            
// in java-util/ResourceBundle.java
catch (PrivilegedActionException e) { throw (IOException) e.getException(); }
// in java-util/Calendar.java
catch (PrivilegedActionException pae) { Exception e = pae.getException(); if (!(e instanceof OptionalDataException)) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } else if (e instanceof IOException) { throw (IOException) e; } else if (e instanceof ClassNotFoundException) { throw (ClassNotFoundException) e; } throw new RuntimeException(e); } }
(Lib) IllegalAccessException 1
            
// in java-util/Currency.java
catch (IllegalAccessException e) { throw new InternalError(); }
1
            
// in java-util/Currency.java
catch (IllegalAccessException e) { throw new InternalError(); }
(Lib) IllegalArgumentException 1
            
// in java-util/Calendar.java
catch (IllegalArgumentException e) {}
0
(Lib) InterruptedException 1
            
// in java-util/Timer.java
catch(InterruptedException e) { }
0
(Lib) LinkageError 1
            
// in java-util/ResourceBundle.java
catch (LinkageError error) { // We need to handle the LinkageError case due to // inconsistent case-sensitivity in ClassLoader. // See 6572242 for details. cacheKey.setCause(error); }
0
(Lib) NoSuchAlgorithmException 1
            
// in java-util/UUID.java
catch (NoSuchAlgorithmException nsae) { throw new InternalError("MD5 not supported"); }
1
            
// in java-util/UUID.java
catch (NoSuchAlgorithmException nsae) { throw new InternalError("MD5 not supported"); }
(Lib) NoSuchFieldException 1
            
// in java-util/Currency.java
catch (NoSuchFieldException e) { throw new InternalError(); }
1
            
// in java-util/Currency.java
catch (NoSuchFieldException e) { throw new InternalError(); }
(Lib) SAXException 1
            
// in java-util/XMLUtils.java
catch (SAXException saxe) { throw new InvalidPropertiesFormatException(saxe); }
1
            
// in java-util/XMLUtils.java
catch (SAXException saxe) { throw new InvalidPropertiesFormatException(saxe); }
(Lib) SecurityException 1
            
// in java-util/TimeZone.java
catch (SecurityException e) { hasPermission = false; }
0
(Lib) Throwable 1
            
// in java-util/ServiceLoader.java
catch (Throwable x) { fail(service, "Provider " + cn + " could not be instantiated: " + x, x); }
0
(Lib) TransformerConfigurationException 1
            
// in java-util/XMLUtils.java
catch (TransformerConfigurationException tce) { assert(false); }
0
(Lib) TransformerException 1
            
// in java-util/XMLUtils.java
catch (TransformerException te) { IOException ioe = new IOException(); ioe.initCause(te); throw ioe; }
1
            
// in java-util/XMLUtils.java
catch (TransformerException te) { IOException ioe = new IOException(); ioe.initCause(te); throw ioe; }
(Lib) UnsupportedEncodingException 1
            
// in java-util/Scanner.java
catch (UnsupportedEncodingException uee) { IllegalArgumentException iae = new IllegalArgumentException(); iae.initCause(uee); throw iae; }
1
            
// in java-util/Scanner.java
catch (UnsupportedEncodingException uee) { IllegalArgumentException iae = new IllegalArgumentException(); iae.initCause(uee); throw iae; }

Exception Recast Summary

There is a common practice of throwing exceptions from within a catch block (e.g. for wrapping a low-level exception). The following table summarizes the usage of this practice in the application. The last column gives the number of times it happens for a pair of exceptions. The graph below the table graphically renders the same information. For a given node, its color represents its origin (blue means library exception, orange means domain exception); the left-most number is the number of times it is thrown, the right-most is the number of times it is caught.

Catch Throw
(Domain) NoSuchElementException
(Lib) IllegalStateException
(Lib) IndexOutOfBoundsException
1
                    
// in java-util/LinkedList.java
catch (NoSuchElementException e) { throw new IllegalStateException(); }
5
                    
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
(Lib) IndexOutOfBoundsException
(Domain) NoSuchElementException
(Domain) ConcurrentModificationException
2
                    
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException e) { checkForComodification(); throw new NoSuchElementException(); }
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException e) { checkForComodification(); throw new NoSuchElementException(); }
3
                    
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException e) { throw new ConcurrentModificationException(); }
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException ex) { throw new ConcurrentModificationException(); }
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException ex) { throw new ConcurrentModificationException(); }
(Lib) CloneNotSupportedException
(Lib) InternalError
(Lib) AssertionError
13
                    
// in java-util/Vector.java
catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); }
// in java-util/ResourceBundle.java
catch (CloneNotSupportedException e) { //this should never happen throw new InternalError(); }
// in java-util/LinkedList.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/TreeMap.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/HashSet.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/ArrayList.java
catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); }
// in java-util/TimeZone.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/IdentityHashMap.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/BitSet.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/Hashtable.java
catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); }
// in java-util/Calendar.java
catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); }
// in java-util/Locale.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/TreeSet.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
3
                    
// in java-util/ArrayDeque.java
catch (CloneNotSupportedException e) { throw new AssertionError(); }
// in java-util/EnumSet.java
catch(CloneNotSupportedException e) { throw new AssertionError(e); }
// in java-util/EnumMap.java
catch(CloneNotSupportedException e) { throw new AssertionError(); }
(Lib) NullPointerException
Unknown
1
                    
// in java-util/ResourceBundle.java
catch (NullPointerException npe) { throw npe; }
(Lib) NoSuchAlgorithmException
(Lib) InternalError
1
                    
// in java-util/UUID.java
catch (NoSuchAlgorithmException nsae) { throw new InternalError("MD5 not supported"); }
(Lib) Exception
(Lib) Error
1
                    
// in java-util/Random.java
catch (Exception ex) { throw new Error(ex); }
(Lib) ClassNotFoundException
(Lib) InternalError
1
                    
// in java-util/Currency.java
catch (ClassNotFoundException e) { throw new InternalError(); }
(Lib) PrivilegedActionException
(Lib) RuntimeException
Unknown
1
                    
// in java-util/Calendar.java
catch (PrivilegedActionException pae) { Exception e = pae.getException(); if (!(e instanceof OptionalDataException)) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } else if (e instanceof IOException) { throw (IOException) e; } else if (e instanceof ClassNotFoundException) { throw (ClassNotFoundException) e; } throw new RuntimeException(e); } }
4
                    
// in java-util/ResourceBundle.java
catch (PrivilegedActionException e) { throw (IOException) e.getException(); }
// in java-util/Calendar.java
catch (PrivilegedActionException pae) { Exception e = pae.getException(); if (!(e instanceof OptionalDataException)) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } else if (e instanceof IOException) { throw (IOException) e; } else if (e instanceof ClassNotFoundException) { throw (ClassNotFoundException) e; } throw new RuntimeException(e); } }
(Lib) NoSuchFieldException
(Lib) InternalError
1
                    
// in java-util/Currency.java
catch (NoSuchFieldException e) { throw new InternalError(); }
(Lib) IllegalAccessException
(Lib) InternalError
1
                    
// in java-util/Currency.java
catch (IllegalAccessException e) { throw new InternalError(); }
(Lib) UnsupportedEncodingException
Unknown
1
                    
// in java-util/Scanner.java
catch (UnsupportedEncodingException uee) { IllegalArgumentException iae = new IllegalArgumentException(); iae.initCause(uee); throw iae; }
(Lib) NumberFormatException
(Domain) InputMismatchException
8
                    
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
(Lib) SAXException
(Domain) InvalidPropertiesFormatException
1
                    
// in java-util/XMLUtils.java
catch (SAXException saxe) { throw new InvalidPropertiesFormatException(saxe); }
(Lib) ParserConfigurationException
(Lib) Error
1
                    
// in java-util/XMLUtils.java
catch (ParserConfigurationException x) { throw new Error(x); }
(Lib) TransformerException
Unknown
1
                    
// in java-util/XMLUtils.java
catch (TransformerException te) { IOException ioe = new IOException(); ioe.initCause(te); throw ioe; }
(Lib) ArrayStoreException
(Lib) ClassCastException
4
                    
// in java-util/Collections.java
catch (ArrayStoreException e) { throw new ClassCastException(); }
// in java-util/Collections.java
catch (ArrayStoreException e) { throw new ClassCastException(); }
// in java-util/Collections.java
catch (ArrayStoreException e) { throw new ClassCastException(); }
// in java-util/Collections.java
catch (ArrayStoreException e) { throw new ClassCastException(); }

Caught / Thrown Exception

Not all exceptions are thrown AND caught in the same project. The following table gives the exceptions types with respect to this. The lower left hand side sell lists all exceptions thrown but not caught (prevalent for libraries), the upper right-hand side lists all exceptions caught but not thrown (usually coming from external dependencies).

Thrown Not Thrown
Caught
Type Name
(Lib) IllegalArgumentException
(Domain) NoSuchElementException
(Lib) IndexOutOfBoundsException
(Lib) NullPointerException
(Domain) MissingResourceException
(Lib) ClassCastException
(Lib) SecurityException
(Lib) SAXException
Type Name
(Lib) CloneNotSupportedException
(Lib) NoSuchAlgorithmException
(Lib) LinkageError
(Lib) Exception
(Lib) ClassNotFoundException
(Lib) PrivilegedActionException
(Lib) IOException
(Lib) NoSuchFieldException
(Lib) IllegalAccessException
(Lib) UnsupportedEncodingException
(Lib) NumberFormatException
(Lib) InterruptedException
(Lib) Throwable
(Lib) ParserConfigurationException
(Lib) TransformerConfigurationException
(Lib) TransformerException
(Lib) ArrayStoreException
Not caught
Type Name
(Lib) ArrayIndexOutOfBoundsException
(Lib) InternalError
(Domain) EmptyStackException
(Lib) UnsupportedOperationException
(Lib) IllegalStateException
(Domain) ConcurrentModificationException
(Lib) AssertionError
(Domain) InputMismatchException
(Lib) StreamCorruptedException
(Lib) Error
(Lib) OutOfMemoryError
(Domain) FormatterClosedException
(Domain) MissingFormatArgumentException
(Domain) UnknownFormatConversionException
(Domain) IllegalFormatWidthException
(Domain) IllegalFormatPrecisionException
(Domain) IllegalFormatCodePointException
(Domain) MissingFormatWidthException
(Domain) IllegalFormatFlagsException
(Domain) FormatFlagsConversionMismatchException
(Domain) IllegalFormatConversionException
(Domain) DuplicateFormatFlagsException
(Domain) UnknownFormatFlagsException
(Domain) ServiceConfigurationError
(Lib) NotSerializableException
(Lib) NegativeArraySizeException
(Domain) InvalidPropertiesFormatException
(Lib) RuntimeException

Methods called in Catch and Finally Blocks

The following shows the methods that are called inside catch blocks (first column) and finally blocks (second column). For each method, we give the number of times it is called in a catch block (second sub-column), and the total number of calls (third sub-column). If the method name is red, it means that it is only called from catch/finally blocks. Hovering over a number triggers showing code snippets from the application code.

Catch Finally
Method Nbr Nbr total
getMessage
8
                  
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
8
start 8
                  
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
15
assert 5
                  
// in java-util/Formatter.java
catch (NumberFormatException x) { assert(false); }
// in java-util/Formatter.java
catch (NumberFormatException x) { assert(false); }
// in java-util/Formatter.java
catch (NumberFormatException x) { assert(false); }
// in java-util/XMLUtils.java
catch (ParserConfigurationException pce) { assert(false); }
// in java-util/XMLUtils.java
catch (TransformerConfigurationException tce) { assert(false); }
21
fail 5
                  
// in java-util/ServiceLoader.java
catch (IOException x) { fail(service, "Error reading configuration file", x); }
// in java-util/ServiceLoader.java
catch (IOException y) { fail(service, "Error closing configuration file", y); }
// in java-util/ServiceLoader.java
catch (IOException x) { fail(service, "Error locating configuration files", x); }
// in java-util/ServiceLoader.java
catch (ClassNotFoundException x) { fail(service, "Provider " + cn + " not found"); }
// in java-util/ServiceLoader.java
catch (Throwable x) { fail(service, "Provider " + cn + " could not be instantiated: " + x, x); }
9
setCause
3
                  
// in java-util/ResourceBundle.java
catch (LinkageError error) { // We need to handle the LinkageError case due to // inconsistent case-sensitivity in ClassLoader. // See 6572242 for details. cacheKey.setCause(error); }
// in java-util/ResourceBundle.java
catch (Exception cause) { cacheKey.setCause(cause); }
// in java-util/ResourceBundle.java
catch (Exception e) { cacheKey.setCause(e); }
3
checkForComodification 2
                  
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException e) { checkForComodification(); throw new NoSuchElementException(); }
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException e) { checkForComodification(); throw new NoSuchElementException(); }
20
getException
2
                  
// in java-util/ResourceBundle.java
catch (PrivilegedActionException e) { throw (IOException) e.getException(); }
// in java-util/Calendar.java
catch (PrivilegedActionException pae) { Exception e = pae.getException(); if (!(e instanceof OptionalDataException)) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } else if (e instanceof IOException) { throw (IOException) e; } else if (e instanceof ClassNotFoundException) { throw (ClassNotFoundException) e; } throw new RuntimeException(e); } }
2
initCause 2
                  
// in java-util/Scanner.java
catch (UnsupportedEncodingException uee) { IllegalArgumentException iae = new IllegalArgumentException(); iae.initCause(uee); throw iae; }
// in java-util/XMLUtils.java
catch (TransformerException te) { IOException ioe = new IOException(); ioe.initCause(te); throw ioe; }
3
Method Nbr Nbr total
close 3
                  
// in java-util/ResourceBundle.java
finally { stream.close(); }
// in java-util/ServiceLoader.java
finally { try { if (r != null) r.close(); if (in != null) in.close(); } catch (IOException y) { fail(service, "Error closing configuration file", y); } }
6
clear 1
                  
// in java-util/Timer.java
finally { // Someone killed this Thread, behave as if Timer cancelled synchronized(queue) { newTasksMayBeScheduled = false; queue.clear(); // Eliminate obsolete references } }
39
currentThread 1
                  
// in java-util/ResourceBundle.java
finally { if (constKey.getCause() instanceof InterruptedException) { Thread.currentThread().interrupt(); } }
2
fail 1
                  
// in java-util/ServiceLoader.java
finally { try { if (r != null) r.close(); if (in != null) in.close(); } catch (IOException y) { fail(service, "Error closing configuration file", y); } }
9
getCause 1
                  
// in java-util/ResourceBundle.java
finally { if (constKey.getCause() instanceof InterruptedException) { Thread.currentThread().interrupt(); } }
2
interrupt
1
                  
// in java-util/ResourceBundle.java
finally { if (constKey.getCause() instanceof InterruptedException) { Thread.currentThread().interrupt(); } }
1

Reference Table

This table concatenates the results of the previous tables.

Checked/Runtime Type Exception Thrown Thrown from Catch Declared Caught directly Caught
with Thrown
Caught
with Thrown Runtime
unknown (Lib) . 0 0 0 0 0 0
unknown (Lib) ArrayIndexOutOfBoundsException 13
            
// in java-util/JapaneseImperialCalendar.java
public int getActualMaximum(int field) { final int fieldsForFixedMax = ERA_MASK|DAY_OF_WEEK_MASK|HOUR_MASK|AM_PM_MASK| HOUR_OF_DAY_MASK|MINUTE_MASK|SECOND_MASK|MILLISECOND_MASK| ZONE_OFFSET_MASK|DST_OFFSET_MASK; if ((fieldsForFixedMax & (1<<field)) != 0) { return getMaximum(field); } JapaneseImperialCalendar jc = getNormalizedCalendar(); LocalGregorianCalendar.Date date = jc.jdate; int normalizedYear = date.getNormalizedYear(); int value = -1; switch (field) { case MONTH: { value = DECEMBER; if (isTransitionYear(date.getNormalizedYear())) { // TODO: there may be multiple transitions in a year. int eraIndex = getEraIndex(date); if (date.getYear() != 1) { eraIndex++; assert eraIndex < eras.length; } long transition = sinceFixedDates[eraIndex]; long fd = jc.cachedFixedDate; if (fd < transition) { LocalGregorianCalendar.Date ldate = (LocalGregorianCalendar.Date) date.clone(); jcal.getCalendarDateFromFixedDate(ldate, transition - 1); value = ldate.getMonth() - 1; } } else { LocalGregorianCalendar.Date d = jcal.getCalendarDate(Long.MAX_VALUE, getZone()); if (date.getEra() == d.getEra() && date.getYear() == d.getYear()) { value = d.getMonth() - 1; } } } break; case DAY_OF_MONTH: value = jcal.getMonthLength(date); break; case DAY_OF_YEAR: { if (isTransitionYear(date.getNormalizedYear())) { // Handle transition year. // TODO: there may be multiple transitions in a year. int eraIndex = getEraIndex(date); if (date.getYear() != 1) { eraIndex++; assert eraIndex < eras.length; } long transition = sinceFixedDates[eraIndex]; long fd = jc.cachedFixedDate; CalendarDate d = gcal.newCalendarDate(TimeZone.NO_TIMEZONE); d.setDate(date.getNormalizedYear(), BaseCalendar.JANUARY, 1); if (fd < transition) { value = (int)(transition - gcal.getFixedDate(d)); } else { d.addYear(+1); value = (int)(gcal.getFixedDate(d) - transition); } } else { LocalGregorianCalendar.Date d = jcal.getCalendarDate(Long.MAX_VALUE, getZone()); if (date.getEra() == d.getEra() && date.getYear() == d.getYear()) { long fd = jcal.getFixedDate(d); long jan1 = getFixedDateJan1(d, fd); value = (int)(fd - jan1) + 1; } else if (date.getYear() == getMinimum(YEAR)) { CalendarDate d1 = jcal.getCalendarDate(Long.MIN_VALUE, getZone()); long fd1 = jcal.getFixedDate(d1); d1.addYear(1); d1.setMonth(BaseCalendar.JANUARY).setDayOfMonth(1); jcal.normalize(d1); long fd2 = jcal.getFixedDate(d1); value = (int)(fd2 - fd1); } else { value = jcal.getYearLength(date); } } } break; case WEEK_OF_YEAR: { if (!isTransitionYear(date.getNormalizedYear())) { LocalGregorianCalendar.Date jd = jcal.getCalendarDate(Long.MAX_VALUE, getZone()); if (date.getEra() == jd.getEra() && date.getYear() == jd.getYear()) { long fd = jcal.getFixedDate(jd); long jan1 = getFixedDateJan1(jd, fd); value = getWeekNumber(jan1, fd); } else if (date.getEra() == null && date.getYear() == getMinimum(YEAR)) { CalendarDate d = jcal.getCalendarDate(Long.MIN_VALUE, getZone()); // shift 400 years to avoid underflow d.addYear(+400); jcal.normalize(d); jd.setEra(d.getEra()); jd.setDate(d.getYear() + 1, BaseCalendar.JANUARY, 1); jcal.normalize(jd); long jan1 = jcal.getFixedDate(d); long nextJan1 = jcal.getFixedDate(jd); long nextJan1st = jcal.getDayOfWeekDateOnOrBefore(nextJan1 + 6, getFirstDayOfWeek()); int ndays = (int)(nextJan1st - nextJan1); if (ndays >= getMinimalDaysInFirstWeek()) { nextJan1st -= 7; } value = getWeekNumber(jan1, nextJan1st); } else { // Get the day of week of January 1 of the year CalendarDate d = gcal.newCalendarDate(TimeZone.NO_TIMEZONE); d.setDate(date.getNormalizedYear(), BaseCalendar.JANUARY, 1); int dayOfWeek = gcal.getDayOfWeek(d); // Normalize the day of week with the firstDayOfWeek value dayOfWeek -= getFirstDayOfWeek(); if (dayOfWeek < 0) { dayOfWeek += 7; } value = 52; int magic = dayOfWeek + getMinimalDaysInFirstWeek() - 1; if ((magic == 6) || (date.isLeapYear() && (magic == 5 || magic == 12))) { value++; } } break; } if (jc == this) { jc = (JapaneseImperialCalendar) jc.clone(); } int max = getActualMaximum(DAY_OF_YEAR); jc.set(DAY_OF_YEAR, max); value = jc.get(WEEK_OF_YEAR); if (value == 1 && max > 7) { jc.add(WEEK_OF_YEAR, -1); value = jc.get(WEEK_OF_YEAR); } } break; case WEEK_OF_MONTH: { LocalGregorianCalendar.Date jd = jcal.getCalendarDate(Long.MAX_VALUE, getZone()); if (!(date.getEra() == jd.getEra() && date.getYear() == jd.getYear())) { CalendarDate d = gcal.newCalendarDate(TimeZone.NO_TIMEZONE); d.setDate(date.getNormalizedYear(), date.getMonth(), 1); int dayOfWeek = gcal.getDayOfWeek(d); int monthLength = gcal.getMonthLength(d); dayOfWeek -= getFirstDayOfWeek(); if (dayOfWeek < 0) { dayOfWeek += 7; } int nDaysFirstWeek = 7 - dayOfWeek; // # of days in the first week value = 3; if (nDaysFirstWeek >= getMinimalDaysInFirstWeek()) { value++; } monthLength -= nDaysFirstWeek + 7 * 3; if (monthLength > 0) { value++; if (monthLength > 7) { value++; } } } else { long fd = jcal.getFixedDate(jd); long month1 = fd - jd.getDayOfMonth() + 1; value = getWeekNumber(month1, fd); } } break; case DAY_OF_WEEK_IN_MONTH: { int ndays, dow1; int dow = date.getDayOfWeek(); BaseCalendar.Date d = (BaseCalendar.Date) date.clone(); ndays = jcal.getMonthLength(d); d.setDayOfMonth(1); jcal.normalize(d); dow1 = d.getDayOfWeek(); int x = dow - dow1; if (x < 0) { x += 7; } ndays -= x; value = (ndays + 6) / 7; } break; case YEAR: { CalendarDate jd = jcal.getCalendarDate(jc.getTimeInMillis(), getZone()); CalendarDate d; int eraIndex = getEraIndex(date); if (eraIndex == eras.length - 1) { d = jcal.getCalendarDate(Long.MAX_VALUE, getZone()); value = d.getYear(); // Use an equivalent year for the // getYearOffsetInMillis call to avoid overflow. if (value > 400) { jd.setYear(value - 400); } } else { d = jcal.getCalendarDate(eras[eraIndex + 1].getSince(getZone()) - 1, getZone()); value = d.getYear(); // Use the same year as d.getYear() to be // consistent with leap and common years. jd.setYear(value); } jcal.normalize(jd); if (getYearOffsetInMillis(jd) > getYearOffsetInMillis(d)) { value--; } } break; default: throw new ArrayIndexOutOfBoundsException(field); } return value; }
// in java-util/Vector.java
public synchronized E elementAt(int index) { if (index >= elementCount) { throw new ArrayIndexOutOfBoundsException(index + " >= " + elementCount); } return (E)elementData[index]; }
// in java-util/Vector.java
public synchronized void setElementAt(E obj, int index) { if (index >= elementCount) { throw new ArrayIndexOutOfBoundsException(index + " >= " + elementCount); } elementData[index] = obj; }
// in java-util/Vector.java
public synchronized void removeElementAt(int index) { modCount++; if (index >= elementCount) { throw new ArrayIndexOutOfBoundsException(index + " >= " + elementCount); } else if (index < 0) { throw new ArrayIndexOutOfBoundsException(index); } int j = elementCount - index - 1; if (j > 0) { System.arraycopy(elementData, index + 1, elementData, index, j); } elementCount--; elementData[elementCount] = null; /* to let gc do its work */ }
// in java-util/Vector.java
public synchronized void insertElementAt(E obj, int index) { modCount++; if (index > elementCount) { throw new ArrayIndexOutOfBoundsException(index + " > " + elementCount); } ensureCapacityHelper(elementCount + 1); System.arraycopy(elementData, index, elementData, index + 1, elementCount - index); elementData[index] = obj; elementCount++; }
// in java-util/Vector.java
public synchronized E get(int index) { if (index >= elementCount) throw new ArrayIndexOutOfBoundsException(index); return (E)elementData[index]; }
// in java-util/Vector.java
public synchronized E set(int index, E element) { if (index >= elementCount) throw new ArrayIndexOutOfBoundsException(index); Object oldValue = elementData[index]; elementData[index] = element; return (E)oldValue; }
// in java-util/Vector.java
public synchronized E remove(int index) { modCount++; if (index >= elementCount) throw new ArrayIndexOutOfBoundsException(index); Object oldValue = elementData[index]; int numMoved = elementCount - index - 1; if (numMoved > 0) System.arraycopy(elementData, index+1, elementData, index, numMoved); elementData[--elementCount] = null; // Let gc do its work return (E)oldValue; }
// in java-util/Vector.java
public synchronized boolean addAll(int index, Collection<? extends E> c) { modCount++; if (index < 0 || index > elementCount) throw new ArrayIndexOutOfBoundsException(index); Object[] a = c.toArray(); int numNew = a.length; ensureCapacityHelper(elementCount + numNew); int numMoved = elementCount - index; if (numMoved > 0) System.arraycopy(elementData, index, elementData, index + numNew, numMoved); System.arraycopy(a, 0, elementData, index, numNew); elementCount += numNew; return numNew != 0; }
// in java-util/Arrays.java
private static void rangeCheck(int arrayLen, int fromIndex, int toIndex) { if (fromIndex > toIndex) throw new IllegalArgumentException("fromIndex(" + fromIndex + ") > toIndex(" + toIndex+")"); if (fromIndex < 0) throw new ArrayIndexOutOfBoundsException(fromIndex); if (toIndex > arrayLen) throw new ArrayIndexOutOfBoundsException(toIndex); }
// in java-util/GregorianCalendar.java
public int getActualMaximum(int field) { final int fieldsForFixedMax = ERA_MASK|DAY_OF_WEEK_MASK|HOUR_MASK|AM_PM_MASK| HOUR_OF_DAY_MASK|MINUTE_MASK|SECOND_MASK|MILLISECOND_MASK| ZONE_OFFSET_MASK|DST_OFFSET_MASK; if ((fieldsForFixedMax & (1<<field)) != 0) { return getMaximum(field); } GregorianCalendar gc = getNormalizedCalendar(); BaseCalendar.Date date = gc.cdate; BaseCalendar cal = gc.calsys; int normalizedYear = date.getNormalizedYear(); int value = -1; switch (field) { case MONTH: { if (!gc.isCutoverYear(normalizedYear)) { value = DECEMBER; break; } // January 1 of the next year may or may not exist. long nextJan1; do { nextJan1 = gcal.getFixedDate(++normalizedYear, BaseCalendar.JANUARY, 1, null); } while (nextJan1 < gregorianCutoverDate); BaseCalendar.Date d = (BaseCalendar.Date) date.clone(); cal.getCalendarDateFromFixedDate(d, nextJan1 - 1); value = d.getMonth() - 1; } break; case DAY_OF_MONTH: { value = cal.getMonthLength(date); if (!gc.isCutoverYear(normalizedYear) || date.getDayOfMonth() == value) { break; } // Handle cutover year. long fd = gc.getCurrentFixedDate(); if (fd >= gregorianCutoverDate) { break; } int monthLength = gc.actualMonthLength(); long monthEnd = gc.getFixedDateMonth1(gc.cdate, fd) + monthLength - 1; // Convert the fixed date to its calendar date. BaseCalendar.Date d = gc.getCalendarDate(monthEnd); value = d.getDayOfMonth(); } break; case DAY_OF_YEAR: { if (!gc.isCutoverYear(normalizedYear)) { value = cal.getYearLength(date); break; } // Handle cutover year. long jan1; if (gregorianCutoverYear == gregorianCutoverYearJulian) { BaseCalendar cocal = gc.getCutoverCalendarSystem(); jan1 = cocal.getFixedDate(normalizedYear, 1, 1, null); } else if (normalizedYear == gregorianCutoverYearJulian) { jan1 = cal.getFixedDate(normalizedYear, 1, 1, null); } else { jan1 = gregorianCutoverDate; } // January 1 of the next year may or may not exist. long nextJan1 = gcal.getFixedDate(++normalizedYear, 1, 1, null); if (nextJan1 < gregorianCutoverDate) { nextJan1 = gregorianCutoverDate; } assert jan1 <= cal.getFixedDate(date.getNormalizedYear(), date.getMonth(), date.getDayOfMonth(), date); assert nextJan1 >= cal.getFixedDate(date.getNormalizedYear(), date.getMonth(), date.getDayOfMonth(), date); value = (int)(nextJan1 - jan1); } break; case WEEK_OF_YEAR: { if (!gc.isCutoverYear(normalizedYear)) { // Get the day of week of January 1 of the year CalendarDate d = cal.newCalendarDate(TimeZone.NO_TIMEZONE); d.setDate(date.getYear(), BaseCalendar.JANUARY, 1); int dayOfWeek = cal.getDayOfWeek(d); // Normalize the day of week with the firstDayOfWeek value dayOfWeek -= getFirstDayOfWeek(); if (dayOfWeek < 0) { dayOfWeek += 7; } value = 52; int magic = dayOfWeek + getMinimalDaysInFirstWeek() - 1; if ((magic == 6) || (date.isLeapYear() && (magic == 5 || magic == 12))) { value++; } break; } if (gc == this) { gc = (GregorianCalendar) gc.clone(); } gc.set(DAY_OF_YEAR, getActualMaximum(DAY_OF_YEAR)); value = gc.get(WEEK_OF_YEAR); } break; case WEEK_OF_MONTH: { if (!gc.isCutoverYear(normalizedYear)) { CalendarDate d = cal.newCalendarDate(null); d.setDate(date.getYear(), date.getMonth(), 1); int dayOfWeek = cal.getDayOfWeek(d); int monthLength = cal.getMonthLength(d); dayOfWeek -= getFirstDayOfWeek(); if (dayOfWeek < 0) { dayOfWeek += 7; } int nDaysFirstWeek = 7 - dayOfWeek; // # of days in the first week value = 3; if (nDaysFirstWeek >= getMinimalDaysInFirstWeek()) { value++; } monthLength -= nDaysFirstWeek + 7 * 3; if (monthLength > 0) { value++; if (monthLength > 7) { value++; } } break; } // Cutover year handling if (gc == this) { gc = (GregorianCalendar) gc.clone(); } int y = gc.internalGet(YEAR); int m = gc.internalGet(MONTH); do { value = gc.get(WEEK_OF_MONTH); gc.add(WEEK_OF_MONTH, +1); } while (gc.get(YEAR) == y && gc.get(MONTH) == m); } break; case DAY_OF_WEEK_IN_MONTH: { // may be in the Gregorian cutover month int ndays, dow1; int dow = date.getDayOfWeek(); if (!gc.isCutoverYear(normalizedYear)) { BaseCalendar.Date d = (BaseCalendar.Date) date.clone(); ndays = cal.getMonthLength(d); d.setDayOfMonth(1); cal.normalize(d); dow1 = d.getDayOfWeek(); } else { // Let a cloned GregorianCalendar take care of the cutover cases. if (gc == this) { gc = (GregorianCalendar) clone(); } ndays = gc.actualMonthLength(); gc.set(DAY_OF_MONTH, gc.getActualMinimum(DAY_OF_MONTH)); dow1 = gc.get(DAY_OF_WEEK); } int x = dow - dow1; if (x < 0) { x += 7; } ndays -= x; value = (ndays + 6) / 7; } break; case YEAR: /* The year computation is no different, in principle, from the * others, however, the range of possible maxima is large. In * addition, the way we know we've exceeded the range is different. * For these reasons, we use the special case code below to handle * this field. * * The actual maxima for YEAR depend on the type of calendar: * * Gregorian = May 17, 292275056 BCE - Aug 17, 292278994 CE * Julian = Dec 2, 292269055 BCE - Jan 3, 292272993 CE * Hybrid = Dec 2, 292269055 BCE - Aug 17, 292278994 CE * * We know we've exceeded the maximum when either the month, date, * time, or era changes in response to setting the year. We don't * check for month, date, and time here because the year and era are * sufficient to detect an invalid year setting. NOTE: If code is * added to check the month and date in the future for some reason, * Feb 29 must be allowed to shift to Mar 1 when setting the year. */ { if (gc == this) { gc = (GregorianCalendar) clone(); } // Calculate the millisecond offset from the beginning // of the year of this calendar and adjust the max // year value if we are beyond the limit in the max // year. long current = gc.getYearOffsetInMillis(); if (gc.internalGetEra() == CE) { gc.setTimeInMillis(Long.MAX_VALUE); value = gc.get(YEAR); long maxEnd = gc.getYearOffsetInMillis(); if (current > maxEnd) { value--; } } else { CalendarSystem mincal = gc.getTimeInMillis() >= gregorianCutover ? gcal : getJulianCalendarSystem(); CalendarDate d = mincal.getCalendarDate(Long.MIN_VALUE, getZone()); long maxEnd = (cal.getDayOfYear(d) - 1) * 24 + d.getHours(); maxEnd *= 60; maxEnd += d.getMinutes(); maxEnd *= 60; maxEnd += d.getSeconds(); maxEnd *= 1000; maxEnd += d.getMillis(); value = d.getYear(); if (value <= 0) { assert mincal == gcal; value = 1 - value; } if (current < maxEnd) { value--; } } } break; default: throw new ArrayIndexOutOfBoundsException(field); } return value; }
0 0 0 0 0
unknown (Lib) ArrayStoreException 0 0 0 4
            
// in java-util/Collections.java
catch (ArrayStoreException e) { throw new ClassCastException(); }
// in java-util/Collections.java
catch (ArrayStoreException e) { throw new ClassCastException(); }
// in java-util/Collections.java
catch (ArrayStoreException e) { throw new ClassCastException(); }
// in java-util/Collections.java
catch (ArrayStoreException e) { throw new ClassCastException(); }
4
            
// in java-util/Collections.java
catch (ArrayStoreException e) { throw new ClassCastException(); }
// in java-util/Collections.java
catch (ArrayStoreException e) { throw new ClassCastException(); }
// in java-util/Collections.java
catch (ArrayStoreException e) { throw new ClassCastException(); }
// in java-util/Collections.java
catch (ArrayStoreException e) { throw new ClassCastException(); }
0
unknown (Lib) AssertionError 3
            
// in java-util/ArrayDeque.java
public ArrayDeque<E> clone() { try { ArrayDeque<E> result = (ArrayDeque<E>) super.clone(); result.elements = Arrays.copyOf(elements, elements.length); return result; } catch (CloneNotSupportedException e) { throw new AssertionError(); } }
// in java-util/EnumSet.java
public EnumSet<E> clone() { try { return (EnumSet<E>) super.clone(); } catch(CloneNotSupportedException e) { throw new AssertionError(e); } }
// in java-util/EnumMap.java
public EnumMap<K, V> clone() { EnumMap<K, V> result = null; try { result = (EnumMap<K, V>) super.clone(); } catch(CloneNotSupportedException e) { throw new AssertionError(); } result.vals = (Object[]) result.vals.clone(); return result; }
3
            
// in java-util/ArrayDeque.java
catch (CloneNotSupportedException e) { throw new AssertionError(); }
// in java-util/EnumSet.java
catch(CloneNotSupportedException e) { throw new AssertionError(e); }
// in java-util/EnumMap.java
catch(CloneNotSupportedException e) { throw new AssertionError(); }
0 0 0 0
unknown (Lib) ClassCastException 15
            
// in java-util/ResourceBundle.java
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException { String bundleName = toBundleName(baseName, locale); ResourceBundle bundle = null; if (format.equals("java.class")) { try { Class<? extends ResourceBundle> bundleClass = (Class<? extends ResourceBundle>)loader.loadClass(bundleName); // If the class isn't a ResourceBundle subclass, throw a // ClassCastException. if (ResourceBundle.class.isAssignableFrom(bundleClass)) { bundle = bundleClass.newInstance(); } else { throw new ClassCastException(bundleClass.getName() + " cannot be cast to ResourceBundle"); } } catch (ClassNotFoundException e) { } } else if (format.equals("java.properties")) { final String resourceName = toResourceName(bundleName, "properties"); final ClassLoader classLoader = loader; final boolean reloadFlag = reload; InputStream stream = null; try { stream = AccessController.doPrivileged( new PrivilegedExceptionAction<InputStream>() { public InputStream run() throws IOException { InputStream is = null; if (reloadFlag) { URL url = classLoader.getResource(resourceName); if (url != null) { URLConnection connection = url.openConnection(); if (connection != null) { // Disable caches to get fresh data for // reloading. connection.setUseCaches(false); is = connection.getInputStream(); } } } else { is = classLoader.getResourceAsStream(resourceName); } return is; } }); } catch (PrivilegedActionException e) { throw (IOException) e.getException(); } if (stream != null) { try { bundle = new PropertyResourceBundle(stream); } finally { stream.close(); } } }
// in java-util/EnumSet.java
public static <E extends Enum<E>> EnumSet<E> noneOf(Class<E> elementType) { Enum[] universe = getUniverse(elementType); if (universe == null) throw new ClassCastException(elementType + " not an enum"); if (universe.length <= 64) return new RegularEnumSet<E>(elementType, universe); else return new JumboEnumSet<E>(elementType, universe); }
// in java-util/EnumSet.java
final void typeCheck(E e) { Class eClass = e.getClass(); if (eClass != elementType && eClass.getSuperclass() != elementType) throw new ClassCastException(eClass + " != " + elementType); }
// in java-util/RegularEnumSet.java
public boolean addAll(Collection<? extends E> c) { if (!(c instanceof RegularEnumSet)) return super.addAll(c); RegularEnumSet es = (RegularEnumSet)c; if (es.elementType != elementType) { if (es.isEmpty()) return false; else throw new ClassCastException( es.elementType + " != " + elementType); } long oldElements = elements; elements |= es.elements; return elements != oldElements; }
// in java-util/EnumMap.java
public void putAll(Map<? extends K, ? extends V> m) { if (m instanceof EnumMap) { EnumMap<? extends K, ? extends V> em = (EnumMap<? extends K, ? extends V>)m; if (em.keyType != keyType) { if (em.isEmpty()) return; throw new ClassCastException(em.keyType + " != " + keyType); } for (int i = 0; i < keyUniverse.length; i++) { Object emValue = em.vals[i]; if (emValue != null) { if (vals[i] == null) size++; vals[i] = emValue; } } } else { super.putAll(m); } }
// in java-util/EnumMap.java
private void typeCheck(K key) { Class keyClass = key.getClass(); if (keyClass != keyType && keyClass.getSuperclass() != keyType) throw new ClassCastException(keyClass + " != " + keyType); }
// in java-util/JumboEnumSet.java
public boolean addAll(Collection<? extends E> c) { if (!(c instanceof JumboEnumSet)) return super.addAll(c); JumboEnumSet es = (JumboEnumSet)c; if (es.elementType != elementType) { if (es.isEmpty()) return false; else throw new ClassCastException( es.elementType + " != " + elementType); } for (int i = 0; i < elements.length; i++) elements[i] |= es.elements[i]; return recalculateSize(); }
// in java-util/Collections.java
void typeCheck(Object o) { if (!type.isInstance(o)) throw new ClassCastException("Attempt to insert " + o.getClass() + " element into collection with element type " + type); }
// in java-util/Collections.java
public boolean addAll(Collection<? extends E> coll) { /* * Dump coll into an array of the required type. This serves * three purposes: it insulates us from concurrent changes in * the contents of coll, it type-checks all of the elements in * coll, and it provides all-or-nothing semantics (which we * wouldn't get if we type-checked each element as we added it). */ E[] a = null; try { a = coll.toArray(zeroLengthElementArray()); } catch (ArrayStoreException e) { throw new ClassCastException(); } boolean result = false; for (E e : a) result |= c.add(e); return result; }
// in java-util/Collections.java
public boolean addAll(int index, Collection<? extends E> c) { // See CheckCollection.addAll, above, for an explanation E[] a = null; try { a = c.toArray(zeroLengthElementArray()); } catch (ArrayStoreException e) { throw new ClassCastException(); } return list.addAll(index, Arrays.asList(a)); }
// in java-util/Collections.java
private void typeCheck(Object key, Object value) { if (!keyType.isInstance(key)) throw new ClassCastException("Attempt to insert " + key.getClass() + " key into collection with key type " + keyType); if (!valueType.isInstance(value)) throw new ClassCastException("Attempt to insert " + value.getClass() +" value into collection with value type " + valueType); }
// in java-util/Collections.java
public void putAll(Map<? extends K, ? extends V> t) { // See CheckCollection.addAll, above, for an explanation K[] keys = null; try { keys = t.keySet().toArray(zeroLengthKeyArray()); } catch (ArrayStoreException e) { throw new ClassCastException(); } V[] values = null; try { values = t.values().toArray(zeroLengthValueArray()); } catch (ArrayStoreException e) { throw new ClassCastException(); } if (keys.length != values.length) throw new ConcurrentModificationException(); for (int i = 0; i < keys.length; i++) m.put(keys[i], values[i]); }
// in java-util/Collections.java
public V setValue(V value) { if (!valueType.isInstance(value)) throw new ClassCastException("Attempt to insert " + value.getClass() + " value into collection with value type " + valueType); return e.setValue(value); }
4
            
// in java-util/Collections.java
catch (ArrayStoreException e) { throw new ClassCastException(); }
// in java-util/Collections.java
catch (ArrayStoreException e) { throw new ClassCastException(); }
// in java-util/Collections.java
catch (ArrayStoreException e) { throw new ClassCastException(); }
// in java-util/Collections.java
catch (ArrayStoreException e) { throw new ClassCastException(); }
0 4
            
// in java-util/ResourceBundle.java
catch (ClassCastException e) { }
// in java-util/AbstractSet.java
catch (ClassCastException unused) { return false; }
// in java-util/AbstractMap.java
catch (ClassCastException unused) { return false; }
// in java-util/Hashtable.java
catch (ClassCastException unused) { return false; }
0 0
unknown (Lib) ClassNotFoundException 0 0 26
            
// in java-util/JapaneseImperialCalendar.java
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); if (jdate == null) { jdate = jcal.newCalendarDate(getZone()); cachedFixedDate = Long.MIN_VALUE; } }
// in java-util/SimpleTimeZone.java
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); if (serialVersionOnStream < 1) { // Fix a bug in the 1.1 SimpleTimeZone code -- namely, // startDayOfWeek and endDayOfWeek were usually uninitialized. We can't do // too much, so we assume SUNDAY, which actually works most of the time. if (startDayOfWeek == 0) { startDayOfWeek = Calendar.SUNDAY; } if (endDayOfWeek == 0) { endDayOfWeek = Calendar.SUNDAY; } // The variables dstSavings, startMode, and endMode are post-1.1, so they // won't be present if we're reading from a 1.1 stream. Fix them up. startMode = endMode = DOW_IN_MONTH_MODE; dstSavings = millisPerHour; } else { // For 1.1.4, in addition to the 3 new instance variables, we also // store the actual rules (which have not be made compatible with 1.1) // in the optional area. Read them in here and parse them. int length = stream.readInt(); byte[] rules = new byte[length]; stream.readFully(rules); unpackRules(rules); } if (serialVersionOnStream >= 2) { int[] times = (int[]) stream.readObject(); unpackTimes(times); } serialVersionOnStream = currentSerialVersion; }
// in java-util/UUID.java
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { in.defaultReadObject(); // Set "cached computation" fields to their initial values version = -1; variant = -1; timestamp = -1; sequence = -1; node = -1; hashCode = -1; }
// in java-util/ResourceBundle.java
public Class<?> loadClass(String name) throws ClassNotFoundException { if (loader != null) { return loader.loadClass(name); } return Class.forName(name); }
// in java-util/LinkedList.java
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { // Read in any hidden serialization magic s.defaultReadObject(); // Read in size int size = s.readInt(); // Initialize header header = new Entry<E>(null, null, null); header.next = header.previous = header; // Read in all elements in the proper order. for (int i=0; i<size; i++) addBefore((E)s.readObject(), header); }
// in java-util/TreeMap.java
private void readObject(final java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { // Read in the Comparator and any hidden stuff s.defaultReadObject(); // Read in size int size = s.readInt(); buildFromSorted(size, null, s, null); }
// in java-util/TreeMap.java
void readTreeSet(int size, java.io.ObjectInputStream s, V defaultVal) throws java.io.IOException, ClassNotFoundException { buildFromSorted(size, null, s, defaultVal); }
// in java-util/TreeMap.java
private void buildFromSorted(int size, Iterator it, java.io.ObjectInputStream str, V defaultVal) throws java.io.IOException, ClassNotFoundException { this.size = size; root = buildFromSorted(0, 0, size-1, computeRedLevel(size), it, str, defaultVal); }
// in java-util/TreeMap.java
private final Entry<K,V> buildFromSorted(int level, int lo, int hi, int redLevel, Iterator it, java.io.ObjectInputStream str, V defaultVal) throws java.io.IOException, ClassNotFoundException { /* * Strategy: The root is the middlemost element. To get to it, we * have to first recursively construct the entire left subtree, * so as to grab all of its elements. We can then proceed with right * subtree. * * The lo and hi arguments are the minimum and maximum * indices to pull out of the iterator or stream for current subtree. * They are not actually indexed, we just proceed sequentially, * ensuring that items are extracted in corresponding order. */ if (hi < lo) return null; int mid = (lo + hi) / 2; Entry<K,V> left = null; if (lo < mid) left = buildFromSorted(level+1, lo, mid - 1, redLevel, it, str, defaultVal); // extract key and/or value from iterator or stream K key; V value; if (it != null) { if (defaultVal==null) { Map.Entry<K,V> entry = (Map.Entry<K,V>)it.next(); key = entry.getKey(); value = entry.getValue(); } else { key = (K)it.next(); value = defaultVal; } } else { // use stream key = (K) str.readObject(); value = (defaultVal != null ? defaultVal : (V) str.readObject()); } Entry<K,V> middle = new Entry<K,V>(key, value, null); // color nodes in non-full bottommost level red if (level == redLevel) middle.color = RED; if (left != null) { middle.left = left; left.parent = middle; } if (mid < hi) { Entry<K,V> right = buildFromSorted(level+1, mid+1, hi, redLevel, it, str, defaultVal); middle.right = right; right.parent = middle; } return middle; }
// in java-util/ArrayDeque.java
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { s.defaultReadObject(); // Read in size and allocate array int size = s.readInt(); allocateElements(size); head = 0; tail = size; // Read in all elements in the proper order. for (int i = 0; i < size; i++) elements[i] = (E)s.readObject(); }
// in java-util/HashSet.java
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { // Read in any hidden serialization magic s.defaultReadObject(); // Read in HashMap capacity and load factor and create backing HashMap int capacity = s.readInt(); float loadFactor = s.readFloat(); map = (((HashSet)this) instanceof LinkedHashSet ? new LinkedHashMap<E,Object>(capacity, loadFactor) : new HashMap<E,Object>(capacity, loadFactor)); // Read in size int size = s.readInt(); // Read in all elements in the proper order. for (int i=0; i<size; i++) { E e = (E) s.readObject(); map.put(e, PRESENT); } }
// in java-util/Date.java
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { fastTime = s.readLong(); }
// in java-util/Random.java
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { ObjectInputStream.GetField fields = s.readFields(); // The seed is read in as {@code long} for // historical reasons, but it is converted to an AtomicLong. long seedVal = (long) fields.get("seed", -1L); if (seedVal < 0) throw new java.io.StreamCorruptedException( "Random: invalid seed"); resetSeed(seedVal); nextNextGaussian = fields.get("nextNextGaussian", 0.0); haveNextNextGaussian = fields.get("haveNextNextGaussian", false); }
// in java-util/HashMap.java
private void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException { // Read in the threshold, loadfactor, and any hidden stuff s.defaultReadObject(); // Read in number of buckets and allocate the bucket array; int numBuckets = s.readInt(); table = new Entry[numBuckets]; init(); // Give subclass a chance to do its thing. // Read in size (number of Mappings) int size = s.readInt(); // Read the keys and values, and put the mappings in the HashMap for (int i=0; i<size; i++) { K key = (K) s.readObject(); V value = (V) s.readObject(); putForCreate(key, value); } }
// in java-util/ArrayList.java
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { // Read in size, and any hidden stuff s.defaultReadObject(); // Read in array length and allocate array int arrayLength = s.readInt(); Object[] a = elementData = new Object[arrayLength]; // Read in all elements in the proper order. for (int i=0; i<size; i++) a[i] = s.readObject(); }
// in java-util/IdentityHashMap.java
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { // Read in any hidden stuff s.defaultReadObject(); // Read in size (number of Mappings) int size = s.readInt(); // Allow for 33% growth (i.e., capacity is >= 2* size()). init(capacity((size*4)/3)); // Read the keys and values, and put the mappings in the table for (int i=0; i<size; i++) { K key = (K) s.readObject(); V value = (V) s.readObject(); putForCreate(key, value); } }
// in java-util/PriorityQueue.java
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { // Read in size, and any hidden stuff s.defaultReadObject(); // Read in (and discard) array length s.readInt(); queue = new Object[size]; // Read in all elements. for (int i = 0; i < size; i++) queue[i] = s.readObject(); // Elements are guaranteed to be in "proper order", but the // spec has never explained what that might be. heapify(); }
// in java-util/BitSet.java
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { ObjectInputStream.GetField fields = s.readFields(); words = (long[]) fields.get("bits", null); // Assume maximum length then find real length // because recalculateWordsInUse assumes maintenance // or reduction in logical size wordsInUse = words.length; recalculateWordsInUse(); sizeIsSticky = (words.length > 0 && words[words.length-1] == 0L); // heuristic checkInvariants(); }
// in java-util/PropertyPermission.java
private synchronized void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException { // Read in the action, then initialize the rest s.defaultReadObject(); init(getMask(actions)); }
// in java-util/PropertyPermission.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { // Don't call defaultReadObject() // Read in serialized fields ObjectInputStream.GetField gfields = in.readFields(); // Get all_allowed all_allowed = gfields.get("all_allowed", false); // Get permissions Hashtable permissions = (Hashtable)gfields.get("permissions", null); perms = new HashMap(permissions.size()*2); perms.putAll(permissions); }
// in java-util/EnumMap.java
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { // Read in the key type and any hidden stuff s.defaultReadObject(); keyUniverse = getKeyUniverse(keyType); vals = new Object[keyUniverse.length]; // Read in size (number of Mappings) int size = s.readInt(); // Read the keys and values, and put the mappings in the HashMap for (int i = 0; i < size; i++) { K key = (K) s.readObject(); V value = (V) s.readObject(); put(key, value); } }
// in java-util/Hashtable.java
private void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException { // Read in the length, threshold, and loadfactor s.defaultReadObject(); // Read the original length of the array and number of elements int origlength = s.readInt(); int elements = s.readInt(); // Compute new size with a bit of room 5% to grow but // no larger than the original size. Make the length // odd if it's large enough, this helps distribute the entries. // Guard against the length ending up zero, that's not valid. int length = (int)(elements * loadFactor) + (elements / 20) + 3; if (length > elements && (length & 1) == 0) length--; if (origlength > 0 && length > origlength) length = origlength; Entry[] table = new Entry[length]; count = 0; // Read the number of elements and then all the key/value objects for (; elements > 0; elements--) { K key = (K)s.readObject(); V value = (V)s.readObject(); // synch could be eliminated for performance reconstitutionPut(table, key, value); } this.table = table; }
// in java-util/Collections.java
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); s = m.keySet(); }
// in java-util/Calendar.java
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { final ObjectInputStream input = stream; input.defaultReadObject(); stamp = new int[FIELD_COUNT]; // Starting with version 2 (not implemented yet), we expect that // fields[], isSet[], isTimeSet, and areFieldsSet may not be // streamed out anymore. We expect 'time' to be correct. if (serialVersionOnStream >= 2) { isTimeSet = true; if (fields == null) fields = new int[FIELD_COUNT]; if (isSet == null) isSet = new boolean[FIELD_COUNT]; } else if (serialVersionOnStream >= 0) { for (int i=0; i<FIELD_COUNT; ++i) stamp[i] = isSet[i] ? COMPUTED : UNSET; } serialVersionOnStream = currentSerialVersion; // If there's a ZoneInfo object, use it for zone. ZoneInfo zi = null; try { zi = AccessController.doPrivileged( new PrivilegedExceptionAction<ZoneInfo>() { public ZoneInfo run() throws Exception { return (ZoneInfo) input.readObject(); } }, CalendarAccessControlContext.INSTANCE); } catch (PrivilegedActionException pae) { Exception e = pae.getException(); if (!(e instanceof OptionalDataException)) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } else if (e instanceof IOException) { throw (IOException) e; } else if (e instanceof ClassNotFoundException) { throw (ClassNotFoundException) e; } throw new RuntimeException(e); } } if (zi != null) { zone = zi; } // If the deserialized object has a SimpleTimeZone, try to // replace it with a ZoneInfo equivalent (as of 1.4) in order // to be compatible with the SimpleTimeZone-based // implementation as much as possible. if (zone instanceof SimpleTimeZone) { String id = zone.getID(); TimeZone tz = TimeZone.getTimeZone(id); if (tz != null && tz.hasSameRules(zone) && tz.getID().equals(id)) { zone = tz; } } }
// in java-util/GregorianCalendar.java
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); if (gdate == null) { gdate = (BaseCalendar.Date) gcal.newCalendarDate(getZone()); cachedFixedDate = Long.MIN_VALUE; } setGregorianChange(gregorianCutover); }
// in java-util/TreeSet.java
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { // Read in any hidden stuff s.defaultReadObject(); // Read in Comparator Comparator<? super E> c = (Comparator<? super E>) s.readObject(); // Create backing TreeMap TreeMap<E,Object> tm; if (c==null) tm = new TreeMap<E,Object>(); else tm = new TreeMap<E,Object>(c); m = tm; // Read in size int size = s.readInt(); tm.readTreeSet(size, s, PRESENT); }
7
            
// in java-util/ResourceBundle.java
catch (ClassNotFoundException e) { }
// in java-util/TreeMap.java
catch (ClassNotFoundException cannotHappen) { }
// in java-util/TreeMap.java
catch (ClassNotFoundException cannotHappen) { }
// in java-util/TreeMap.java
catch (ClassNotFoundException cannotHappen) { }
// in java-util/TreeMap.java
catch (ClassNotFoundException cannotHappen) { }
// in java-util/Currency.java
catch (ClassNotFoundException e) { throw new InternalError(); }
// in java-util/ServiceLoader.java
catch (ClassNotFoundException x) { fail(service, "Provider " + cn + " not found"); }
1
            
// in java-util/Currency.java
catch (ClassNotFoundException e) { throw new InternalError(); }
0
unknown (Lib) CloneNotSupportedException 0 0 1
            
// in java-util/AbstractMap.java
protected Object clone() throws CloneNotSupportedException { AbstractMap<K,V> result = (AbstractMap<K,V>)super.clone(); result.keySet = null; result.values = null; return result; }
18
            
// in java-util/Vector.java
catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); }
// in java-util/ResourceBundle.java
catch (CloneNotSupportedException e) { //this should never happen throw new InternalError(); }
// in java-util/LinkedList.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/TreeMap.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/ArrayDeque.java
catch (CloneNotSupportedException e) { throw new AssertionError(); }
// in java-util/HashSet.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/Date.java
catch (CloneNotSupportedException e) {}
// in java-util/EnumSet.java
catch(CloneNotSupportedException e) { throw new AssertionError(e); }
// in java-util/HashMap.java
catch (CloneNotSupportedException e) { // assert false; }
// in java-util/ArrayList.java
catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); }
// in java-util/TimeZone.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/IdentityHashMap.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/BitSet.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/EnumMap.java
catch(CloneNotSupportedException e) { throw new AssertionError(); }
// in java-util/Hashtable.java
catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); }
// in java-util/Calendar.java
catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); }
// in java-util/Locale.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/TreeSet.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
16
            
// in java-util/Vector.java
catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); }
// in java-util/ResourceBundle.java
catch (CloneNotSupportedException e) { //this should never happen throw new InternalError(); }
// in java-util/LinkedList.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/TreeMap.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/ArrayDeque.java
catch (CloneNotSupportedException e) { throw new AssertionError(); }
// in java-util/HashSet.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/EnumSet.java
catch(CloneNotSupportedException e) { throw new AssertionError(e); }
// in java-util/ArrayList.java
catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); }
// in java-util/TimeZone.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/IdentityHashMap.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/BitSet.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/EnumMap.java
catch(CloneNotSupportedException e) { throw new AssertionError(); }
// in java-util/Hashtable.java
catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); }
// in java-util/Calendar.java
catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); }
// in java-util/Locale.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/TreeSet.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
0
runtime (Domain) ConcurrentModificationException
public class ConcurrentModificationException extends RuntimeException {
    /**
     * Constructs a ConcurrentModificationException with no
     * detail message.
     */
    public ConcurrentModificationException() {
    }

    /**
     * Constructs a <tt>ConcurrentModificationException</tt> with the
     * specified detail message.
     *
     * @param message the detail message pertaining to this exception.
     */
    public ConcurrentModificationException(String message) {
	super(message);
    }
}
31
            
// in java-util/LinkedList.java
final void checkForComodification() { if (modCount != expectedModCount) throw new ConcurrentModificationException(); }
// in java-util/TreeMap.java
final Entry<K,V> nextEntry() { Entry<K,V> e = next; if (e == null) throw new NoSuchElementException(); if (modCount != expectedModCount) throw new ConcurrentModificationException(); next = successor(e); lastReturned = e; return e; }
// in java-util/TreeMap.java
final Entry<K,V> prevEntry() { Entry<K,V> e = next; if (e == null) throw new NoSuchElementException(); if (modCount != expectedModCount) throw new ConcurrentModificationException(); next = predecessor(e); lastReturned = e; return e; }
// in java-util/TreeMap.java
public void remove() { if (lastReturned == null) throw new IllegalStateException(); if (modCount != expectedModCount) throw new ConcurrentModificationException(); // deleted entries are replaced by their successors if (lastReturned.left != null && lastReturned.right != null) next = lastReturned; deleteEntry(lastReturned); expectedModCount = modCount; lastReturned = null; }
// in java-util/TreeMap.java
final TreeMap.Entry<K,V> nextEntry() { TreeMap.Entry<K,V> e = next; if (e == null || e.key == fenceKey) throw new NoSuchElementException(); if (m.modCount != expectedModCount) throw new ConcurrentModificationException(); next = successor(e); lastReturned = e; return e; }
// in java-util/TreeMap.java
final TreeMap.Entry<K,V> prevEntry() { TreeMap.Entry<K,V> e = next; if (e == null || e.key == fenceKey) throw new NoSuchElementException(); if (m.modCount != expectedModCount) throw new ConcurrentModificationException(); next = predecessor(e); lastReturned = e; return e; }
// in java-util/TreeMap.java
final void removeAscending() { if (lastReturned == null) throw new IllegalStateException(); if (m.modCount != expectedModCount) throw new ConcurrentModificationException(); // deleted entries are replaced by their successors if (lastReturned.left != null && lastReturned.right != null) next = lastReturned; m.deleteEntry(lastReturned); lastReturned = null; expectedModCount = m.modCount; }
// in java-util/TreeMap.java
final void removeDescending() { if (lastReturned == null) throw new IllegalStateException(); if (m.modCount != expectedModCount) throw new ConcurrentModificationException(); m.deleteEntry(lastReturned); lastReturned = null; expectedModCount = m.modCount; }
// in java-util/ArrayDeque.java
private boolean delete(int i) { checkInvariants(); final E[] elements = this.elements; final int mask = elements.length - 1; final int h = head; final int t = tail; final int front = (i - h) & mask; final int back = (t - i) & mask; // Invariant: head <= i < tail mod circularity if (front >= ((t - h) & mask)) throw new ConcurrentModificationException(); // Optimize for least element motion if (front < back) { if (h <= i) { System.arraycopy(elements, h, elements, h + 1, front); } else { // Wrap around System.arraycopy(elements, 0, elements, 1, i); elements[0] = elements[mask]; System.arraycopy(elements, h, elements, h + 1, mask - h); } elements[h] = null; head = (h + 1) & mask; return false; } else { if (i < t) { // Copy the null tail as well System.arraycopy(elements, i + 1, elements, i, back); tail = t - 1; } else { // Wrap around System.arraycopy(elements, i + 1, elements, i, mask - i); elements[mask] = elements[0]; System.arraycopy(elements, 1, elements, 0, t); tail = (t - 1) & mask; } return true; } }
// in java-util/ArrayDeque.java
public E next() { if (cursor == fence) throw new NoSuchElementException(); E result = elements[cursor]; // This check doesn't catch all possible comodifications, // but does catch the ones that corrupt traversal if (tail != fence || result == null) throw new ConcurrentModificationException(); lastRet = cursor; cursor = (cursor + 1) & (elements.length - 1); return result; }
// in java-util/ArrayDeque.java
public E next() { if (cursor == fence) throw new NoSuchElementException(); cursor = (cursor - 1) & (elements.length - 1); E result = elements[cursor]; if (head != fence || result == null) throw new ConcurrentModificationException(); lastRet = cursor; return result; }
// in java-util/WeakHashMap.java
protected Entry<K,V> nextEntry() { if (modCount != expectedModCount) throw new ConcurrentModificationException(); if (nextKey == null && !hasNext()) throw new NoSuchElementException(); lastReturned = entry; entry = entry.next; currentKey = nextKey; nextKey = null; return lastReturned; }
// in java-util/WeakHashMap.java
public void remove() { if (lastReturned == null) throw new IllegalStateException(); if (modCount != expectedModCount) throw new ConcurrentModificationException(); WeakHashMap.this.remove(currentKey); expectedModCount = modCount; lastReturned = null; currentKey = null; }
// in java-util/LinkedHashMap.java
public void remove() { if (lastReturned == null) throw new IllegalStateException(); if (modCount != expectedModCount) throw new ConcurrentModificationException(); LinkedHashMap.this.remove(lastReturned.key); lastReturned = null; expectedModCount = modCount; }
// in java-util/LinkedHashMap.java
Entry<K,V> nextEntry() { if (modCount != expectedModCount) throw new ConcurrentModificationException(); if (nextEntry == header) throw new NoSuchElementException(); Entry<K,V> e = lastReturned = nextEntry; nextEntry = e.after; return e; }
// in java-util/AbstractList.java
public void remove() { if (lastRet == -1) throw new IllegalStateException(); checkForComodification(); try { AbstractList.this.remove(lastRet); if (lastRet < cursor) cursor--; lastRet = -1; expectedModCount = modCount; } catch (IndexOutOfBoundsException e) { throw new ConcurrentModificationException(); } }
// in java-util/AbstractList.java
final void checkForComodification() { if (modCount != expectedModCount) throw new ConcurrentModificationException(); }
// in java-util/AbstractList.java
public void set(E e) { if (lastRet == -1) throw new IllegalStateException(); checkForComodification(); try { AbstractList.this.set(lastRet, e); expectedModCount = modCount; } catch (IndexOutOfBoundsException ex) { throw new ConcurrentModificationException(); } }
// in java-util/AbstractList.java
public void add(E e) { checkForComodification(); try { AbstractList.this.add(cursor++, e); lastRet = -1; expectedModCount = modCount; } catch (IndexOutOfBoundsException ex) { throw new ConcurrentModificationException(); } }
// in java-util/AbstractList.java
private void checkForComodification() { if (l.modCount != expectedModCount) throw new ConcurrentModificationException(); }
// in java-util/HashMap.java
final Entry<K,V> nextEntry() { if (modCount != expectedModCount) throw new ConcurrentModificationException(); Entry<K,V> e = next; if (e == null) throw new NoSuchElementException(); if ((next = e.next) == null) { Entry[] t = table; while (index < t.length && (next = t[index++]) == null) ; } current = e; return e; }
// in java-util/HashMap.java
public void remove() { if (current == null) throw new IllegalStateException(); if (modCount != expectedModCount) throw new ConcurrentModificationException(); Object k = current.key; current = null; HashMap.this.removeEntryForKey(k); expectedModCount = modCount; }
// in java-util/ArrayList.java
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException{ // Write out element count, and any hidden stuff int expectedModCount = modCount; s.defaultWriteObject(); // Write out array length s.writeInt(elementData.length); // Write out all elements in the proper order. for (int i=0; i<size; i++) s.writeObject(elementData[i]); if (modCount != expectedModCount) { throw new ConcurrentModificationException(); } }
// in java-util/IdentityHashMap.java
protected int nextIndex() { if (modCount != expectedModCount) throw new ConcurrentModificationException(); if (!indexValid && !hasNext()) throw new NoSuchElementException(); indexValid = false; lastReturnedIndex = index; index += 2; return lastReturnedIndex; }
// in java-util/IdentityHashMap.java
public void remove() { if (lastReturnedIndex == -1) throw new IllegalStateException(); if (modCount != expectedModCount) throw new ConcurrentModificationException(); expectedModCount = ++modCount; int deletedSlot = lastReturnedIndex; lastReturnedIndex = -1; size--; // back up index to revisit new contents after deletion index = deletedSlot; indexValid = false; // Removal code proceeds as in closeDeletion except that // it must catch the rare case where an element already // seen is swapped into a vacant slot that will be later // traversed by this iterator. We cannot allow future // next() calls to return it again. The likelihood of // this occurring under 2/3 load factor is very slim, but // when it does happen, we must make a copy of the rest of // the table to use for the rest of the traversal. Since // this can only happen when we are near the end of the table, // even in these rare cases, this is not very expensive in // time or space. Object[] tab = traversalTable; int len = tab.length; int d = deletedSlot; K key = (K) tab[d]; tab[d] = null; // vacate the slot tab[d + 1] = null; // If traversing a copy, remove in real table. // We can skip gap-closure on copy. if (tab != IdentityHashMap.this.table) { IdentityHashMap.this.remove(key); expectedModCount = modCount; return; } Object item; for (int i = nextKeyIndex(d, len); (item = tab[i]) != null; i = nextKeyIndex(i, len)) { int r = hash(item, len); // See closeDeletion for explanation of this conditional if ((i < r && (r <= d || d <= i)) || (r <= d && d <= i)) { // If we are about to swap an already-seen element // into a slot that may later be returned by next(), // then clone the rest of table for use in future // next() calls. It is OK that our copy will have // a gap in the "wrong" place, since it will never // be used for searching anyway. if (i < deletedSlot && d >= deletedSlot && traversalTable == IdentityHashMap.this.table) { int remaining = len - deletedSlot; Object[] newTable = new Object[remaining]; System.arraycopy(tab, deletedSlot, newTable, 0, remaining); traversalTable = newTable; index = 0; } tab[d] = item; tab[d + 1] = tab[i + 1]; tab[i] = null; tab[i + 1] = null; d = i; } }
// in java-util/PriorityQueue.java
public E next() { if (expectedModCount != modCount) throw new ConcurrentModificationException(); if (cursor < size) return (E) queue[lastRet = cursor++]; if (forgetMeNot != null) { lastRet = -1; lastRetElt = forgetMeNot.poll(); if (lastRetElt != null) return lastRetElt; } throw new NoSuchElementException(); }
// in java-util/PriorityQueue.java
public void remove() { if (expectedModCount != modCount) throw new ConcurrentModificationException(); if (lastRet != -1) { E moved = PriorityQueue.this.removeAt(lastRet); lastRet = -1; if (moved == null) cursor--; else { if (forgetMeNot == null) forgetMeNot = new ArrayDeque<E>(); forgetMeNot.add(moved); } } else if (lastRetElt != null) { PriorityQueue.this.removeEq(lastRetElt); lastRetElt = null; } else { throw new IllegalStateException(); } expectedModCount = modCount; }
// in java-util/Hashtable.java
public T next() { if (modCount != expectedModCount) throw new ConcurrentModificationException(); return nextElement(); }
// in java-util/Hashtable.java
public void remove() { if (!iterator) throw new UnsupportedOperationException(); if (lastReturned == null) throw new IllegalStateException("Hashtable Enumerator"); if (modCount != expectedModCount) throw new ConcurrentModificationException(); synchronized(Hashtable.this) { Entry[] tab = Hashtable.this.table; int index = (lastReturned.hash & 0x7FFFFFFF) % tab.length; for (Entry<K,V> e = tab[index], prev = null; e != null; prev = e, e = e.next) { if (e == lastReturned) { modCount++; expectedModCount++; if (prev == null) tab[index] = e.next; else prev.next = e.next; count--; lastReturned = null; return; } } throw new ConcurrentModificationException(); } }
// in java-util/Collections.java
public void putAll(Map<? extends K, ? extends V> t) { // See CheckCollection.addAll, above, for an explanation K[] keys = null; try { keys = t.keySet().toArray(zeroLengthKeyArray()); } catch (ArrayStoreException e) { throw new ClassCastException(); } V[] values = null; try { values = t.values().toArray(zeroLengthValueArray()); } catch (ArrayStoreException e) { throw new ClassCastException(); } if (keys.length != values.length) throw new ConcurrentModificationException(); for (int i = 0; i < keys.length; i++) m.put(keys[i], values[i]); }
3
            
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException e) { throw new ConcurrentModificationException(); }
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException ex) { throw new ConcurrentModificationException(); }
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException ex) { throw new ConcurrentModificationException(); }
0 0 0 0
runtime (Domain) DuplicateFormatFlagsException
public class DuplicateFormatFlagsException extends IllegalFormatException {

    private static final long serialVersionUID = 18890531L;

    private String flags;

    /**
     * Constructs an instance of this class with the specified flags.
     *
     * @param  f
     *         The set of format flags which contain a duplicate flag.
     */
    public DuplicateFormatFlagsException(String f) {
 	if (f == null)
 	    throw new NullPointerException();
	this.flags = f;
    }

    /**
     * Returns the set of flags which contains a duplicate flag.
     *
     * @return  The flags
     */
    public String getFlags() {
	return flags;
    }

    public String getMessage() {
	return String.format("Flags = '%s'", flags);
    }
}
1
            
// in java-util/Formatter.java
public static Flags parse(String s) { char[] ca = s.toCharArray(); Flags f = new Flags(0); for (int i = 0; i < ca.length; i++) { Flags v = parse(ca[i]); if (f.contains(v)) throw new DuplicateFormatFlagsException(v.toString()); f.add(v); } return f; }
0 0 0 0 0
runtime (Domain) EmptyStackException
public
class EmptyStackException extends RuntimeException {
    /**
     * Constructs a new <code>EmptyStackException</code> with <tt>null</tt> 
     * as its error message string.
     */
    public EmptyStackException() {
    }
}
1
            
// in java-util/Stack.java
public synchronized E peek() { int len = size(); if (len == 0) throw new EmptyStackException(); return elementAt(len - 1); }
0 0 0 0 0
runtime (Lib) Error 3
            
// in java-util/ServiceLoader.java
public S next() { if (!hasNext()) { throw new NoSuchElementException(); } String cn = nextName; nextName = null; try { S p = service.cast(Class.forName(cn, true, loader) .newInstance()); providers.put(cn, p); return p; } catch (ClassNotFoundException x) { fail(service, "Provider " + cn + " not found"); } catch (Throwable x) { fail(service, "Provider " + cn + " could not be instantiated: " + x, x); } throw new Error(); // This cannot happen }
// in java-util/XMLUtils.java
static Document getLoadingDoc(InputStream in) throws SAXException, IOException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setIgnoringElementContentWhitespace(true); dbf.setValidating(true); dbf.setCoalescing(true); dbf.setIgnoringComments(true); try { DocumentBuilder db = dbf.newDocumentBuilder(); db.setEntityResolver(new Resolver()); db.setErrorHandler(new EH()); InputSource is = new InputSource(in); return db.parse(is); } catch (ParserConfigurationException x) { throw new Error(x); } }
2
            
// in java-util/Random.java
catch (Exception ex) { throw new Error(ex); }
// in java-util/XMLUtils.java
catch (ParserConfigurationException x) { throw new Error(x); }
0 0 0 0
checked (Lib) Exception 0 0 1
            
// in java-util/Calendar.java
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { final ObjectInputStream input = stream; input.defaultReadObject(); stamp = new int[FIELD_COUNT]; // Starting with version 2 (not implemented yet), we expect that // fields[], isSet[], isTimeSet, and areFieldsSet may not be // streamed out anymore. We expect 'time' to be correct. if (serialVersionOnStream >= 2) { isTimeSet = true; if (fields == null) fields = new int[FIELD_COUNT]; if (isSet == null) isSet = new boolean[FIELD_COUNT]; } else if (serialVersionOnStream >= 0) { for (int i=0; i<FIELD_COUNT; ++i) stamp[i] = isSet[i] ? COMPUTED : UNSET; } serialVersionOnStream = currentSerialVersion; // If there's a ZoneInfo object, use it for zone. ZoneInfo zi = null; try { zi = AccessController.doPrivileged( new PrivilegedExceptionAction<ZoneInfo>() { public ZoneInfo run() throws Exception { return (ZoneInfo) input.readObject(); } }, CalendarAccessControlContext.INSTANCE); } catch (PrivilegedActionException pae) { Exception e = pae.getException(); if (!(e instanceof OptionalDataException)) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } else if (e instanceof IOException) { throw (IOException) e; } else if (e instanceof ClassNotFoundException) { throw (ClassNotFoundException) e; } throw new RuntimeException(e); } } if (zi != null) { zone = zi; } // If the deserialized object has a SimpleTimeZone, try to // replace it with a ZoneInfo equivalent (as of 1.4) in order // to be compatible with the SimpleTimeZone-based // implementation as much as possible. if (zone instanceof SimpleTimeZone) { String id = zone.getID(); TimeZone tz = TimeZone.getTimeZone(id); if (tz != null && tz.hasSameRules(zone) && tz.getID().equals(id)) { zone = tz; } } }
// in java-util/Calendar.java
public ZoneInfo run() throws Exception { return (ZoneInfo) input.readObject(); }
6
            
// in java-util/ResourceBundle.java
catch (Exception cause) { cacheKey.setCause(cause); }
// in java-util/ResourceBundle.java
catch (Exception e) { cacheKey.setCause(e); }
// in java-util/ResourceBundle.java
catch (Exception e) { // ignore other exceptions }
// in java-util/Random.java
catch (Exception ex) { throw new Error(ex); }
// in java-util/Calendar.java
catch (Exception e) { // Note: GregorianCalendar.computeTime throws // IllegalArgumentException if the ERA value is invalid // even it's in lenient mode. }
// in java-util/Locale.java
catch (Exception e) { // just fall through }
1
            
// in java-util/Random.java
catch (Exception ex) { throw new Error(ex); }
1
runtime (Domain) FormatFlagsConversionMismatchException
public class FormatFlagsConversionMismatchException
    extends IllegalFormatException
{
    private static final long serialVersionUID = 19120414L;

    private String f;

    private char c;

    /**
     * Constructs an instance of this class with the specified flag
     * and conversion.
     *
     * @param  f
     *         The flag
     *
     * @param  c
     *         The conversion
     */
    public FormatFlagsConversionMismatchException(String f, char c) {
 	if (f == null)
 	    throw new NullPointerException();
	this.f = f;
	this.c = c;
    }

    /**
     * Returns the incompatible flag.
     *
     * @return  The flag
     */
     public String getFlags() {
	return f;
    }

    /**
     * Returns the incompatible conversion.
     *
     * @return  The conversion
     */
    public char getConversion() {
	return c;
    }

    public String getMessage() {
	return "Conversion = " + c + ", Flags = " + f;
    }
}
1
            
// in java-util/Formatter.java
private void failMismatch(Flags f, char c) { String fs = f.toString(); throw new FormatFlagsConversionMismatchException(fs, c); }
0 0 0 0 0
runtime (Domain) FormatterClosedException
public class FormatterClosedException extends IllegalStateException {

    private static final long serialVersionUID = 18111216L;
    
    /**
     * Constructs an instance of this class.
     */
    public FormatterClosedException() { }
}
1
            
// in java-util/Formatter.java
private void ensureOpen() { if (a == null) throw new FormatterClosedException(); }
0 0 0 0 0
checked (Lib) IOException 0 0 89
            
// in java-util/JapaneseImperialCalendar.java
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); if (jdate == null) { jdate = jcal.newCalendarDate(getZone()); cachedFixedDate = Long.MIN_VALUE; } }
// in java-util/Vector.java
private synchronized void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException { s.defaultWriteObject(); }
// in java-util/SimpleTimeZone.java
private void writeObject(ObjectOutputStream stream) throws IOException { // Construct a binary rule byte[] rules = packRules(); int[] times = packTimes(); // Convert to 1.1 FCS rules. This step may cause us to lose information. makeRulesCompatible(); // Write out the 1.1 FCS rules stream.defaultWriteObject(); // Write out the binary rules in the optional data area of the stream. stream.writeInt(rules.length); stream.write(rules); stream.writeObject(times); // Recover the original rules. This recovers the information lost // by makeRulesCompatible. unpackRules(rules); unpackTimes(times); }
// in java-util/SimpleTimeZone.java
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); if (serialVersionOnStream < 1) { // Fix a bug in the 1.1 SimpleTimeZone code -- namely, // startDayOfWeek and endDayOfWeek were usually uninitialized. We can't do // too much, so we assume SUNDAY, which actually works most of the time. if (startDayOfWeek == 0) { startDayOfWeek = Calendar.SUNDAY; } if (endDayOfWeek == 0) { endDayOfWeek = Calendar.SUNDAY; } // The variables dstSavings, startMode, and endMode are post-1.1, so they // won't be present if we're reading from a 1.1 stream. Fix them up. startMode = endMode = DOW_IN_MONTH_MODE; dstSavings = millisPerHour; } else { // For 1.1.4, in addition to the 3 new instance variables, we also // store the actual rules (which have not be made compatible with 1.1) // in the optional area. Read them in here and parse them. int length = stream.readInt(); byte[] rules = new byte[length]; stream.readFully(rules); unpackRules(rules); } if (serialVersionOnStream >= 2) { int[] times = (int[]) stream.readObject(); unpackTimes(times); } serialVersionOnStream = currentSerialVersion; }
// in java-util/UUID.java
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { in.defaultReadObject(); // Set "cached computation" fields to their initial values version = -1; variant = -1; timestamp = -1; sequence = -1; node = -1; hashCode = -1; }
// in java-util/ResourceBundle.java
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException { String bundleName = toBundleName(baseName, locale); ResourceBundle bundle = null; if (format.equals("java.class")) { try { Class<? extends ResourceBundle> bundleClass = (Class<? extends ResourceBundle>)loader.loadClass(bundleName); // If the class isn't a ResourceBundle subclass, throw a // ClassCastException. if (ResourceBundle.class.isAssignableFrom(bundleClass)) { bundle = bundleClass.newInstance(); } else { throw new ClassCastException(bundleClass.getName() + " cannot be cast to ResourceBundle"); } } catch (ClassNotFoundException e) { } } else if (format.equals("java.properties")) { final String resourceName = toResourceName(bundleName, "properties"); final ClassLoader classLoader = loader; final boolean reloadFlag = reload; InputStream stream = null; try { stream = AccessController.doPrivileged( new PrivilegedExceptionAction<InputStream>() { public InputStream run() throws IOException { InputStream is = null; if (reloadFlag) { URL url = classLoader.getResource(resourceName); if (url != null) { URLConnection connection = url.openConnection(); if (connection != null) { // Disable caches to get fresh data for // reloading. connection.setUseCaches(false); is = connection.getInputStream(); } } } else { is = classLoader.getResourceAsStream(resourceName); } return is; } }); } catch (PrivilegedActionException e) { throw (IOException) e.getException(); } if (stream != null) { try { bundle = new PropertyResourceBundle(stream); } finally { stream.close(); } } }
// in java-util/ResourceBundle.java
public InputStream run() throws IOException { InputStream is = null; if (reloadFlag) { URL url = classLoader.getResource(resourceName); if (url != null) { URLConnection connection = url.openConnection(); if (connection != null) { // Disable caches to get fresh data for // reloading. connection.setUseCaches(false); is = connection.getInputStream(); } } } else { is = classLoader.getResourceAsStream(resourceName); } return is; }
// in java-util/LinkedList.java
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException { // Write out any hidden serialization magic s.defaultWriteObject(); // Write out size s.writeInt(size); // Write out all elements in the proper order. for (Entry e = header.next; e != header; e = e.next) s.writeObject(e.element); }
// in java-util/LinkedList.java
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { // Read in any hidden serialization magic s.defaultReadObject(); // Read in size int size = s.readInt(); // Initialize header header = new Entry<E>(null, null, null); header.next = header.previous = header; // Read in all elements in the proper order. for (int i=0; i<size; i++) addBefore((E)s.readObject(), header); }
// in java-util/TreeMap.java
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException { // Write out the Comparator and any hidden stuff s.defaultWriteObject(); // Write out size (number of Mappings) s.writeInt(size); // Write out keys and values (alternating) for (Iterator<Map.Entry<K,V>> i = entrySet().iterator(); i.hasNext(); ) { Map.Entry<K,V> e = i.next(); s.writeObject(e.getKey()); s.writeObject(e.getValue()); } }
// in java-util/TreeMap.java
private void readObject(final java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { // Read in the Comparator and any hidden stuff s.defaultReadObject(); // Read in size int size = s.readInt(); buildFromSorted(size, null, s, null); }
// in java-util/TreeMap.java
void readTreeSet(int size, java.io.ObjectInputStream s, V defaultVal) throws java.io.IOException, ClassNotFoundException { buildFromSorted(size, null, s, defaultVal); }
// in java-util/TreeMap.java
private void buildFromSorted(int size, Iterator it, java.io.ObjectInputStream str, V defaultVal) throws java.io.IOException, ClassNotFoundException { this.size = size; root = buildFromSorted(0, 0, size-1, computeRedLevel(size), it, str, defaultVal); }
// in java-util/TreeMap.java
private final Entry<K,V> buildFromSorted(int level, int lo, int hi, int redLevel, Iterator it, java.io.ObjectInputStream str, V defaultVal) throws java.io.IOException, ClassNotFoundException { /* * Strategy: The root is the middlemost element. To get to it, we * have to first recursively construct the entire left subtree, * so as to grab all of its elements. We can then proceed with right * subtree. * * The lo and hi arguments are the minimum and maximum * indices to pull out of the iterator or stream for current subtree. * They are not actually indexed, we just proceed sequentially, * ensuring that items are extracted in corresponding order. */ if (hi < lo) return null; int mid = (lo + hi) / 2; Entry<K,V> left = null; if (lo < mid) left = buildFromSorted(level+1, lo, mid - 1, redLevel, it, str, defaultVal); // extract key and/or value from iterator or stream K key; V value; if (it != null) { if (defaultVal==null) { Map.Entry<K,V> entry = (Map.Entry<K,V>)it.next(); key = entry.getKey(); value = entry.getValue(); } else { key = (K)it.next(); value = defaultVal; } } else { // use stream key = (K) str.readObject(); value = (defaultVal != null ? defaultVal : (V) str.readObject()); } Entry<K,V> middle = new Entry<K,V>(key, value, null); // color nodes in non-full bottommost level red if (level == redLevel) middle.color = RED; if (left != null) { middle.left = left; left.parent = middle; } if (mid < hi) { Entry<K,V> right = buildFromSorted(level+1, mid+1, hi, redLevel, it, str, defaultVal); middle.right = right; right.parent = middle; } return middle; }
// in java-util/ArrayDeque.java
private void writeObject(ObjectOutputStream s) throws IOException { s.defaultWriteObject(); // Write out size s.writeInt(size()); // Write out elements in order. int mask = elements.length - 1; for (int i = head; i != tail; i = (i + 1) & mask) s.writeObject(elements[i]); }
// in java-util/ArrayDeque.java
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { s.defaultReadObject(); // Read in size and allocate array int size = s.readInt(); allocateElements(size); head = 0; tail = size; // Read in all elements in the proper order. for (int i = 0; i < size; i++) elements[i] = (E)s.readObject(); }
// in java-util/HashSet.java
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException { // Write out any hidden serialization magic s.defaultWriteObject(); // Write out HashMap capacity and load factor s.writeInt(map.capacity()); s.writeFloat(map.loadFactor()); // Write out size s.writeInt(map.size()); // Write out all elements in the proper order. for (Iterator i=map.keySet().iterator(); i.hasNext(); ) s.writeObject(i.next()); }
// in java-util/HashSet.java
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { // Read in any hidden serialization magic s.defaultReadObject(); // Read in HashMap capacity and load factor and create backing HashMap int capacity = s.readInt(); float loadFactor = s.readFloat(); map = (((HashSet)this) instanceof LinkedHashSet ? new LinkedHashMap<E,Object>(capacity, loadFactor) : new HashMap<E,Object>(capacity, loadFactor)); // Read in size int size = s.readInt(); // Read in all elements in the proper order. for (int i=0; i<size; i++) { E e = (E) s.readObject(); map.put(e, PRESENT); } }
// in java-util/Date.java
private void writeObject(ObjectOutputStream s) throws IOException { s.writeLong(getTimeImpl()); }
// in java-util/Date.java
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { fastTime = s.readLong(); }
// in java-util/Random.java
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { ObjectInputStream.GetField fields = s.readFields(); // The seed is read in as {@code long} for // historical reasons, but it is converted to an AtomicLong. long seedVal = (long) fields.get("seed", -1L); if (seedVal < 0) throw new java.io.StreamCorruptedException( "Random: invalid seed"); resetSeed(seedVal); nextNextGaussian = fields.get("nextNextGaussian", 0.0); haveNextNextGaussian = fields.get("haveNextNextGaussian", false); }
// in java-util/Random.java
synchronized private void writeObject(ObjectOutputStream s) throws IOException { // set the values of the Serializable fields ObjectOutputStream.PutField fields = s.putFields(); // The seed is serialized as a long for historical reasons. fields.put("seed", seed.get()); fields.put("nextNextGaussian", nextNextGaussian); fields.put("haveNextNextGaussian", haveNextNextGaussian); // save them s.writeFields(); }
// in java-util/HashMap.java
private void writeObject(java.io.ObjectOutputStream s) throws IOException { Iterator<Map.Entry<K,V>> i = (size > 0) ? entrySet0().iterator() : null; // Write out the threshold, loadfactor, and any hidden stuff s.defaultWriteObject(); // Write out number of buckets s.writeInt(table.length); // Write out size (number of Mappings) s.writeInt(size); // Write out keys and values (alternating) if (i != null) { while (i.hasNext()) { Map.Entry<K,V> e = i.next(); s.writeObject(e.getKey()); s.writeObject(e.getValue()); } } }
// in java-util/HashMap.java
private void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException { // Read in the threshold, loadfactor, and any hidden stuff s.defaultReadObject(); // Read in number of buckets and allocate the bucket array; int numBuckets = s.readInt(); table = new Entry[numBuckets]; init(); // Give subclass a chance to do its thing. // Read in size (number of Mappings) int size = s.readInt(); // Read the keys and values, and put the mappings in the HashMap for (int i=0; i<size; i++) { K key = (K) s.readObject(); V value = (V) s.readObject(); putForCreate(key, value); } }
// in java-util/ArrayList.java
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException{ // Write out element count, and any hidden stuff int expectedModCount = modCount; s.defaultWriteObject(); // Write out array length s.writeInt(elementData.length); // Write out all elements in the proper order. for (int i=0; i<size; i++) s.writeObject(elementData[i]); if (modCount != expectedModCount) { throw new ConcurrentModificationException(); } }
// in java-util/ArrayList.java
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { // Read in size, and any hidden stuff s.defaultReadObject(); // Read in array length and allocate array int arrayLength = s.readInt(); Object[] a = elementData = new Object[arrayLength]; // Read in all elements in the proper order. for (int i=0; i<size; i++) a[i] = s.readObject(); }
// in java-util/Properties.java
public synchronized void load(Reader reader) throws IOException { load0(new LineReader(reader)); }
// in java-util/Properties.java
public synchronized void load(InputStream inStream) throws IOException { load0(new LineReader(inStream)); }
// in java-util/Properties.java
private void load0 (LineReader lr) throws IOException { char[] convtBuf = new char[1024]; int limit; int keyLen; int valueStart; char c; boolean hasSep; boolean precedingBackslash; while ((limit = lr.readLine()) >= 0) { c = 0; keyLen = 0; valueStart = limit; hasSep = false; //System.out.println("line=<" + new String(lineBuf, 0, limit) + ">"); precedingBackslash = false; while (keyLen < limit) { c = lr.lineBuf[keyLen]; //need check if escaped. if ((c == '=' || c == ':') && !precedingBackslash) { valueStart = keyLen + 1; hasSep = true; break; } else if ((c == ' ' || c == '\t' || c == '\f') && !precedingBackslash) { valueStart = keyLen + 1; break; } if (c == '\\') { precedingBackslash = !precedingBackslash; } else { precedingBackslash = false; } keyLen++; } while (valueStart < limit) { c = lr.lineBuf[valueStart]; if (c != ' ' && c != '\t' && c != '\f') { if (!hasSep && (c == '=' || c == ':')) { hasSep = true; } else { break; } } valueStart++; } String key = loadConvert(lr.lineBuf, 0, keyLen, convtBuf); String value = loadConvert(lr.lineBuf, valueStart, limit - valueStart, convtBuf); put(key, value); } }
// in java-util/Properties.java
int readLine() throws IOException { int len = 0; char c = 0; boolean skipWhiteSpace = true; boolean isCommentLine = false; boolean isNewLine = true; boolean appendedLineBegin = false; boolean precedingBackslash = false; boolean skipLF = false; while (true) { if (inOff >= inLimit) { inLimit = (inStream==null)?reader.read(inCharBuf) :inStream.read(inByteBuf); inOff = 0; if (inLimit <= 0) { if (len == 0 || isCommentLine) { return -1; } return len; } } if (inStream != null) { //The line below is equivalent to calling a //ISO8859-1 decoder. c = (char) (0xff & inByteBuf[inOff++]); } else { c = inCharBuf[inOff++]; } if (skipLF) { skipLF = false; if (c == '\n') { continue; } } if (skipWhiteSpace) { if (c == ' ' || c == '\t' || c == '\f') { continue; } if (!appendedLineBegin && (c == '\r' || c == '\n')) { continue; } skipWhiteSpace = false; appendedLineBegin = false; } if (isNewLine) { isNewLine = false; if (c == '#' || c == '!') { isCommentLine = true; continue; } } if (c != '\n' && c != '\r') { lineBuf[len++] = c; if (len == lineBuf.length) { int newLength = lineBuf.length * 2; if (newLength < 0) { newLength = Integer.MAX_VALUE; } char[] buf = new char[newLength]; System.arraycopy(lineBuf, 0, buf, 0, lineBuf.length); lineBuf = buf; } //flip the preceding backslash flag if (c == '\\') { precedingBackslash = !precedingBackslash; } else { precedingBackslash = false; } } else { // reached EOL if (isCommentLine || len == 0) { isCommentLine = false; isNewLine = true; skipWhiteSpace = true; len = 0; continue; } if (inOff >= inLimit) { inLimit = (inStream==null) ?reader.read(inCharBuf) :inStream.read(inByteBuf); inOff = 0; if (inLimit <= 0) { return len; } } if (precedingBackslash) { len -= 1; //skip the leading whitespace characters in following line skipWhiteSpace = true; appendedLineBegin = true; precedingBackslash = false; if (c == '\r') { skipLF = true; } } else { return len; } } } }
// in java-util/Properties.java
private static void writeComments(BufferedWriter bw, String comments) throws IOException { bw.write("#"); int len = comments.length(); int current = 0; int last = 0; char[] uu = new char[6]; uu[0] = '\\'; uu[1] = 'u'; while (current < len) { char c = comments.charAt(current); if (c > '\u00ff' || c == '\n' || c == '\r') { if (last != current) bw.write(comments.substring(last, current)); if (c > '\u00ff') { uu[2] = toHex((c >> 12) & 0xf); uu[3] = toHex((c >> 8) & 0xf); uu[4] = toHex((c >> 4) & 0xf); uu[5] = toHex( c & 0xf); bw.write(new String(uu)); } else { bw.newLine(); if (c == '\r' && current != len - 1 && comments.charAt(current + 1) == '\n') { current++; } if (current == len - 1 || (comments.charAt(current + 1) != '#' && comments.charAt(current + 1) != '!')) bw.write("#"); } last = current + 1; } current++; } if (last != current) bw.write(comments.substring(last, current)); bw.newLine(); }
// in java-util/Properties.java
public void store(Writer writer, String comments) throws IOException { store0((writer instanceof BufferedWriter)?(BufferedWriter)writer : new BufferedWriter(writer), comments, false); }
// in java-util/Properties.java
public void store(OutputStream out, String comments) throws IOException { store0(new BufferedWriter(new OutputStreamWriter(out, "8859_1")), comments, true); }
// in java-util/Properties.java
private void store0(BufferedWriter bw, String comments, boolean escUnicode) throws IOException { if (comments != null) { writeComments(bw, comments); } bw.write("#" + new Date().toString()); bw.newLine(); synchronized (this) { for (Enumeration e = keys(); e.hasMoreElements();) { String key = (String)e.nextElement(); String val = (String)get(key); key = saveConvert(key, true, escUnicode); /* No need to escape embedded and trailing spaces for value, hence * pass false to flag. */ val = saveConvert(val, false, escUnicode); bw.write(key + "=" + val); bw.newLine(); } } bw.flush(); }
// in java-util/Properties.java
public synchronized void loadFromXML(InputStream in) throws IOException, InvalidPropertiesFormatException { if (in == null) throw new NullPointerException(); XMLUtils.load(this, in); in.close(); }
// in java-util/Properties.java
public synchronized void storeToXML(OutputStream os, String comment) throws IOException { if (os == null) throw new NullPointerException(); storeToXML(os, comment, "UTF-8"); }
// in java-util/Properties.java
public synchronized void storeToXML(OutputStream os, String comment, String encoding) throws IOException { if (os == null) throw new NullPointerException(); XMLUtils.save(this, os, comment, encoding); }
// in java-util/Formatter.java
public void print(Object arg, Locale l) throws IOException { a.append(s); }
// in java-util/Formatter.java
public void print(Object arg, Locale l) throws IOException { if (dt) { printDateTime(arg, l); return; } switch(c) { case Conversion.DECIMAL_INTEGER: case Conversion.OCTAL_INTEGER: case Conversion.HEXADECIMAL_INTEGER: printInteger(arg, l); break; case Conversion.SCIENTIFIC: case Conversion.GENERAL: case Conversion.DECIMAL_FLOAT: case Conversion.HEXADECIMAL_FLOAT: printFloat(arg, l); break; case Conversion.CHARACTER: case Conversion.CHARACTER_UPPER: printCharacter(arg); break; case Conversion.BOOLEAN: printBoolean(arg); break; case Conversion.STRING: printString(arg, l); break; case Conversion.HASHCODE: printHashCode(arg); break; case Conversion.LINE_SEPARATOR: if (ls == null) ls = System.getProperty("line.separator"); a.append(ls); break; case Conversion.PERCENT_SIGN: a.append('%'); break; default: assert false; } }
// in java-util/Formatter.java
private void printInteger(Object arg, Locale l) throws IOException { if (arg == null) print("null"); else if (arg instanceof Byte) print(((Byte)arg).byteValue(), l); else if (arg instanceof Short) print(((Short)arg).shortValue(), l); else if (arg instanceof Integer) print(((Integer)arg).intValue(), l); else if (arg instanceof Long) print(((Long)arg).longValue(), l); else if (arg instanceof BigInteger) print(((BigInteger)arg), l); else failConversion(c, arg); }
// in java-util/Formatter.java
private void printFloat(Object arg, Locale l) throws IOException { if (arg == null) print("null"); else if (arg instanceof Float) print(((Float)arg).floatValue(), l); else if (arg instanceof Double) print(((Double)arg).doubleValue(), l); else if (arg instanceof BigDecimal) print(((BigDecimal)arg), l); else failConversion(c, arg); }
// in java-util/Formatter.java
private void printDateTime(Object arg, Locale l) throws IOException { if (arg == null) { print("null"); return; } Calendar cal = null; // Instead of Calendar.setLenient(true), perhaps we should // wrap the IllegalArgumentException that might be thrown? if (arg instanceof Long) { // Note that the following method uses an instance of the // default time zone (TimeZone.getDefaultRef(). cal = Calendar.getInstance(l); cal.setTimeInMillis((Long)arg); } else if (arg instanceof Date) { // Note that the following method uses an instance of the // default time zone (TimeZone.getDefaultRef(). cal = Calendar.getInstance(l); cal.setTime((Date)arg); } else if (arg instanceof Calendar) { cal = (Calendar) ((Calendar)arg).clone(); cal.setLenient(true); } else { failConversion(c, arg); } print(cal, c, l); }
// in java-util/Formatter.java
private void printCharacter(Object arg) throws IOException { if (arg == null) { print("null"); return; } String s = null; if (arg instanceof Character) { s = ((Character)arg).toString(); } else if (arg instanceof Byte) { byte i = ((Byte)arg).byteValue(); if (Character.isValidCodePoint(i)) s = new String(Character.toChars(i)); else throw new IllegalFormatCodePointException(i); } else if (arg instanceof Short) { short i = ((Short)arg).shortValue(); if (Character.isValidCodePoint(i)) s = new String(Character.toChars(i)); else throw new IllegalFormatCodePointException(i); } else if (arg instanceof Integer) { int i = ((Integer)arg).intValue(); if (Character.isValidCodePoint(i)) s = new String(Character.toChars(i)); else throw new IllegalFormatCodePointException(i); } else { failConversion(c, arg); } print(s); }
// in java-util/Formatter.java
private void printString(Object arg, Locale l) throws IOException { if (arg == null) { print("null"); } else if (arg instanceof Formattable) { Formatter fmt = formatter; if (formatter.locale() != l) fmt = new Formatter(formatter.out(), l); ((Formattable)arg).formatTo(fmt, f.valueOf(), width, precision); } else { print(arg.toString()); } }
// in java-util/Formatter.java
private void printBoolean(Object arg) throws IOException { String s; if (arg != null) s = ((arg instanceof Boolean) ? ((Boolean)arg).toString() : Boolean.toString(true)); else s = Boolean.toString(false); print(s); }
// in java-util/Formatter.java
private void printHashCode(Object arg) throws IOException { String s = (arg == null ? "null" : Integer.toHexString(arg.hashCode())); print(s); }
// in java-util/Formatter.java
private void print(String s) throws IOException { if (precision != -1 && precision < s.length()) s = s.substring(0, precision); if (f.contains(Flags.UPPERCASE)) s = s.toUpperCase(); a.append(justify(s)); }
// in java-util/Formatter.java
private void print(byte value, Locale l) throws IOException { long v = value; if (value < 0 && (c == Conversion.OCTAL_INTEGER || c == Conversion.HEXADECIMAL_INTEGER)) { v += (1L << 8); assert v >= 0 : v; } print(v, l); }
// in java-util/Formatter.java
private void print(short value, Locale l) throws IOException { long v = value; if (value < 0 && (c == Conversion.OCTAL_INTEGER || c == Conversion.HEXADECIMAL_INTEGER)) { v += (1L << 16); assert v >= 0 : v; } print(v, l); }
// in java-util/Formatter.java
private void print(int value, Locale l) throws IOException { long v = value; if (value < 0 && (c == Conversion.OCTAL_INTEGER || c == Conversion.HEXADECIMAL_INTEGER)) { v += (1L << 32); assert v >= 0 : v; } print(v, l); }
// in java-util/Formatter.java
private void print(long value, Locale l) throws IOException { StringBuilder sb = new StringBuilder(); if (c == Conversion.DECIMAL_INTEGER) { boolean neg = value < 0; char[] va; if (value < 0) va = Long.toString(value, 10).substring(1).toCharArray(); else va = Long.toString(value, 10).toCharArray(); // leading sign indicator leadingSign(sb, neg); // the value localizedMagnitude(sb, va, f, adjustWidth(width, f, neg), l); // trailing sign indicator trailingSign(sb, neg); } else if (c == Conversion.OCTAL_INTEGER) { checkBadFlags(Flags.PARENTHESES, Flags.LEADING_SPACE, Flags.PLUS); String s = Long.toOctalString(value); int len = (f.contains(Flags.ALTERNATE) ? s.length() + 1 : s.length()); // apply ALTERNATE (radix indicator for octal) before ZERO_PAD if (f.contains(Flags.ALTERNATE)) sb.append('0'); if (f.contains(Flags.ZERO_PAD)) for (int i = 0; i < width - len; i++) sb.append('0'); sb.append(s); } else if (c == Conversion.HEXADECIMAL_INTEGER) { checkBadFlags(Flags.PARENTHESES, Flags.LEADING_SPACE, Flags.PLUS); String s = Long.toHexString(value); int len = (f.contains(Flags.ALTERNATE) ? s.length() + 2 : s.length()); // apply ALTERNATE (radix indicator for hex) before ZERO_PAD if (f.contains(Flags.ALTERNATE)) sb.append(f.contains(Flags.UPPERCASE) ? "0X" : "0x"); if (f.contains(Flags.ZERO_PAD)) for (int i = 0; i < width - len; i++) sb.append('0'); if (f.contains(Flags.UPPERCASE)) s = s.toUpperCase(); sb.append(s); } // justify based on width a.append(justify(sb.toString())); }
// in java-util/Formatter.java
private void print(BigInteger value, Locale l) throws IOException { StringBuilder sb = new StringBuilder(); boolean neg = value.signum() == -1; BigInteger v = value.abs(); // leading sign indicator leadingSign(sb, neg); // the value if (c == Conversion.DECIMAL_INTEGER) { char[] va = v.toString().toCharArray(); localizedMagnitude(sb, va, f, adjustWidth(width, f, neg), l); } else if (c == Conversion.OCTAL_INTEGER) { String s = v.toString(8); int len = s.length() + sb.length(); if (neg && f.contains(Flags.PARENTHESES)) len++; // apply ALTERNATE (radix indicator for octal) before ZERO_PAD if (f.contains(Flags.ALTERNATE)) { len++; sb.append('0'); } if (f.contains(Flags.ZERO_PAD)) { for (int i = 0; i < width - len; i++) sb.append('0'); } sb.append(s); } else if (c == Conversion.HEXADECIMAL_INTEGER) { String s = v.toString(16); int len = s.length() + sb.length(); if (neg && f.contains(Flags.PARENTHESES)) len++; // apply ALTERNATE (radix indicator for hex) before ZERO_PAD if (f.contains(Flags.ALTERNATE)) { len += 2; sb.append(f.contains(Flags.UPPERCASE) ? "0X" : "0x"); } if (f.contains(Flags.ZERO_PAD)) for (int i = 0; i < width - len; i++) sb.append('0'); if (f.contains(Flags.UPPERCASE)) s = s.toUpperCase(); sb.append(s); } // trailing sign indicator trailingSign(sb, (value.signum() == -1)); // justify based on width a.append(justify(sb.toString())); }
// in java-util/Formatter.java
private void print(float value, Locale l) throws IOException { print((double) value, l); }
// in java-util/Formatter.java
private void print(double value, Locale l) throws IOException { StringBuilder sb = new StringBuilder(); boolean neg = Double.compare(value, 0.0) == -1; if (!Double.isNaN(value)) { double v = Math.abs(value); // leading sign indicator leadingSign(sb, neg); // the value if (!Double.isInfinite(v)) print(sb, v, l, f, c, precision, neg); else sb.append(f.contains(Flags.UPPERCASE) ? "INFINITY" : "Infinity"); // trailing sign indicator trailingSign(sb, neg); } else { sb.append(f.contains(Flags.UPPERCASE) ? "NAN" : "NaN"); } // justify based on width a.append(justify(sb.toString())); }
// in java-util/Formatter.java
private void print(StringBuilder sb, double value, Locale l, Flags f, char c, int precision, boolean neg) throws IOException { if (c == Conversion.SCIENTIFIC) { // Create a new FormattedFloatingDecimal with the desired // precision. int prec = (precision == -1 ? 6 : precision); FormattedFloatingDecimal fd = new FormattedFloatingDecimal(value, prec, FormattedFloatingDecimal.Form.SCIENTIFIC); char[] v = new char[MAX_FD_CHARS]; int len = fd.getChars(v); char[] mant = addZeros(mantissa(v, len), prec); // If the precision is zero and the '#' flag is set, add the // requested decimal point. if (f.contains(Flags.ALTERNATE) && (prec == 0)) mant = addDot(mant); char[] exp = (value == 0.0) ? new char[] {'+','0','0'} : exponent(v, len); int newW = width; if (width != -1) newW = adjustWidth(width - exp.length - 1, f, neg); localizedMagnitude(sb, mant, f, newW, null); sb.append(f.contains(Flags.UPPERCASE) ? 'E' : 'e'); Flags flags = f.dup().remove(Flags.GROUP); char sign = exp[0]; assert(sign == '+' || sign == '-'); sb.append(sign); char[] tmp = new char[exp.length - 1]; System.arraycopy(exp, 1, tmp, 0, exp.length - 1); sb.append(localizedMagnitude(null, tmp, flags, -1, null)); } else if (c == Conversion.DECIMAL_FLOAT) { // Create a new FormattedFloatingDecimal with the desired // precision. int prec = (precision == -1 ? 6 : precision); FormattedFloatingDecimal fd = new FormattedFloatingDecimal(value, prec, FormattedFloatingDecimal.Form.DECIMAL_FLOAT); // MAX_FD_CHARS + 1 (round?) char[] v = new char[MAX_FD_CHARS + 1 + Math.abs(fd.getExponent())]; int len = fd.getChars(v); char[] mant = addZeros(mantissa(v, len), prec); // If the precision is zero and the '#' flag is set, add the // requested decimal point. if (f.contains(Flags.ALTERNATE) && (prec == 0)) mant = addDot(mant); int newW = width; if (width != -1) newW = adjustWidth(width, f, neg); localizedMagnitude(sb, mant, f, newW, l); } else if (c == Conversion.GENERAL) { int prec = precision; if (precision == -1) prec = 6; else if (precision == 0) prec = 1; FormattedFloatingDecimal fd = new FormattedFloatingDecimal(value, prec, FormattedFloatingDecimal.Form.GENERAL); // MAX_FD_CHARS + 1 (round?) char[] v = new char[MAX_FD_CHARS + 1 + Math.abs(fd.getExponent())]; int len = fd.getChars(v); char[] exp = exponent(v, len); if (exp != null) { prec -= 1; } else { prec = prec - (value == 0 ? 0 : fd.getExponentRounded()) - 1; } char[] mant = addZeros(mantissa(v, len), prec); // If the precision is zero and the '#' flag is set, add the // requested decimal point. if (f.contains(Flags.ALTERNATE) && (prec == 0)) mant = addDot(mant); int newW = width; if (width != -1) { if (exp != null) newW = adjustWidth(width - exp.length - 1, f, neg); else newW = adjustWidth(width, f, neg); } localizedMagnitude(sb, mant, f, newW, null); if (exp != null) { sb.append(f.contains(Flags.UPPERCASE) ? 'E' : 'e'); Flags flags = f.dup().remove(Flags.GROUP); char sign = exp[0]; assert(sign == '+' || sign == '-'); sb.append(sign); char[] tmp = new char[exp.length - 1]; System.arraycopy(exp, 1, tmp, 0, exp.length - 1); sb.append(localizedMagnitude(null, tmp, flags, -1, null)); } } else if (c == Conversion.HEXADECIMAL_FLOAT) { int prec = precision; if (precision == -1) // assume that we want all of the digits prec = 0; else if (precision == 0) prec = 1; String s = hexDouble(value, prec); char[] va; boolean upper = f.contains(Flags.UPPERCASE); sb.append(upper ? "0X" : "0x"); if (f.contains(Flags.ZERO_PAD)) for (int i = 0; i < width - s.length() - 2; i++) sb.append('0'); int idx = s.indexOf('p'); va = s.substring(0, idx).toCharArray(); if (upper) { String tmp = new String(va); // don't localize hex tmp = tmp.toUpperCase(Locale.US); va = tmp.toCharArray(); } sb.append(prec != 0 ? addZeros(va, prec) : va); sb.append(upper ? 'P' : 'p'); sb.append(s.substring(idx+1)); } }
// in java-util/Formatter.java
private void print(BigDecimal value, Locale l) throws IOException { if (c == Conversion.HEXADECIMAL_FLOAT) failConversion(c, value); StringBuilder sb = new StringBuilder(); boolean neg = value.signum() == -1; BigDecimal v = value.abs(); // leading sign indicator leadingSign(sb, neg); // the value print(sb, v, l, f, c, precision, neg); // trailing sign indicator trailingSign(sb, neg); // justify based on width a.append(justify(sb.toString())); }
// in java-util/Formatter.java
private void print(StringBuilder sb, BigDecimal value, Locale l, Flags f, char c, int precision, boolean neg) throws IOException { if (c == Conversion.SCIENTIFIC) { // Create a new BigDecimal with the desired precision. int prec = (precision == -1 ? 6 : precision); int scale = value.scale(); int origPrec = value.precision(); int nzeros = 0; int compPrec; if (prec > origPrec - 1) { compPrec = origPrec; nzeros = prec - (origPrec - 1); } else { compPrec = prec + 1; } MathContext mc = new MathContext(compPrec); BigDecimal v = new BigDecimal(value.unscaledValue(), scale, mc); BigDecimalLayout bdl = new BigDecimalLayout(v.unscaledValue(), v.scale(), BigDecimalLayoutForm.SCIENTIFIC); char[] mant = bdl.mantissa(); // Add a decimal point if necessary. The mantissa may not // contain a decimal point if the scale is zero (the internal // representation has no fractional part) or the original // precision is one. Append a decimal point if '#' is set or if // we require zero padding to get to the requested precision. if ((origPrec == 1 || !bdl.hasDot()) && (nzeros > 0 || (f.contains(Flags.ALTERNATE)))) mant = addDot(mant); // Add trailing zeros in the case precision is greater than // the number of available digits after the decimal separator. mant = trailingZeros(mant, nzeros); char[] exp = bdl.exponent(); int newW = width; if (width != -1) newW = adjustWidth(width - exp.length - 1, f, neg); localizedMagnitude(sb, mant, f, newW, null); sb.append(f.contains(Flags.UPPERCASE) ? 'E' : 'e'); Flags flags = f.dup().remove(Flags.GROUP); char sign = exp[0]; assert(sign == '+' || sign == '-'); sb.append(exp[0]); char[] tmp = new char[exp.length - 1]; System.arraycopy(exp, 1, tmp, 0, exp.length - 1); sb.append(localizedMagnitude(null, tmp, flags, -1, null)); } else if (c == Conversion.DECIMAL_FLOAT) { // Create a new BigDecimal with the desired precision. int prec = (precision == -1 ? 6 : precision); int scale = value.scale(); if (scale > prec) { // more "scale" digits than the requested "precision int compPrec = value.precision(); if (compPrec <= scale) { // case of 0.xxxxxx value = value.setScale(prec, RoundingMode.HALF_UP); } else { compPrec -= (scale - prec); value = new BigDecimal(value.unscaledValue(), scale, new MathContext(compPrec)); } } BigDecimalLayout bdl = new BigDecimalLayout( value.unscaledValue(), value.scale(), BigDecimalLayoutForm.DECIMAL_FLOAT); char mant[] = bdl.mantissa(); int nzeros = (bdl.scale() < prec ? prec - bdl.scale() : 0); // Add a decimal point if necessary. The mantissa may not // contain a decimal point if the scale is zero (the internal // representation has no fractional part). Append a decimal // point if '#' is set or we require zero padding to get to the // requested precision. if (bdl.scale() == 0 && (f.contains(Flags.ALTERNATE) || nzeros > 0)) mant = addDot(bdl.mantissa()); // Add trailing zeros if the precision is greater than the // number of available digits after the decimal separator. mant = trailingZeros(mant, nzeros); localizedMagnitude(sb, mant, f, adjustWidth(width, f, neg), l); } else if (c == Conversion.GENERAL) { int prec = precision; if (precision == -1) prec = 6; else if (precision == 0) prec = 1; BigDecimal tenToTheNegFour = BigDecimal.valueOf(1, 4); BigDecimal tenToThePrec = BigDecimal.valueOf(1, -prec); if ((value.equals(BigDecimal.ZERO)) || ((value.compareTo(tenToTheNegFour) != -1) && (value.compareTo(tenToThePrec) == -1))) { int e = - value.scale() + (value.unscaledValue().toString().length() - 1); // xxx.yyy // g precision (# sig digits) = #x + #y // f precision = #y // exponent = #x - 1 // => f precision = g precision - exponent - 1 // 0.000zzz // g precision (# sig digits) = #z // f precision = #0 (after '.') + #z // exponent = - #0 (after '.') - 1 // => f precision = g precision - exponent - 1 prec = prec - e - 1; print(sb, value, l, f, Conversion.DECIMAL_FLOAT, prec, neg); } else { print(sb, value, l, f, Conversion.SCIENTIFIC, prec - 1, neg); } } else if (c == Conversion.HEXADECIMAL_FLOAT) { // This conversion isn't supported. The error should be // reported earlier. assert false; } }
// in java-util/Formatter.java
private void print(Calendar t, char c, Locale l) throws IOException { StringBuilder sb = new StringBuilder(); print(sb, t, c, l); // justify based on width String s = justify(sb.toString()); if (f.contains(Flags.UPPERCASE)) s = s.toUpperCase(); a.append(s); }
// in java-util/Formatter.java
private Appendable print(StringBuilder sb, Calendar t, char c, Locale l) throws IOException { assert(width == -1); if (sb == null) sb = new StringBuilder(); switch (c) { case DateTime.HOUR_OF_DAY_0: // 'H' (00 - 23) case DateTime.HOUR_0: // 'I' (01 - 12) case DateTime.HOUR_OF_DAY: // 'k' (0 - 23) -- like H case DateTime.HOUR: { // 'l' (1 - 12) -- like I int i = t.get(Calendar.HOUR_OF_DAY); if (c == DateTime.HOUR_0 || c == DateTime.HOUR) i = (i == 0 || i == 12 ? 12 : i % 12); Flags flags = (c == DateTime.HOUR_OF_DAY_0 || c == DateTime.HOUR_0 ? Flags.ZERO_PAD : Flags.NONE); sb.append(localizedMagnitude(null, i, flags, 2, l)); break; } case DateTime.MINUTE: { // 'M' (00 - 59) int i = t.get(Calendar.MINUTE); Flags flags = Flags.ZERO_PAD; sb.append(localizedMagnitude(null, i, flags, 2, l)); break; } case DateTime.NANOSECOND: { // 'N' (000000000 - 999999999) int i = t.get(Calendar.MILLISECOND) * 1000000; Flags flags = Flags.ZERO_PAD; sb.append(localizedMagnitude(null, i, flags, 9, l)); break; } case DateTime.MILLISECOND: { // 'L' (000 - 999) int i = t.get(Calendar.MILLISECOND); Flags flags = Flags.ZERO_PAD; sb.append(localizedMagnitude(null, i, flags, 3, l)); break; } case DateTime.MILLISECOND_SINCE_EPOCH: { // 'Q' (0 - 99...?) long i = t.getTimeInMillis(); Flags flags = Flags.NONE; sb.append(localizedMagnitude(null, i, flags, width, l)); break; } case DateTime.AM_PM: { // 'p' (am or pm) // Calendar.AM = 0, Calendar.PM = 1, LocaleElements defines upper String[] ampm = { "AM", "PM" }; if (l != null && l != Locale.US) { DateFormatSymbols dfs = DateFormatSymbols.getInstance(l); ampm = dfs.getAmPmStrings(); } String s = ampm[t.get(Calendar.AM_PM)]; sb.append(s.toLowerCase(l != null ? l : Locale.US)); break; } case DateTime.SECONDS_SINCE_EPOCH: { // 's' (0 - 99...?) long i = t.getTimeInMillis() / 1000; Flags flags = Flags.NONE; sb.append(localizedMagnitude(null, i, flags, width, l)); break; } case DateTime.SECOND: { // 'S' (00 - 60 - leap second) int i = t.get(Calendar.SECOND); Flags flags = Flags.ZERO_PAD; sb.append(localizedMagnitude(null, i, flags, 2, l)); break; } case DateTime.ZONE_NUMERIC: { // 'z' ({-|+}####) - ls minus? int i = t.get(Calendar.ZONE_OFFSET); boolean neg = i < 0; sb.append(neg ? '-' : '+'); if (neg) i = -i; int min = i / 60000; // combine minute and hour into a single integer int offset = (min / 60) * 100 + (min % 60); Flags flags = Flags.ZERO_PAD; sb.append(localizedMagnitude(null, offset, flags, 4, l)); break; } case DateTime.ZONE: { // 'Z' (symbol) TimeZone tz = t.getTimeZone(); sb.append(tz.getDisplayName((t.get(Calendar.DST_OFFSET) != 0), TimeZone.SHORT, l)); break; } // Date case DateTime.NAME_OF_DAY_ABBREV: // 'a' case DateTime.NAME_OF_DAY: { // 'A' int i = t.get(Calendar.DAY_OF_WEEK); Locale lt = ((l == null) ? Locale.US : l); DateFormatSymbols dfs = DateFormatSymbols.getInstance(lt); if (c == DateTime.NAME_OF_DAY) sb.append(dfs.getWeekdays()[i]); else sb.append(dfs.getShortWeekdays()[i]); break; } case DateTime.NAME_OF_MONTH_ABBREV: // 'b' case DateTime.NAME_OF_MONTH_ABBREV_X: // 'h' -- same b case DateTime.NAME_OF_MONTH: { // 'B' int i = t.get(Calendar.MONTH); Locale lt = ((l == null) ? Locale.US : l); DateFormatSymbols dfs = DateFormatSymbols.getInstance(lt); if (c == DateTime.NAME_OF_MONTH) sb.append(dfs.getMonths()[i]); else sb.append(dfs.getShortMonths()[i]); break; } case DateTime.CENTURY: // 'C' (00 - 99) case DateTime.YEAR_2: // 'y' (00 - 99) case DateTime.YEAR_4: { // 'Y' (0000 - 9999) int i = t.get(Calendar.YEAR); int size = 2; switch (c) { case DateTime.CENTURY: i /= 100; break; case DateTime.YEAR_2: i %= 100; break; case DateTime.YEAR_4: size = 4; break; } Flags flags = Flags.ZERO_PAD; sb.append(localizedMagnitude(null, i, flags, size, l)); break; } case DateTime.DAY_OF_MONTH_0: // 'd' (01 - 31) case DateTime.DAY_OF_MONTH: { // 'e' (1 - 31) -- like d int i = t.get(Calendar.DATE); Flags flags = (c == DateTime.DAY_OF_MONTH_0 ? Flags.ZERO_PAD : Flags.NONE); sb.append(localizedMagnitude(null, i, flags, 2, l)); break; } case DateTime.DAY_OF_YEAR: { // 'j' (001 - 366) int i = t.get(Calendar.DAY_OF_YEAR); Flags flags = Flags.ZERO_PAD; sb.append(localizedMagnitude(null, i, flags, 3, l)); break; } case DateTime.MONTH: { // 'm' (01 - 12) int i = t.get(Calendar.MONTH) + 1; Flags flags = Flags.ZERO_PAD; sb.append(localizedMagnitude(null, i, flags, 2, l)); break; } // Composites case DateTime.TIME: // 'T' (24 hour hh:mm:ss - %tH:%tM:%tS) case DateTime.TIME_24_HOUR: { // 'R' (hh:mm same as %H:%M) char sep = ':'; print(sb, t, DateTime.HOUR_OF_DAY_0, l).append(sep); print(sb, t, DateTime.MINUTE, l); if (c == DateTime.TIME) { sb.append(sep); print(sb, t, DateTime.SECOND, l); } break; } case DateTime.TIME_12_HOUR: { // 'r' (hh:mm:ss [AP]M) char sep = ':'; print(sb, t, DateTime.HOUR_0, l).append(sep); print(sb, t, DateTime.MINUTE, l).append(sep); print(sb, t, DateTime.SECOND, l).append(' '); // this may be in wrong place for some locales StringBuilder tsb = new StringBuilder(); print(tsb, t, DateTime.AM_PM, l); sb.append(tsb.toString().toUpperCase(l != null ? l : Locale.US)); break; } case DateTime.DATE_TIME: { // 'c' (Sat Nov 04 12:02:33 EST 1999) char sep = ' '; print(sb, t, DateTime.NAME_OF_DAY_ABBREV, l).append(sep); print(sb, t, DateTime.NAME_OF_MONTH_ABBREV, l).append(sep); print(sb, t, DateTime.DAY_OF_MONTH_0, l).append(sep); print(sb, t, DateTime.TIME, l).append(sep); print(sb, t, DateTime.ZONE, l).append(sep); print(sb, t, DateTime.YEAR_4, l); break; } case DateTime.DATE: { // 'D' (mm/dd/yy) char sep = '/'; print(sb, t, DateTime.MONTH, l).append(sep); print(sb, t, DateTime.DAY_OF_MONTH_0, l).append(sep); print(sb, t, DateTime.YEAR_2, l); break; } case DateTime.ISO_STANDARD_DATE: { // 'F' (%Y-%m-%d) char sep = '-'; print(sb, t, DateTime.YEAR_4, l).append(sep); print(sb, t, DateTime.MONTH, l).append(sep); print(sb, t, DateTime.DAY_OF_MONTH_0, l); break; } default: assert false; } return sb; }
// in java-util/ServiceLoader.java
private int parseLine(Class service, URL u, BufferedReader r, int lc, List<String> names) throws IOException, ServiceConfigurationError { String ln = r.readLine(); if (ln == null) { return -1; } int ci = ln.indexOf('#'); if (ci >= 0) ln = ln.substring(0, ci); ln = ln.trim(); int n = ln.length(); if (n != 0) { if ((ln.indexOf(' ') >= 0) || (ln.indexOf('\t') >= 0)) fail(service, u, lc, "Illegal configuration-file syntax"); int cp = ln.codePointAt(0); if (!Character.isJavaIdentifierStart(cp)) fail(service, u, lc, "Illegal provider-class name: " + ln); for (int i = Character.charCount(cp); i < n; i += Character.charCount(cp)) { cp = ln.codePointAt(i); if (!Character.isJavaIdentifierPart(cp) && (cp != '.')) fail(service, u, lc, "Illegal provider-class name: " + ln); } if (!providers.containsKey(ln) && !names.contains(ln)) names.add(ln); } return lc + 1; }
// in java-util/IdentityHashMap.java
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException { // Write out and any hidden stuff s.defaultWriteObject(); // Write out size (number of Mappings) s.writeInt(size); // Write out keys and values (alternating) Object[] tab = table; for (int i = 0; i < tab.length; i += 2) { Object key = tab[i]; if (key != null) { s.writeObject(unmaskNull(key)); s.writeObject(tab[i + 1]); } } }
// in java-util/IdentityHashMap.java
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { // Read in any hidden stuff s.defaultReadObject(); // Read in size (number of Mappings) int size = s.readInt(); // Allow for 33% growth (i.e., capacity is >= 2* size()). init(capacity((size*4)/3)); // Read the keys and values, and put the mappings in the table for (int i=0; i<size; i++) { K key = (K) s.readObject(); V value = (V) s.readObject(); putForCreate(key, value); } }
// in java-util/IdentityHashMap.java
private void putForCreate(K key, V value) throws IOException { K k = (K)maskNull(key); Object[] tab = table; int len = tab.length; int i = hash(k, len); Object item; while ( (item = tab[i]) != null) { if (item == k) throw new java.io.StreamCorruptedException(); i = nextKeyIndex(i, len); } tab[i] = k; tab[i + 1] = value; }
// in java-util/PriorityQueue.java
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException{ // Write out element count, and any hidden stuff s.defaultWriteObject(); // Write out array length, for compatibility with 1.5 version s.writeInt(Math.max(2, size + 1)); // Write out all elements in the "proper order". for (int i = 0; i < size; i++) s.writeObject(queue[i]); }
// in java-util/PriorityQueue.java
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { // Read in size, and any hidden stuff s.defaultReadObject(); // Read in (and discard) array length s.readInt(); queue = new Object[size]; // Read in all elements. for (int i = 0; i < size; i++) queue[i] = s.readObject(); // Elements are guaranteed to be in "proper order", but the // spec has never explained what that might be. heapify(); }
// in java-util/BitSet.java
private void writeObject(ObjectOutputStream s) throws IOException { checkInvariants(); if (! sizeIsSticky) trimToSize(); ObjectOutputStream.PutField fields = s.putFields(); fields.put("bits", words); s.writeFields(); }
// in java-util/BitSet.java
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { ObjectInputStream.GetField fields = s.readFields(); words = (long[]) fields.get("bits", null); // Assume maximum length then find real length // because recalculateWordsInUse assumes maintenance // or reduction in logical size wordsInUse = words.length; recalculateWordsInUse(); sizeIsSticky = (words.length > 0 && words[words.length-1] == 0L); // heuristic checkInvariants(); }
// in java-util/XMLUtils.java
static void load(Properties props, InputStream in) throws IOException, InvalidPropertiesFormatException { Document doc = null; try { doc = getLoadingDoc(in); } catch (SAXException saxe) { throw new InvalidPropertiesFormatException(saxe); } Element propertiesElement = (Element)doc.getChildNodes().item(1); String xmlVersion = propertiesElement.getAttribute("version"); if (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0) throw new InvalidPropertiesFormatException( "Exported Properties file format version " + xmlVersion + " is not supported. This java installation can read" + " versions " + EXTERNAL_XML_VERSION + " or older. You" + " may need to install a newer version of JDK."); importProperties(props, propertiesElement); }
// in java-util/XMLUtils.java
static Document getLoadingDoc(InputStream in) throws SAXException, IOException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setIgnoringElementContentWhitespace(true); dbf.setValidating(true); dbf.setCoalescing(true); dbf.setIgnoringComments(true); try { DocumentBuilder db = dbf.newDocumentBuilder(); db.setEntityResolver(new Resolver()); db.setErrorHandler(new EH()); InputSource is = new InputSource(in); return db.parse(is); } catch (ParserConfigurationException x) { throw new Error(x); } }
// in java-util/XMLUtils.java
static void save(Properties props, OutputStream os, String comment, String encoding) throws IOException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = null; try { db = dbf.newDocumentBuilder(); } catch (ParserConfigurationException pce) { assert(false); } Document doc = db.newDocument(); Element properties = (Element) doc.appendChild(doc.createElement("properties")); if (comment != null) { Element comments = (Element)properties.appendChild( doc.createElement("comment")); comments.appendChild(doc.createTextNode(comment)); } Set keys = props.keySet(); Iterator i = keys.iterator(); while(i.hasNext()) { String key = (String)i.next(); Element entry = (Element)properties.appendChild( doc.createElement("entry")); entry.setAttribute("key", key); entry.appendChild(doc.createTextNode(props.getProperty(key))); } emitDocument(doc, os, encoding); }
// in java-util/XMLUtils.java
static void emitDocument(Document doc, OutputStream os, String encoding) throws IOException { TransformerFactory tf = TransformerFactory.newInstance(); Transformer t = null; try { t = tf.newTransformer(); t.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, PROPS_DTD_URI); t.setOutputProperty(OutputKeys.INDENT, "yes"); t.setOutputProperty(OutputKeys.METHOD, "xml"); t.setOutputProperty(OutputKeys.ENCODING, encoding); } catch (TransformerConfigurationException tce) { assert(false); } DOMSource doms = new DOMSource(doc); StreamResult sr = new StreamResult(os); try { t.transform(doms, sr); } catch (TransformerException te) { IOException ioe = new IOException(); ioe.initCause(te); throw ioe; } }
// in java-util/PropertyPermission.java
private synchronized void writeObject(java.io.ObjectOutputStream s) throws IOException { // Write out the actions. The superclass takes care of the name // call getActions to make sure actions field is initialized if (actions == null) getActions(); s.defaultWriteObject(); }
// in java-util/PropertyPermission.java
private synchronized void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException { // Read in the action, then initialize the rest s.defaultReadObject(); init(getMask(actions)); }
// in java-util/PropertyPermission.java
private void writeObject(ObjectOutputStream out) throws IOException { // Don't call out.defaultWriteObject() // Copy perms into a Hashtable Hashtable permissions = new Hashtable(perms.size()*2); synchronized (this) { permissions.putAll(perms); } // Write out serializable fields ObjectOutputStream.PutField pfields = out.putFields(); pfields.put("all_allowed", all_allowed); pfields.put("permissions", permissions); out.writeFields(); }
// in java-util/PropertyPermission.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { // Don't call defaultReadObject() // Read in serialized fields ObjectInputStream.GetField gfields = in.readFields(); // Get all_allowed all_allowed = gfields.get("all_allowed", false); // Get permissions Hashtable permissions = (Hashtable)gfields.get("permissions", null); perms = new HashMap(permissions.size()*2); perms.putAll(permissions); }
// in java-util/EnumMap.java
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException { // Write out the key type and any hidden stuff s.defaultWriteObject(); // Write out size (number of Mappings) s.writeInt(size); // Write out keys and values (alternating) for (Map.Entry<K,V> e : entrySet()) { s.writeObject(e.getKey()); s.writeObject(e.getValue()); } }
// in java-util/EnumMap.java
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { // Read in the key type and any hidden stuff s.defaultReadObject(); keyUniverse = getKeyUniverse(keyType); vals = new Object[keyUniverse.length]; // Read in size (number of Mappings) int size = s.readInt(); // Read the keys and values, and put the mappings in the HashMap for (int i = 0; i < size; i++) { K key = (K) s.readObject(); V value = (V) s.readObject(); put(key, value); } }
// in java-util/Hashtable.java
private synchronized void writeObject(java.io.ObjectOutputStream s) throws IOException { // Write out the length, threshold, loadfactor s.defaultWriteObject(); // Write out length, count of elements and then the key/value objects s.writeInt(table.length); s.writeInt(count); for (int index = table.length-1; index >= 0; index--) { Entry entry = table[index]; while (entry != null) { s.writeObject(entry.key); s.writeObject(entry.value); entry = entry.next; } } }
// in java-util/Hashtable.java
private void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException { // Read in the length, threshold, and loadfactor s.defaultReadObject(); // Read the original length of the array and number of elements int origlength = s.readInt(); int elements = s.readInt(); // Compute new size with a bit of room 5% to grow but // no larger than the original size. Make the length // odd if it's large enough, this helps distribute the entries. // Guard against the length ending up zero, that's not valid. int length = (int)(elements * loadFactor) + (elements / 20) + 3; if (length > elements && (length & 1) == 0) length--; if (origlength > 0 && length > origlength) length = origlength; Entry[] table = new Entry[length]; count = 0; // Read the number of elements and then all the key/value objects for (; elements > 0; elements--) { K key = (K)s.readObject(); V value = (V)s.readObject(); // synch could be eliminated for performance reconstitutionPut(table, key, value); } this.table = table; }
// in java-util/Collections.java
private void writeObject(ObjectOutputStream s) throws IOException { synchronized(mutex) {s.defaultWriteObject();} }
// in java-util/Collections.java
private void writeObject(ObjectOutputStream s) throws IOException { synchronized(mutex) {s.defaultWriteObject();} }
// in java-util/Collections.java
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); s = m.keySet(); }
// in java-util/Calendar.java
private void writeObject(ObjectOutputStream stream) throws IOException { // Try to compute the time correctly, for the future (stream // version 2) in which we don't write out fields[] or isSet[]. if (!isTimeSet) { try { updateTime(); } catch (IllegalArgumentException e) {} } // If this Calendar has a ZoneInfo, save it and set a // SimpleTimeZone equivalent (as a single DST schedule) for // backward compatibility. TimeZone savedZone = null; if (zone instanceof ZoneInfo) { SimpleTimeZone stz = ((ZoneInfo)zone).getLastRuleInstance(); if (stz == null) { stz = new SimpleTimeZone(zone.getRawOffset(), zone.getID()); } savedZone = zone; zone = stz; } // Write out the 1.1 FCS object. stream.defaultWriteObject(); // Write out the ZoneInfo object // 4802409: we write out even if it is null, a temporary workaround // the real fix for bug 4844924 in corba-iiop stream.writeObject(savedZone); if (savedZone != null) { zone = savedZone; } }
// in java-util/Calendar.java
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { final ObjectInputStream input = stream; input.defaultReadObject(); stamp = new int[FIELD_COUNT]; // Starting with version 2 (not implemented yet), we expect that // fields[], isSet[], isTimeSet, and areFieldsSet may not be // streamed out anymore. We expect 'time' to be correct. if (serialVersionOnStream >= 2) { isTimeSet = true; if (fields == null) fields = new int[FIELD_COUNT]; if (isSet == null) isSet = new boolean[FIELD_COUNT]; } else if (serialVersionOnStream >= 0) { for (int i=0; i<FIELD_COUNT; ++i) stamp[i] = isSet[i] ? COMPUTED : UNSET; } serialVersionOnStream = currentSerialVersion; // If there's a ZoneInfo object, use it for zone. ZoneInfo zi = null; try { zi = AccessController.doPrivileged( new PrivilegedExceptionAction<ZoneInfo>() { public ZoneInfo run() throws Exception { return (ZoneInfo) input.readObject(); } }, CalendarAccessControlContext.INSTANCE); } catch (PrivilegedActionException pae) { Exception e = pae.getException(); if (!(e instanceof OptionalDataException)) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } else if (e instanceof IOException) { throw (IOException) e; } else if (e instanceof ClassNotFoundException) { throw (ClassNotFoundException) e; } throw new RuntimeException(e); } } if (zi != null) { zone = zi; } // If the deserialized object has a SimpleTimeZone, try to // replace it with a ZoneInfo equivalent (as of 1.4) in order // to be compatible with the SimpleTimeZone-based // implementation as much as possible. if (zone instanceof SimpleTimeZone) { String id = zone.getID(); TimeZone tz = TimeZone.getTimeZone(id); if (tz != null && tz.hasSameRules(zone) && tz.getID().equals(id)) { zone = tz; } } }
// in java-util/GregorianCalendar.java
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); if (gdate == null) { gdate = (BaseCalendar.Date) gcal.newCalendarDate(getZone()); cachedFixedDate = Long.MIN_VALUE; } setGregorianChange(gregorianCutover); }
// in java-util/TreeSet.java
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException { // Write out any hidden stuff s.defaultWriteObject(); // Write out Comparator s.writeObject(m.comparator()); // Write out size s.writeInt(m.size()); // Write out all elements in the proper order. for (Iterator i=m.keySet().iterator(); i.hasNext(); ) s.writeObject(i.next()); }
// in java-util/TreeSet.java
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { // Read in any hidden stuff s.defaultReadObject(); // Read in Comparator Comparator<? super E> c = (Comparator<? super E>) s.readObject(); // Create backing TreeMap TreeMap<E,Object> tm; if (c==null) tm = new TreeMap<E,Object>(); else tm = new TreeMap<E,Object>(c); m = tm; // Read in size int size = s.readInt(); tm.readTreeSet(size, s, PRESENT); }
13
            
// in java-util/TreeMap.java
catch (java.io.IOException cannotHappen) { }
// in java-util/TreeMap.java
catch (java.io.IOException cannotHappen) { }
// in java-util/TreeMap.java
catch (java.io.IOException cannotHappen) { }
// in java-util/TreeMap.java
catch (java.io.IOException cannotHappen) { }
// in java-util/Scanner.java
catch (IOException ioe) { lastException = ioe; n = -1; }
// in java-util/Scanner.java
catch (IOException ioe) { lastException = ioe; }
// in java-util/Properties.java
catch (IOException e) { }
// in java-util/Formatter.java
catch (IOException ioe) { lastException = ioe; }
// in java-util/Formatter.java
catch (IOException ioe) { lastException = ioe; }
// in java-util/Formatter.java
catch (IOException x) { lastException = x; }
// in java-util/ServiceLoader.java
catch (IOException x) { fail(service, "Error reading configuration file", x); }
// in java-util/ServiceLoader.java
catch (IOException y) { fail(service, "Error closing configuration file", y); }
// in java-util/ServiceLoader.java
catch (IOException x) { fail(service, "Error locating configuration files", x); }
0 0
unknown (Lib) IllegalAccessException 0 0 1
            
// in java-util/ResourceBundle.java
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException { String bundleName = toBundleName(baseName, locale); ResourceBundle bundle = null; if (format.equals("java.class")) { try { Class<? extends ResourceBundle> bundleClass = (Class<? extends ResourceBundle>)loader.loadClass(bundleName); // If the class isn't a ResourceBundle subclass, throw a // ClassCastException. if (ResourceBundle.class.isAssignableFrom(bundleClass)) { bundle = bundleClass.newInstance(); } else { throw new ClassCastException(bundleClass.getName() + " cannot be cast to ResourceBundle"); } } catch (ClassNotFoundException e) { } } else if (format.equals("java.properties")) { final String resourceName = toResourceName(bundleName, "properties"); final ClassLoader classLoader = loader; final boolean reloadFlag = reload; InputStream stream = null; try { stream = AccessController.doPrivileged( new PrivilegedExceptionAction<InputStream>() { public InputStream run() throws IOException { InputStream is = null; if (reloadFlag) { URL url = classLoader.getResource(resourceName); if (url != null) { URLConnection connection = url.openConnection(); if (connection != null) { // Disable caches to get fresh data for // reloading. connection.setUseCaches(false); is = connection.getInputStream(); } } } else { is = classLoader.getResourceAsStream(resourceName); } return is; } }); } catch (PrivilegedActionException e) { throw (IOException) e.getException(); } if (stream != null) { try { bundle = new PropertyResourceBundle(stream); } finally { stream.close(); } } }
1
            
// in java-util/Currency.java
catch (IllegalAccessException e) { throw new InternalError(); }
1
            
// in java-util/Currency.java
catch (IllegalAccessException e) { throw new InternalError(); }
0
runtime (Lib) IllegalArgumentException 97
            
// in java-util/JapaneseImperialCalendar.java
public void add(int field, int amount) { // If amount == 0, do nothing even the given field is out of // range. This is tested by JCK. if (amount == 0) { return; // Do nothing! } if (field < 0 || field >= ZONE_OFFSET) { throw new IllegalArgumentException(); } // Sync the time and calendar fields. complete(); if (field == YEAR) { LocalGregorianCalendar.Date d = (LocalGregorianCalendar.Date) jdate.clone(); d.addYear(amount); pinDayOfMonth(d); set(ERA, getEraIndex(d)); set(YEAR, d.getYear()); set(MONTH, d.getMonth() - 1); set(DAY_OF_MONTH, d.getDayOfMonth()); } else if (field == MONTH) { LocalGregorianCalendar.Date d = (LocalGregorianCalendar.Date) jdate.clone(); d.addMonth(amount); pinDayOfMonth(d); set(ERA, getEraIndex(d)); set(YEAR, d.getYear()); set(MONTH, d.getMonth() - 1); set(DAY_OF_MONTH, d.getDayOfMonth()); } else if (field == ERA) { int era = internalGet(ERA) + amount; if (era < 0) { era = 0; } else if (era > eras.length - 1) { era = eras.length - 1; } set(ERA, era); } else { long delta = amount; long timeOfDay = 0; switch (field) { // Handle the time fields here. Convert the given // amount to milliseconds and call setTimeInMillis. case HOUR: case HOUR_OF_DAY: delta *= 60 * 60 * 1000; // hours to milliseconds break; case MINUTE: delta *= 60 * 1000; // minutes to milliseconds break; case SECOND: delta *= 1000; // seconds to milliseconds break; case MILLISECOND: break; // Handle week, day and AM_PM fields which involves // time zone offset change adjustment. Convert the // given amount to the number of days. case WEEK_OF_YEAR: case WEEK_OF_MONTH: case DAY_OF_WEEK_IN_MONTH: delta *= 7; break; case DAY_OF_MONTH: // synonym of DATE case DAY_OF_YEAR: case DAY_OF_WEEK: break; case AM_PM: // Convert the amount to the number of days (delta) // and +12 or -12 hours (timeOfDay). delta = amount / 2; timeOfDay = 12 * (amount % 2); break; } // The time fields don't require time zone offset change // adjustment. if (field >= HOUR) { setTimeInMillis(time + delta); return; } // The rest of the fields (week, day or AM_PM fields) // require time zone offset (both GMT and DST) change // adjustment. // Translate the current time to the fixed date and time // of the day. long fd = cachedFixedDate; timeOfDay += internalGet(HOUR_OF_DAY); timeOfDay *= 60; timeOfDay += internalGet(MINUTE); timeOfDay *= 60; timeOfDay += internalGet(SECOND); timeOfDay *= 1000; timeOfDay += internalGet(MILLISECOND); if (timeOfDay >= ONE_DAY) { fd++; timeOfDay -= ONE_DAY; } else if (timeOfDay < 0) { fd--; timeOfDay += ONE_DAY; } fd += delta; // fd is the expected fixed date after the calculation int zoneOffset = internalGet(ZONE_OFFSET) + internalGet(DST_OFFSET); setTimeInMillis((fd - EPOCH_OFFSET) * ONE_DAY + timeOfDay - zoneOffset); zoneOffset -= internalGet(ZONE_OFFSET) + internalGet(DST_OFFSET); // If the time zone offset has changed, then adjust the difference. if (zoneOffset != 0) { setTimeInMillis(time + zoneOffset); long fd2 = cachedFixedDate; // If the adjustment has changed the date, then take // the previous one. if (fd2 != fd) { setTimeInMillis(time - zoneOffset); } } } }
// in java-util/JapaneseImperialCalendar.java
public void roll(int field, int amount) { // If amount == 0, do nothing even the given field is out of // range. This is tested by JCK. if (amount == 0) { return; } if (field < 0 || field >= ZONE_OFFSET) { throw new IllegalArgumentException(); } // Sync the time and calendar fields. complete(); int min = getMinimum(field); int max = getMaximum(field); switch (field) { case ERA: case AM_PM: case MINUTE: case SECOND: case MILLISECOND: // These fields are handled simply, since they have fixed // minima and maxima. Other fields are complicated, since // the range within they must roll varies depending on the // date, a time zone and the era transitions. break; case HOUR: case HOUR_OF_DAY: { int unit = max + 1; // 12 or 24 hours int h = internalGet(field); int nh = (h + amount) % unit; if (nh < 0) { nh += unit; } time += ONE_HOUR * (nh - h); // The day might have changed, which could happen if // the daylight saving time transition brings it to // the next day, although it's very unlikely. But we // have to make sure not to change the larger fields. CalendarDate d = jcal.getCalendarDate(time, getZone()); if (internalGet(DAY_OF_MONTH) != d.getDayOfMonth()) { d.setEra(jdate.getEra()); d.setDate(internalGet(YEAR), internalGet(MONTH) + 1, internalGet(DAY_OF_MONTH)); if (field == HOUR) { assert (internalGet(AM_PM) == PM); d.addHours(+12); // restore PM } time = jcal.getTime(d); } int hourOfDay = d.getHours(); internalSet(field, hourOfDay % unit); if (field == HOUR) { internalSet(HOUR_OF_DAY, hourOfDay); } else { internalSet(AM_PM, hourOfDay / 12); internalSet(HOUR, hourOfDay % 12); } // Time zone offset and/or daylight saving might have changed. int zoneOffset = d.getZoneOffset(); int saving = d.getDaylightSaving(); internalSet(ZONE_OFFSET, zoneOffset - saving); internalSet(DST_OFFSET, saving); return; } case YEAR: min = getActualMinimum(field); max = getActualMaximum(field); break; case MONTH: // Rolling the month involves both pinning the final value to [0, 11] // and adjusting the DAY_OF_MONTH if necessary. We only adjust the // DAY_OF_MONTH if, after updating the MONTH field, it is illegal. // E.g., <jan31>.roll(MONTH, 1) -> <feb28> or <feb29>. { if (!isTransitionYear(jdate.getNormalizedYear())) { int year = jdate.getYear(); if (year == getMaximum(YEAR)) { CalendarDate jd = jcal.getCalendarDate(time, getZone()); CalendarDate d = jcal.getCalendarDate(Long.MAX_VALUE, getZone()); max = d.getMonth() - 1; int n = getRolledValue(internalGet(field), amount, min, max); if (n == max) { // To avoid overflow, use an equivalent year. jd.addYear(-400); jd.setMonth(n + 1); if (jd.getDayOfMonth() > d.getDayOfMonth()) { jd.setDayOfMonth(d.getDayOfMonth()); jcal.normalize(jd); } if (jd.getDayOfMonth() == d.getDayOfMonth() && jd.getTimeOfDay() > d.getTimeOfDay()) { jd.setMonth(n + 1); jd.setDayOfMonth(d.getDayOfMonth() - 1); jcal.normalize(jd); // Month may have changed by the normalization. n = jd.getMonth() - 1; } set(DAY_OF_MONTH, jd.getDayOfMonth()); } set(MONTH, n); } else if (year == getMinimum(YEAR)) { CalendarDate jd = jcal.getCalendarDate(time, getZone()); CalendarDate d = jcal.getCalendarDate(Long.MIN_VALUE, getZone()); min = d.getMonth() - 1; int n = getRolledValue(internalGet(field), amount, min, max); if (n == min) { // To avoid underflow, use an equivalent year. jd.addYear(+400); jd.setMonth(n + 1); if (jd.getDayOfMonth() < d.getDayOfMonth()) { jd.setDayOfMonth(d.getDayOfMonth()); jcal.normalize(jd); } if (jd.getDayOfMonth() == d.getDayOfMonth() && jd.getTimeOfDay() < d.getTimeOfDay()) { jd.setMonth(n + 1); jd.setDayOfMonth(d.getDayOfMonth() + 1); jcal.normalize(jd); // Month may have changed by the normalization. n = jd.getMonth() - 1; } set(DAY_OF_MONTH, jd.getDayOfMonth()); } set(MONTH, n); } else { int mon = (internalGet(MONTH) + amount) % 12; if (mon < 0) { mon += 12; } set(MONTH, mon); // Keep the day of month in the range. We // don't want to spill over into the next // month; e.g., we don't want jan31 + 1 mo -> // feb31 -> mar3. int monthLen = monthLength(mon); if (internalGet(DAY_OF_MONTH) > monthLen) { set(DAY_OF_MONTH, monthLen); } } } else { int eraIndex = getEraIndex(jdate); CalendarDate transition = null; if (jdate.getYear() == 1) { transition = eras[eraIndex].getSinceDate(); min = transition.getMonth() - 1; } else { if (eraIndex < eras.length - 1) { transition = eras[eraIndex + 1].getSinceDate(); if (transition.getYear() == jdate.getNormalizedYear()) { max = transition.getMonth() - 1; if (transition.getDayOfMonth() == 1) { max--; } } } } if (min == max) { // The year has only one month. No need to // process further. (Showa Gan-nen (year 1) // and the last year have only one month.) return; } int n = getRolledValue(internalGet(field), amount, min, max); set(MONTH, n); if (n == min) { if (!(transition.getMonth() == BaseCalendar.JANUARY && transition.getDayOfMonth() == 1)) { if (jdate.getDayOfMonth() < transition.getDayOfMonth()) { set(DAY_OF_MONTH, transition.getDayOfMonth()); } } } else if (n == max && (transition.getMonth() - 1 == n)) { int dom = transition.getDayOfMonth(); if (jdate.getDayOfMonth() >= dom) { set(DAY_OF_MONTH, dom - 1); } } } return; } case WEEK_OF_YEAR: { int y = jdate.getNormalizedYear(); max = getActualMaximum(WEEK_OF_YEAR); set(DAY_OF_WEEK, internalGet(DAY_OF_WEEK)); // update stamp[field] int woy = internalGet(WEEK_OF_YEAR); int value = woy + amount; if (!isTransitionYear(jdate.getNormalizedYear())) { int year = jdate.getYear(); if (year == getMaximum(YEAR)) { max = getActualMaximum(WEEK_OF_YEAR); } else if (year == getMinimum(YEAR)) { min = getActualMinimum(WEEK_OF_YEAR); max = getActualMaximum(WEEK_OF_YEAR); if (value > min && value < max) { set(WEEK_OF_YEAR, value); return; } } // If the new value is in between min and max // (exclusive), then we can use the value. if (value > min && value < max) { set(WEEK_OF_YEAR, value); return; } long fd = cachedFixedDate; // Make sure that the min week has the current DAY_OF_WEEK long day1 = fd - (7 * (woy - min)); if (year != getMinimum(YEAR)) { if (gcal.getYearFromFixedDate(day1) != y) { min++; } } else { CalendarDate d = jcal.getCalendarDate(Long.MIN_VALUE, getZone()); if (day1 < jcal.getFixedDate(d)) { min++; } } // Make sure the same thing for the max week fd += 7 * (max - internalGet(WEEK_OF_YEAR)); if (gcal.getYearFromFixedDate(fd) != y) { max--; } break; } // Handle transition here. long fd = cachedFixedDate; long day1 = fd - (7 * (woy - min)); // Make sure that the min week has the current DAY_OF_WEEK LocalGregorianCalendar.Date d = getCalendarDate(day1); if (!(d.getEra() == jdate.getEra() && d.getYear() == jdate.getYear())) { min++; } // Make sure the same thing for the max week fd += 7 * (max - woy); jcal.getCalendarDateFromFixedDate(d, fd); if (!(d.getEra() == jdate.getEra() && d.getYear() == jdate.getYear())) { max--; } // value: the new WEEK_OF_YEAR which must be converted // to month and day of month. value = getRolledValue(woy, amount, min, max) - 1; d = getCalendarDate(day1 + value * 7); set(MONTH, d.getMonth() - 1); set(DAY_OF_MONTH, d.getDayOfMonth()); return; } case WEEK_OF_MONTH: { boolean isTransitionYear = isTransitionYear(jdate.getNormalizedYear()); // dow: relative day of week from the first day of week int dow = internalGet(DAY_OF_WEEK) - getFirstDayOfWeek(); if (dow < 0) { dow += 7; } long fd = cachedFixedDate; long month1; // fixed date of the first day (usually 1) of the month int monthLength; // actual month length if (isTransitionYear) { month1 = getFixedDateMonth1(jdate, fd); monthLength = actualMonthLength(); } else { month1 = fd - internalGet(DAY_OF_MONTH) + 1; monthLength = jcal.getMonthLength(jdate); } // the first day of week of the month. long monthDay1st = jcal.getDayOfWeekDateOnOrBefore(month1 + 6, getFirstDayOfWeek()); // if the week has enough days to form a week, the // week starts from the previous month. if ((int)(monthDay1st - month1) >= getMinimalDaysInFirstWeek()) { monthDay1st -= 7; } max = getActualMaximum(field); // value: the new WEEK_OF_MONTH value int value = getRolledValue(internalGet(field), amount, 1, max) - 1; // nfd: fixed date of the rolled date long nfd = monthDay1st + value * 7 + dow; // Unlike WEEK_OF_YEAR, we need to change day of week if the // nfd is out of the month. if (nfd < month1) { nfd = month1; } else if (nfd >= (month1 + monthLength)) { nfd = month1 + monthLength - 1; } set(DAY_OF_MONTH, (int)(nfd - month1) + 1); return; } case DAY_OF_MONTH: { if (!isTransitionYear(jdate.getNormalizedYear())) { max = jcal.getMonthLength(jdate); break; } // TODO: Need to change the spec to be usable DAY_OF_MONTH rolling... // Transition handling. We can't change year and era // values here due to the Calendar roll spec! long month1 = getFixedDateMonth1(jdate, cachedFixedDate); // It may not be a regular month. Convert the date and range to // the relative values, perform the roll, and // convert the result back to the rolled date. int value = getRolledValue((int)(cachedFixedDate - month1), amount, 0, actualMonthLength() - 1); LocalGregorianCalendar.Date d = getCalendarDate(month1 + value); assert getEraIndex(d) == internalGetEra() && d.getYear() == internalGet(YEAR) && d.getMonth()-1 == internalGet(MONTH); set(DAY_OF_MONTH, d.getDayOfMonth()); return; } case DAY_OF_YEAR: { max = getActualMaximum(field); if (!isTransitionYear(jdate.getNormalizedYear())) { break; } // Handle transition. We can't change year and era values // here due to the Calendar roll spec. int value = getRolledValue(internalGet(DAY_OF_YEAR), amount, min, max); long jan0 = cachedFixedDate - internalGet(DAY_OF_YEAR); LocalGregorianCalendar.Date d = getCalendarDate(jan0 + value); assert getEraIndex(d) == internalGetEra() && d.getYear() == internalGet(YEAR); set(MONTH, d.getMonth() - 1); set(DAY_OF_MONTH, d.getDayOfMonth()); return; } case DAY_OF_WEEK: { int normalizedYear = jdate.getNormalizedYear(); if (!isTransitionYear(normalizedYear) && !isTransitionYear(normalizedYear - 1)) { // If the week of year is in the same year, we can // just change DAY_OF_WEEK. int weekOfYear = internalGet(WEEK_OF_YEAR); if (weekOfYear > 1 && weekOfYear < 52) { set(WEEK_OF_YEAR, internalGet(WEEK_OF_YEAR)); max = SATURDAY; break; } } // We need to handle it in a different way around year // boundaries and in the transition year. Note that // changing era and year values violates the roll // rule: not changing larger calendar fields... amount %= 7; if (amount == 0) { return; } long fd = cachedFixedDate; long dowFirst = jcal.getDayOfWeekDateOnOrBefore(fd, getFirstDayOfWeek()); fd += amount; if (fd < dowFirst) { fd += 7; } else if (fd >= dowFirst + 7) { fd -= 7; } LocalGregorianCalendar.Date d = getCalendarDate(fd); set(ERA, getEraIndex(d)); set(d.getYear(), d.getMonth() - 1, d.getDayOfMonth()); return; } case DAY_OF_WEEK_IN_MONTH: { min = 1; // after having normalized, min should be 1. if (!isTransitionYear(jdate.getNormalizedYear())) { int dom = internalGet(DAY_OF_MONTH); int monthLength = jcal.getMonthLength(jdate); int lastDays = monthLength % 7; max = monthLength / 7; int x = (dom - 1) % 7; if (x < lastDays) { max++; } set(DAY_OF_WEEK, internalGet(DAY_OF_WEEK)); break; } // Transition year handling. long fd = cachedFixedDate; long month1 = getFixedDateMonth1(jdate, fd); int monthLength = actualMonthLength(); int lastDays = monthLength % 7; max = monthLength / 7; int x = (int)(fd - month1) % 7; if (x < lastDays) { max++; } int value = getRolledValue(internalGet(field), amount, min, max) - 1; fd = month1 + value * 7 + x; LocalGregorianCalendar.Date d = getCalendarDate(fd); set(DAY_OF_MONTH, d.getDayOfMonth()); return; } } set(field, getRolledValue(internalGet(field), amount, min, max)); }
// in java-util/JapaneseImperialCalendar.java
protected void computeTime() { // In non-lenient mode, perform brief checking of calendar // fields which have been set externally. Through this // checking, the field values are stored in originalFields[] // to see if any of them are normalized later. if (!isLenient()) { if (originalFields == null) { originalFields = new int[FIELD_COUNT]; } for (int field = 0; field < FIELD_COUNT; field++) { int value = internalGet(field); if (isExternallySet(field)) { // Quick validation for any out of range values if (value < getMinimum(field) || value > getMaximum(field)) { throw new IllegalArgumentException(getFieldName(field)); } } originalFields[field] = value; } } // Let the super class determine which calendar fields to be // used to calculate the time. int fieldMask = selectFields(); int year; int era; if (isSet(ERA)) { era = internalGet(ERA); year = isSet(YEAR) ? internalGet(YEAR) : 1; } else { if (isSet(YEAR)) { era = eras.length - 1; year = internalGet(YEAR); } else { // Equivalent to 1970 (Gregorian) era = SHOWA; year = 45; } } // Calculate the time of day. We rely on the convention that // an UNSET field has 0. long timeOfDay = 0; if (isFieldSet(fieldMask, HOUR_OF_DAY)) { timeOfDay += (long) internalGet(HOUR_OF_DAY); } else { timeOfDay += internalGet(HOUR); // The default value of AM_PM is 0 which designates AM. if (isFieldSet(fieldMask, AM_PM)) { timeOfDay += 12 * internalGet(AM_PM); } } timeOfDay *= 60; timeOfDay += internalGet(MINUTE); timeOfDay *= 60; timeOfDay += internalGet(SECOND); timeOfDay *= 1000; timeOfDay += internalGet(MILLISECOND); // Convert the time of day to the number of days and the // millisecond offset from midnight. long fixedDate = timeOfDay / ONE_DAY; timeOfDay %= ONE_DAY; while (timeOfDay < 0) { timeOfDay += ONE_DAY; --fixedDate; } // Calculate the fixed date since January 1, 1 (Gregorian). fixedDate += getFixedDate(era, year, fieldMask); // millis represents local wall-clock time in milliseconds. long millis = (fixedDate - EPOCH_OFFSET) * ONE_DAY + timeOfDay; // Compute the time zone offset and DST offset. There are two potential // ambiguities here. We'll assume a 2:00 am (wall time) switchover time // for discussion purposes here. // 1. The transition into DST. Here, a designated time of 2:00 am - 2:59 am // can be in standard or in DST depending. However, 2:00 am is an invalid // representation (the representation jumps from 1:59:59 am Std to 3:00:00 am DST). // We assume standard time. // 2. The transition out of DST. Here, a designated time of 1:00 am - 1:59 am // can be in standard or DST. Both are valid representations (the rep // jumps from 1:59:59 DST to 1:00:00 Std). // Again, we assume standard time. // We use the TimeZone object, unless the user has explicitly set the ZONE_OFFSET // or DST_OFFSET fields; then we use those fields. TimeZone zone = getZone(); if (zoneOffsets == null) { zoneOffsets = new int[2]; } int tzMask = fieldMask & (ZONE_OFFSET_MASK|DST_OFFSET_MASK); if (tzMask != (ZONE_OFFSET_MASK|DST_OFFSET_MASK)) { if (zone instanceof ZoneInfo) { ((ZoneInfo)zone).getOffsetsByWall(millis, zoneOffsets); } else { zone.getOffsets(millis - zone.getRawOffset(), zoneOffsets); } } if (tzMask != 0) { if (isFieldSet(tzMask, ZONE_OFFSET)) { zoneOffsets[0] = internalGet(ZONE_OFFSET); } if (isFieldSet(tzMask, DST_OFFSET)) { zoneOffsets[1] = internalGet(DST_OFFSET); } } // Adjust the time zone offset values to get the UTC time. millis -= zoneOffsets[0] + zoneOffsets[1]; // Set this calendar's time in milliseconds time = millis; int mask = computeFields(fieldMask | getSetStateFields(), tzMask); if (!isLenient()) { for (int field = 0; field < FIELD_COUNT; field++) { if (!isExternallySet(field)) { continue; } if (originalFields[field] != internalGet(field)) { int wrongValue = internalGet(field); // Restore the original field values System.arraycopy(originalFields, 0, fields, 0, fields.length); throw new IllegalArgumentException(getFieldName(field) + "=" + wrongValue + ", expected " + originalFields[field]); } } } setFieldsNormalized(mask); }
// in java-util/SimpleTimeZone.java
public int getOffset(int era, int year, int month, int day, int dayOfWeek, int millis) { if (era != GregorianCalendar.AD && era != GregorianCalendar.BC) { throw new IllegalArgumentException("Illegal era " + era); } int y = year; if (era == GregorianCalendar.BC) { // adjust y with the GregorianCalendar-style year numbering. y = 1 - y; } // If the year isn't representable with the 64-bit long // integer in milliseconds, convert the year to an // equivalent year. This is required to pass some JCK test cases // which are actually useless though because the specified years // can't be supported by the Java time system. if (y >= 292278994) { y = 2800 + y % 2800; } else if (y <= -292269054) { // y %= 28 also produces an equivalent year, but positive // year numbers would be convenient to use the UNIX cal // command. y = (int) CalendarUtils.mod((long) y, 28); } // convert year to its 1-based month value int m = month + 1; // First, calculate time as a Gregorian date. BaseCalendar cal = gcal; BaseCalendar.Date cdate = (BaseCalendar.Date) cal.newCalendarDate(TimeZone.NO_TIMEZONE); cdate.setDate(y, m, day); long time = cal.getTime(cdate); // normalize cdate time += millis - rawOffset; // UTC time // If the time value represents a time before the default // Gregorian cutover, recalculate time using the Julian // calendar system. For the Julian calendar system, the // normalized year numbering is ..., -2 (BCE 2), -1 (BCE 1), // 1, 2 ... which is different from the GregorianCalendar // style year numbering (..., -1, 0 (BCE 1), 1, 2, ...). if (time < GregorianCalendar.DEFAULT_GREGORIAN_CUTOVER) { cal = (BaseCalendar) CalendarSystem.forName("julian"); cdate = (BaseCalendar.Date) cal.newCalendarDate(TimeZone.NO_TIMEZONE); cdate.setNormalizedDate(y, m, day); time = cal.getTime(cdate) + millis - rawOffset; } if ((cdate.getNormalizedYear() != y) || (cdate.getMonth() != m) || (cdate.getDayOfMonth() != day) // The validation should be cdate.getDayOfWeek() == // dayOfWeek. However, we don't check dayOfWeek for // compatibility. || (dayOfWeek < Calendar.SUNDAY || dayOfWeek > Calendar.SATURDAY) || (millis < 0 || millis >= (24*60*60*1000))) { throw new IllegalArgumentException(); } if (!useDaylight || year < startYear || era != GregorianCalendar.CE) { return rawOffset; } return getOffset(cal, cdate, y, time); }
// in java-util/SimpleTimeZone.java
public void setDSTSavings(int millisSavedDuringDST) { if (millisSavedDuringDST <= 0) { throw new IllegalArgumentException("Illegal daylight saving value: " + millisSavedDuringDST); } dstSavings = millisSavedDuringDST; }
// in java-util/SimpleTimeZone.java
private void decodeStartRule() { useDaylight = (startDay != 0) && (endDay != 0); if (startDay != 0) { if (startMonth < Calendar.JANUARY || startMonth > Calendar.DECEMBER) { throw new IllegalArgumentException( "Illegal start month " + startMonth); } if (startTime < 0 || startTime > millisPerDay) { throw new IllegalArgumentException( "Illegal start time " + startTime); } if (startDayOfWeek == 0) { startMode = DOM_MODE; } else { if (startDayOfWeek > 0) { startMode = DOW_IN_MONTH_MODE; } else { startDayOfWeek = -startDayOfWeek; if (startDay > 0) { startMode = DOW_GE_DOM_MODE; } else { startDay = -startDay; startMode = DOW_LE_DOM_MODE; } } if (startDayOfWeek > Calendar.SATURDAY) { throw new IllegalArgumentException( "Illegal start day of week " + startDayOfWeek); } } if (startMode == DOW_IN_MONTH_MODE) { if (startDay < -5 || startDay > 5) { throw new IllegalArgumentException( "Illegal start day of week in month " + startDay); } } else if (startDay < 1 || startDay > staticMonthLength[startMonth]) { throw new IllegalArgumentException( "Illegal start day " + startDay); } } }
// in java-util/SimpleTimeZone.java
private void decodeEndRule() { useDaylight = (startDay != 0) && (endDay != 0); if (endDay != 0) { if (endMonth < Calendar.JANUARY || endMonth > Calendar.DECEMBER) { throw new IllegalArgumentException( "Illegal end month " + endMonth); } if (endTime < 0 || endTime > millisPerDay) { throw new IllegalArgumentException( "Illegal end time " + endTime); } if (endDayOfWeek == 0) { endMode = DOM_MODE; } else { if (endDayOfWeek > 0) { endMode = DOW_IN_MONTH_MODE; } else { endDayOfWeek = -endDayOfWeek; if (endDay > 0) { endMode = DOW_GE_DOM_MODE; } else { endDay = -endDay; endMode = DOW_LE_DOM_MODE; } } if (endDayOfWeek > Calendar.SATURDAY) { throw new IllegalArgumentException( "Illegal end day of week " + endDayOfWeek); } } if (endMode == DOW_IN_MONTH_MODE) { if (endDay < -5 || endDay > 5) { throw new IllegalArgumentException( "Illegal end day of week in month " + endDay); } } else if (endDay < 1 || endDay > staticMonthLength[endMonth]) { throw new IllegalArgumentException( "Illegal end day " + endDay); } } }
// in java-util/UUID.java
public static UUID fromString(String name) { String[] components = name.split("-"); if (components.length != 5) throw new IllegalArgumentException("Invalid UUID string: "+name); for (int i=0; i<5; i++) components[i] = "0x"+components[i]; long mostSigBits = Long.decode(components[0]).longValue(); mostSigBits <<= 16; mostSigBits |= Long.decode(components[1]).longValue(); mostSigBits <<= 16; mostSigBits |= Long.decode(components[2]).longValue(); long leastSigBits = Long.decode(components[3]).longValue(); leastSigBits <<= 48; leastSigBits |= Long.decode(components[4]).longValue(); return new UUID(mostSigBits, leastSigBits); }
// in java-util/ResourceBundle.java
private static ResourceBundle getBundleImpl(String baseName, Locale locale, ClassLoader loader, Control control) { if (locale == null || control == null) { throw new NullPointerException(); } // We create a CacheKey here for use by this call. The base // name and loader will never change during the bundle loading // process. We have to make sure that the locale is set before // using it as a cache key. CacheKey cacheKey = new CacheKey(baseName, locale, loader); ResourceBundle bundle = null; // Quick lookup of the cache. BundleReference bundleRef = cacheList.get(cacheKey); if (bundleRef != null) { bundle = bundleRef.get(); bundleRef = null; } // If this bundle and all of its parents are valid (not expired), // then return this bundle. If any of the bundles is expired, we // don't call control.needsReload here but instead drop into the // complete loading process below. if (isValidBundle(bundle) && hasValidParentChain(bundle)) { return bundle; } // No valid bundle was found in the cache, so we need to load the // resource bundle and its parents. boolean isKnownControl = (control == Control.INSTANCE) || (control instanceof SingleFormatControl); List<String> formats = control.getFormats(baseName); if (!isKnownControl && !checkList(formats)) { throw new IllegalArgumentException("Invalid Control: getFormats"); } ResourceBundle baseBundle = null; for (Locale targetLocale = locale; targetLocale != null; targetLocale = control.getFallbackLocale(baseName, targetLocale)) { List<Locale> candidateLocales = control.getCandidateLocales(baseName, targetLocale); if (!isKnownControl && !checkList(candidateLocales)) { throw new IllegalArgumentException("Invalid Control: getCandidateLocales"); } bundle = findBundle(cacheKey, candidateLocales, formats, 0, control, baseBundle); // If the loaded bundle is the base bundle and exactly for the // requested locale or the only candidate locale, then take the // bundle as the resulting one. If the loaded bundle is the base // bundle, it's put on hold until we finish processing all // fallback locales. if (isValidBundle(bundle)) { boolean isBaseBundle = Locale.ROOT.equals(bundle.locale); if (!isBaseBundle || bundle.locale.equals(locale) || (candidateLocales.size() == 1 && bundle.locale.equals(candidateLocales.get(0)))) { break; } // If the base bundle has been loaded, keep the reference in // baseBundle so that we can avoid any redundant loading in case // the control specify not to cache bundles. if (isBaseBundle && baseBundle == null) { baseBundle = bundle; } } } if (bundle == null) { if (baseBundle == null) { throwMissingResourceException(baseName, locale, cacheKey.getCause()); } bundle = baseBundle; } return bundle; }
// in java-util/ResourceBundle.java
private static final void setExpirationTime(CacheKey cacheKey, Control control) { long ttl = control.getTimeToLive(cacheKey.getName(), cacheKey.getLocale()); if (ttl >= 0) { // If any expiration time is specified, set the time to be // expired in the cache. long now = System.currentTimeMillis(); cacheKey.loadTime = now; cacheKey.expirationTime = now + ttl; } else if (ttl >= Control.TTL_NO_EXPIRATION_CONTROL) { cacheKey.expirationTime = ttl; } else { throw new IllegalArgumentException("Invalid Control: TTL=" + ttl); } }
// in java-util/ResourceBundle.java
public static final Control getControl(List<String> formats) { if (formats.equals(Control.FORMAT_PROPERTIES)) { return SingleFormatControl.PROPERTIES_ONLY; } if (formats.equals(Control.FORMAT_CLASS)) { return SingleFormatControl.CLASS_ONLY; } if (formats.equals(Control.FORMAT_DEFAULT)) { return Control.INSTANCE; } throw new IllegalArgumentException(); }
// in java-util/ResourceBundle.java
public static final Control getNoFallbackControl(List<String> formats) { if (formats.equals(Control.FORMAT_DEFAULT)) { return NoFallbackControl.NO_FALLBACK; } if (formats.equals(Control.FORMAT_PROPERTIES)) { return NoFallbackControl.PROPERTIES_ONLY_NO_FALLBACK; } if (formats.equals(Control.FORMAT_CLASS)) { return NoFallbackControl.CLASS_ONLY_NO_FALLBACK; } throw new IllegalArgumentException(); }
// in java-util/TreeMap.java
public final V put(K key, V value) { if (!inRange(key)) throw new IllegalArgumentException("key out of range"); return m.put(key, value); }
// in java-util/TreeMap.java
public NavigableMap<K,V> subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) { if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range"); if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey out of range"); return new AscendingSubMap(m, false, fromKey, fromInclusive, false, toKey, toInclusive); }
// in java-util/TreeMap.java
public NavigableMap<K,V> headMap(K toKey, boolean inclusive) { if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range"); return new AscendingSubMap(m, fromStart, lo, loInclusive, false, toKey, inclusive); }
// in java-util/TreeMap.java
public NavigableMap<K,V> tailMap(K fromKey, boolean inclusive){ if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range"); return new AscendingSubMap(m, false, fromKey, inclusive, toEnd, hi, hiInclusive); }
// in java-util/TreeMap.java
public NavigableMap<K,V> subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) { if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range"); if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey out of range"); return new DescendingSubMap(m, false, toKey, toInclusive, false, fromKey, fromInclusive); }
// in java-util/TreeMap.java
public NavigableMap<K,V> headMap(K toKey, boolean inclusive) { if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range"); return new DescendingSubMap(m, false, toKey, inclusive, toEnd, hi, hiInclusive); }
// in java-util/TreeMap.java
public NavigableMap<K,V> tailMap(K fromKey, boolean inclusive){ if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range"); return new DescendingSubMap(m, fromStart, lo, loInclusive, false, fromKey, inclusive); }
// in java-util/Currency.java
private static Currency getInstance(String currencyCode, int defaultFractionDigits) { synchronized (instances) { // Try to look up the currency code in the instances table. // This does the null pointer check as a side effect. // Also, if there already is an entry, the currencyCode must be valid. Currency instance = (Currency) instances.get(currencyCode); if (instance != null) { return instance; } if (defaultFractionDigits == Integer.MIN_VALUE) { // Currency code not internally generated, need to verify first // A currency code must have 3 characters and exist in the main table // or in the list of other currencies. if (currencyCode.length() != 3) { throw new IllegalArgumentException(); } char char1 = currencyCode.charAt(0); char char2 = currencyCode.charAt(1); int tableEntry = getMainTableEntry(char1, char2); if ((tableEntry & COUNTRY_TYPE_MASK) == SIMPLE_CASE_COUNTRY_MASK && tableEntry != INVALID_COUNTRY_ENTRY && currencyCode.charAt(2) - 'A' == (tableEntry & SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK)) { defaultFractionDigits = (tableEntry & SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK) >> SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT; } else { // Check for '-' separately so we don't get false hits in the table. if (currencyCode.charAt(2) == '-') { throw new IllegalArgumentException(); } int index = otherCurrencies.indexOf(currencyCode); if (index == -1) { throw new IllegalArgumentException(); } defaultFractionDigits = otherCurrenciesDFD[index / 4]; } } instance = new Currency(currencyCode, defaultFractionDigits); instances.put(currencyCode, instance); return instance; } }
// in java-util/Currency.java
public static Currency getInstance(Locale locale) { String country = locale.getCountry(); if (country == null) { throw new NullPointerException(); } if (country.length() != 2) { throw new IllegalArgumentException(); } char char1 = country.charAt(0); char char2 = country.charAt(1); int tableEntry = getMainTableEntry(char1, char2); if ((tableEntry & COUNTRY_TYPE_MASK) == SIMPLE_CASE_COUNTRY_MASK && tableEntry != INVALID_COUNTRY_ENTRY) { char finalChar = (char) ((tableEntry & SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK) + 'A'); int defaultFractionDigits = (tableEntry & SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK) >> SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT; StringBuffer sb = new StringBuffer(country); sb.append(finalChar); return getInstance(sb.toString(), defaultFractionDigits); } else { // special cases if (tableEntry == INVALID_COUNTRY_ENTRY) { throw new IllegalArgumentException(); } if (tableEntry == COUNTRY_WITHOUT_CURRENCY_ENTRY) { return null; } else { int index = (tableEntry & SPECIAL_CASE_COUNTRY_INDEX_MASK) - SPECIAL_CASE_COUNTRY_INDEX_DELTA; if (scCutOverTimes[index] == Long.MAX_VALUE || System.currentTimeMillis() < scCutOverTimes[index]) { return getInstance(scOldCurrencies[index], scOldCurrenciesDFD[index]); } else { return getInstance(scNewCurrencies[index], scNewCurrenciesDFD[index]); } } } }
// in java-util/Currency.java
private static int getMainTableEntry(char char1, char char2) { if (char1 < 'A' || char1 > 'Z' || char2 < 'A' || char2 > 'Z') { throw new IllegalArgumentException(); } return mainTable.charAt((char1 - 'A') * A_TO_Z + (char2 - 'A')); }
// in java-util/Scanner.java
private static Readable makeReadable(ReadableByteChannel source, String charsetName) { if (source == null) throw new NullPointerException("source"); if (!Charset.isSupported(charsetName)) throw new IllegalArgumentException(charsetName); return Channels.newReader(source, charsetName); }
// in java-util/Scanner.java
public Scanner useRadix(int radix) { if ((radix < Character.MIN_RADIX) || (radix > Character.MAX_RADIX)) throw new IllegalArgumentException("radix:"+radix); if (this.defaultRadix == radix) return this; this.defaultRadix = radix; // Force rebuilding and recompilation of radix dependent patterns integerPattern = null; return this; }
// in java-util/Scanner.java
public String findWithinHorizon(Pattern pattern, int horizon) { ensureOpen(); if (pattern == null) throw new NullPointerException(); if (horizon < 0) throw new IllegalArgumentException("horizon < 0"); clearCaches(); // Search for the pattern while (true) { String token = findPatternInBuffer(pattern, horizon); if (token != null) { matchValid = true; return token; } if (needInput) readInput(); else break; // up to end of input } return null; }
// in java-util/Timer.java
public void schedule(TimerTask task, long delay) { if (delay < 0) throw new IllegalArgumentException("Negative delay."); sched(task, System.currentTimeMillis()+delay, 0); }
// in java-util/Timer.java
public void schedule(TimerTask task, long delay, long period) { if (delay < 0) throw new IllegalArgumentException("Negative delay."); if (period <= 0) throw new IllegalArgumentException("Non-positive period."); sched(task, System.currentTimeMillis()+delay, -period); }
// in java-util/Timer.java
public void schedule(TimerTask task, Date firstTime, long period) { if (period <= 0) throw new IllegalArgumentException("Non-positive period."); sched(task, firstTime.getTime(), -period); }
// in java-util/Timer.java
public void scheduleAtFixedRate(TimerTask task, long delay, long period) { if (delay < 0) throw new IllegalArgumentException("Negative delay."); if (period <= 0) throw new IllegalArgumentException("Non-positive period."); sched(task, System.currentTimeMillis()+delay, period); }
// in java-util/Timer.java
public void scheduleAtFixedRate(TimerTask task, Date firstTime, long period) { if (period <= 0) throw new IllegalArgumentException("Non-positive period."); sched(task, firstTime.getTime(), period); }
// in java-util/Timer.java
private void sched(TimerTask task, long time, long period) { if (time < 0) throw new IllegalArgumentException("Illegal execution time."); synchronized(queue) { if (!thread.newTasksMayBeScheduled) throw new IllegalStateException("Timer already cancelled."); synchronized(task.lock) { if (task.state != TimerTask.VIRGIN) throw new IllegalStateException( "Task already scheduled or cancelled"); task.nextExecutionTime = time; task.period = period; task.state = TimerTask.SCHEDULED; } queue.add(task); if (queue.getMin() == task) queue.notify(); } }
// in java-util/Random.java
public int nextInt(int n) { if (n <= 0) throw new IllegalArgumentException("n must be positive"); if ((n & -n) == n) // i.e., n is a power of 2 return (int)((n * (long)next(31)) >> 31); int bits, val; do { bits = next(31); val = bits % n; } while (bits - val + (n-1) < 0); return val; }
// in java-util/AbstractQueue.java
public boolean addAll(Collection<? extends E> c) { if (c == null) throw new NullPointerException(); if (c == this) throw new IllegalArgumentException(); boolean modified = false; Iterator<? extends E> e = c.iterator(); while (e.hasNext()) { if (add(e.next())) modified = true; } return modified; }
// in java-util/Arrays.java
private static void rangeCheck(int arrayLen, int fromIndex, int toIndex) { if (fromIndex > toIndex) throw new IllegalArgumentException("fromIndex(" + fromIndex + ") > toIndex(" + toIndex+")"); if (fromIndex < 0) throw new ArrayIndexOutOfBoundsException(fromIndex); if (toIndex > arrayLen) throw new ArrayIndexOutOfBoundsException(toIndex); }
// in java-util/Arrays.java
public static <T,U> T[] copyOfRange(U[] original, int from, int to, Class<? extends T[]> newType) { int newLength = to - from; if (newLength < 0) throw new IllegalArgumentException(from + " > " + to); T[] copy = ((Object)newType == (Object)Object[].class) ? (T[]) new Object[newLength] : (T[]) Array.newInstance(newType.getComponentType(), newLength); System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength)); return copy; }
// in java-util/Arrays.java
public static byte[] copyOfRange(byte[] original, int from, int to) { int newLength = to - from; if (newLength < 0) throw new IllegalArgumentException(from + " > " + to); byte[] copy = new byte[newLength]; System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength)); return copy; }
// in java-util/Arrays.java
public static short[] copyOfRange(short[] original, int from, int to) { int newLength = to - from; if (newLength < 0) throw new IllegalArgumentException(from + " > " + to); short[] copy = new short[newLength]; System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength)); return copy; }
// in java-util/Arrays.java
public static int[] copyOfRange(int[] original, int from, int to) { int newLength = to - from; if (newLength < 0) throw new IllegalArgumentException(from + " > " + to); int[] copy = new int[newLength]; System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength)); return copy; }
// in java-util/Arrays.java
public static long[] copyOfRange(long[] original, int from, int to) { int newLength = to - from; if (newLength < 0) throw new IllegalArgumentException(from + " > " + to); long[] copy = new long[newLength]; System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength)); return copy; }
// in java-util/Arrays.java
public static char[] copyOfRange(char[] original, int from, int to) { int newLength = to - from; if (newLength < 0) throw new IllegalArgumentException(from + " > " + to); char[] copy = new char[newLength]; System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength)); return copy; }
// in java-util/Arrays.java
public static float[] copyOfRange(float[] original, int from, int to) { int newLength = to - from; if (newLength < 0) throw new IllegalArgumentException(from + " > " + to); float[] copy = new float[newLength]; System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength)); return copy; }
// in java-util/Arrays.java
public static double[] copyOfRange(double[] original, int from, int to) { int newLength = to - from; if (newLength < 0) throw new IllegalArgumentException(from + " > " + to); double[] copy = new double[newLength]; System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength)); return copy; }
// in java-util/Arrays.java
public static boolean[] copyOfRange(boolean[] original, int from, int to) { int newLength = to - from; if (newLength < 0) throw new IllegalArgumentException(from + " > " + to); boolean[] copy = new boolean[newLength]; System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength)); return copy; }
// in java-util/EnumSet.java
public static <E extends Enum<E>> EnumSet<E> copyOf(Collection<E> c) { if (c instanceof EnumSet) { return ((EnumSet<E>)c).clone(); } else { if (c.isEmpty()) throw new IllegalArgumentException("Collection is empty"); Iterator<E> i = c.iterator(); E first = i.next(); EnumSet<E> result = EnumSet.of(first); while (i.hasNext()) result.add(i.next()); return result; } }
// in java-util/EnumSet.java
public static <E extends Enum<E>> EnumSet<E> range(E from, E to) { if (from.compareTo(to) > 0) throw new IllegalArgumentException(from + " > " + to); EnumSet<E> result = noneOf(from.getDeclaringClass()); result.addRange(from, to); return result; }
// in java-util/TimeZone.java
public String getDisplayName(boolean daylight, int style, Locale locale) { if (style != SHORT && style != LONG) { throw new IllegalArgumentException("Illegal style: " + style); } String id = getID(); String[] names = getDisplayNames(id, locale); if (names == null) { if (id.startsWith("GMT")) { char sign = id.charAt(3); if (sign == '+' || sign == '-') { return id; } } int offset = getRawOffset(); if (daylight) { offset += getDSTSavings(); } return ZoneInfoFile.toCustomID(offset); } int index = daylight ? 3 : 1; if (style == SHORT) { index++; } return names[index]; }
// in java-util/Properties.java
private String loadConvert (char[] in, int off, int len, char[] convtBuf) { if (convtBuf.length < len) { int newLen = len * 2; if (newLen < 0) { newLen = Integer.MAX_VALUE; } convtBuf = new char[newLen]; } char aChar; char[] out = convtBuf; int outLen = 0; int end = off + len; while (off < end) { aChar = in[off++]; if (aChar == '\\') { aChar = in[off++]; if(aChar == 'u') { // Read the xxxx int value=0; for (int i=0; i<4; i++) { aChar = in[off++]; switch (aChar) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': value = (value << 4) + aChar - '0'; break; case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': value = (value << 4) + 10 + aChar - 'a'; break; case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': value = (value << 4) + 10 + aChar - 'A'; break; default: throw new IllegalArgumentException( "Malformed \\uxxxx encoding."); } } out[outLen++] = (char)value; } else { if (aChar == 't') aChar = '\t'; else if (aChar == 'r') aChar = '\r'; else if (aChar == 'n') aChar = '\n'; else if (aChar == 'f') aChar = '\f'; out[outLen++] = aChar; } } else { out[outLen++] = (char)aChar; } } return new String (out, 0, outLen); }
// in java-util/PropertyPermission.java
private void init(int mask) { if ((mask & ALL) != mask) throw new IllegalArgumentException("invalid actions mask"); if (mask == NONE) throw new IllegalArgumentException("invalid actions mask"); if (getName() == null) throw new NullPointerException("name can't be null"); this.mask = mask; }
// in java-util/PropertyPermission.java
private static int getMask(String actions) { int mask = NONE; if (actions == null) { return mask; } // Check against use of constants (used heavily within the JDK) if (actions == SecurityConstants.PROPERTY_READ_ACTION) { return READ; } if (actions == SecurityConstants.PROPERTY_WRITE_ACTION) { return WRITE; } else if (actions == SecurityConstants.PROPERTY_RW_ACTION) { return READ|WRITE; } char[] a = actions.toCharArray(); int i = a.length - 1; if (i < 0) return mask; while (i != -1) { char c; // skip whitespace while ((i!=-1) && ((c = a[i]) == ' ' || c == '\r' || c == '\n' || c == '\f' || c == '\t')) i--; // check for the known strings int matchlen; if (i >= 3 && (a[i-3] == 'r' || a[i-3] == 'R') && (a[i-2] == 'e' || a[i-2] == 'E') && (a[i-1] == 'a' || a[i-1] == 'A') && (a[i] == 'd' || a[i] == 'D')) { matchlen = 4; mask |= READ; } else if (i >= 4 && (a[i-4] == 'w' || a[i-4] == 'W') && (a[i-3] == 'r' || a[i-3] == 'R') && (a[i-2] == 'i' || a[i-2] == 'I') && (a[i-1] == 't' || a[i-1] == 'T') && (a[i] == 'e' || a[i] == 'E')) { matchlen = 5; mask |= WRITE; } else { // parse error throw new IllegalArgumentException( "invalid permission: " + actions); } // make sure we didn't just match the tail of a word // like "ackbarfaccept". Also, skip to the comma. boolean seencomma = false; while (i >= matchlen && !seencomma) { switch(a[i-matchlen]) { case ',': seencomma = true; /*FALLTHROUGH*/ case ' ': case '\r': case '\n': case '\f': case '\t': break; default: throw new IllegalArgumentException( "invalid permission: " + actions); } i--; } // point i at the location of the comma minus one (or -1). i -= matchlen; } return mask; }
// in java-util/PropertyPermission.java
public void add(Permission permission) { if (! (permission instanceof PropertyPermission)) throw new IllegalArgumentException("invalid permission: "+ permission); if (isReadOnly()) throw new SecurityException( "attempt to add a Permission to a readonly PermissionCollection"); PropertyPermission pp = (PropertyPermission) permission; String propName = pp.getName(); synchronized (this) { PropertyPermission existing = (PropertyPermission) perms.get(propName); if (existing != null) { int oldMask = existing.getMask(); int newMask = pp.getMask(); if (oldMask != newMask) { int effective = oldMask | newMask; String actions = PropertyPermission.getActions(effective); perms.put(propName, new PropertyPermission(propName, actions)); } } else { perms.put(propName, permission); } } if (!all_allowed) { if (propName.equals("*")) all_allowed = true; } }
// in java-util/Collections.java
public static <T> List<T> nCopies(int n, T o) { if (n < 0) throw new IllegalArgumentException("List length = " + n); return new CopiesList<T>(n, o); }
// in java-util/Collections.java
public List<E> subList(int fromIndex, int toIndex) { if (fromIndex < 0) throw new IndexOutOfBoundsException("fromIndex = " + fromIndex); if (toIndex > n) throw new IndexOutOfBoundsException("toIndex = " + toIndex); if (fromIndex > toIndex) throw new IllegalArgumentException("fromIndex(" + fromIndex + ") > toIndex(" + toIndex + ")"); return new CopiesList(toIndex - fromIndex, element); }
// in java-util/Calendar.java
boolean checkDisplayNameParams(int field, int style, int minStyle, int maxStyle, Locale locale, int fieldMask) { if (field < 0 || field >= fields.length || style < minStyle || style > maxStyle) { throw new IllegalArgumentException(); } if (locale == null) { throw new NullPointerException(); } return isFieldSet(fieldMask, field); }
// in java-util/GregorianCalendar.java
public void add(int field, int amount) { // If amount == 0, do nothing even the given field is out of // range. This is tested by JCK. if (amount == 0) { return; // Do nothing! } if (field < 0 || field >= ZONE_OFFSET) { throw new IllegalArgumentException(); } // Sync the time and calendar fields. complete(); if (field == YEAR) { int year = internalGet(YEAR); if (internalGetEra() == CE) { year += amount; if (year > 0) { set(YEAR, year); } else { // year <= 0 set(YEAR, 1 - year); // if year == 0, you get 1 BCE. set(ERA, BCE); } } else { // era == BCE year -= amount; if (year > 0) { set(YEAR, year); } else { // year <= 0 set(YEAR, 1 - year); // if year == 0, you get 1 CE set(ERA, CE); } } pinDayOfMonth(); } else if (field == MONTH) { int month = internalGet(MONTH) + amount; int year = internalGet(YEAR); int y_amount; if (month >= 0) { y_amount = month/12; } else { y_amount = (month+1)/12 - 1; } if (y_amount != 0) { if (internalGetEra() == CE) { year += y_amount; if (year > 0) { set(YEAR, year); } else { // year <= 0 set(YEAR, 1 - year); // if year == 0, you get 1 BCE set(ERA, BCE); } } else { // era == BCE year -= y_amount; if (year > 0) { set(YEAR, year); } else { // year <= 0 set(YEAR, 1 - year); // if year == 0, you get 1 CE set(ERA, CE); } } } if (month >= 0) { set(MONTH, (int) (month % 12)); } else { // month < 0 month %= 12; if (month < 0) { month += 12; } set(MONTH, JANUARY + month); } pinDayOfMonth(); } else if (field == ERA) { int era = internalGet(ERA) + amount; if (era < 0) { era = 0; } if (era > 1) { era = 1; } set(ERA, era); } else { long delta = amount; long timeOfDay = 0; switch (field) { // Handle the time fields here. Convert the given // amount to milliseconds and call setTimeInMillis. case HOUR: case HOUR_OF_DAY: delta *= 60 * 60 * 1000; // hours to minutes break; case MINUTE: delta *= 60 * 1000; // minutes to seconds break; case SECOND: delta *= 1000; // seconds to milliseconds break; case MILLISECOND: break; // Handle week, day and AM_PM fields which involves // time zone offset change adjustment. Convert the // given amount to the number of days. case WEEK_OF_YEAR: case WEEK_OF_MONTH: case DAY_OF_WEEK_IN_MONTH: delta *= 7; break; case DAY_OF_MONTH: // synonym of DATE case DAY_OF_YEAR: case DAY_OF_WEEK: break; case AM_PM: // Convert the amount to the number of days (delta) // and +12 or -12 hours (timeOfDay). delta = amount / 2; timeOfDay = 12 * (amount % 2); break; } // The time fields don't require time zone offset change // adjustment. if (field >= HOUR) { setTimeInMillis(time + delta); return; } // The rest of the fields (week, day or AM_PM fields) // require time zone offset (both GMT and DST) change // adjustment. // Translate the current time to the fixed date and time // of the day. long fd = getCurrentFixedDate(); timeOfDay += internalGet(HOUR_OF_DAY); timeOfDay *= 60; timeOfDay += internalGet(MINUTE); timeOfDay *= 60; timeOfDay += internalGet(SECOND); timeOfDay *= 1000; timeOfDay += internalGet(MILLISECOND); if (timeOfDay >= ONE_DAY) { fd++; timeOfDay -= ONE_DAY; } else if (timeOfDay < 0) { fd--; timeOfDay += ONE_DAY; } fd += delta; // fd is the expected fixed date after the calculation int zoneOffset = internalGet(ZONE_OFFSET) + internalGet(DST_OFFSET); setTimeInMillis((fd - EPOCH_OFFSET) * ONE_DAY + timeOfDay - zoneOffset); zoneOffset -= internalGet(ZONE_OFFSET) + internalGet(DST_OFFSET); // If the time zone offset has changed, then adjust the difference. if (zoneOffset != 0) { setTimeInMillis(time + zoneOffset); long fd2 = getCurrentFixedDate(); // If the adjustment has changed the date, then take // the previous one. if (fd2 != fd) { setTimeInMillis(time - zoneOffset); } } } }
// in java-util/GregorianCalendar.java
public void roll(int field, int amount) { // If amount == 0, do nothing even the given field is out of // range. This is tested by JCK. if (amount == 0) { return; } if (field < 0 || field >= ZONE_OFFSET) { throw new IllegalArgumentException(); } // Sync the time and calendar fields. complete(); int min = getMinimum(field); int max = getMaximum(field); switch (field) { case AM_PM: case ERA: case YEAR: case MINUTE: case SECOND: case MILLISECOND: // These fields are handled simply, since they have fixed minima // and maxima. The field DAY_OF_MONTH is almost as simple. Other // fields are complicated, since the range within they must roll // varies depending on the date. break; case HOUR: case HOUR_OF_DAY: { int unit = max + 1; // 12 or 24 hours int h = internalGet(field); int nh = (h + amount) % unit; if (nh < 0) { nh += unit; } time += ONE_HOUR * (nh - h); // The day might have changed, which could happen if // the daylight saving time transition brings it to // the next day, although it's very unlikely. But we // have to make sure not to change the larger fields. CalendarDate d = calsys.getCalendarDate(time, getZone()); if (internalGet(DAY_OF_MONTH) != d.getDayOfMonth()) { d.setDate(internalGet(YEAR), internalGet(MONTH) + 1, internalGet(DAY_OF_MONTH)); if (field == HOUR) { assert (internalGet(AM_PM) == PM); d.addHours(+12); // restore PM } time = calsys.getTime(d); } int hourOfDay = d.getHours(); internalSet(field, hourOfDay % unit); if (field == HOUR) { internalSet(HOUR_OF_DAY, hourOfDay); } else { internalSet(AM_PM, hourOfDay / 12); internalSet(HOUR, hourOfDay % 12); } // Time zone offset and/or daylight saving might have changed. int zoneOffset = d.getZoneOffset(); int saving = d.getDaylightSaving(); internalSet(ZONE_OFFSET, zoneOffset - saving); internalSet(DST_OFFSET, saving); return; } case MONTH: // Rolling the month involves both pinning the final value to [0, 11] // and adjusting the DAY_OF_MONTH if necessary. We only adjust the // DAY_OF_MONTH if, after updating the MONTH field, it is illegal. // E.g., <jan31>.roll(MONTH, 1) -> <feb28> or <feb29>. { if (!isCutoverYear(cdate.getNormalizedYear())) { int mon = (internalGet(MONTH) + amount) % 12; if (mon < 0) { mon += 12; } set(MONTH, mon); // Keep the day of month in the range. We don't want to spill over // into the next month; e.g., we don't want jan31 + 1 mo -> feb31 -> // mar3. int monthLen = monthLength(mon); if (internalGet(DAY_OF_MONTH) > monthLen) { set(DAY_OF_MONTH, monthLen); } } else { // We need to take care of different lengths in // year and month due to the cutover. int yearLength = getActualMaximum(MONTH) + 1; int mon = (internalGet(MONTH) + amount) % yearLength; if (mon < 0) { mon += yearLength; } set(MONTH, mon); int monthLen = getActualMaximum(DAY_OF_MONTH); if (internalGet(DAY_OF_MONTH) > monthLen) { set(DAY_OF_MONTH, monthLen); } } return; } case WEEK_OF_YEAR: { int y = cdate.getNormalizedYear(); max = getActualMaximum(WEEK_OF_YEAR); set(DAY_OF_WEEK, internalGet(DAY_OF_WEEK)); int woy = internalGet(WEEK_OF_YEAR); int value = woy + amount; if (!isCutoverYear(y)) { // If the new value is in between min and max // (exclusive), then we can use the value. if (value > min && value < max) { set(WEEK_OF_YEAR, value); return; } long fd = getCurrentFixedDate(); // Make sure that the min week has the current DAY_OF_WEEK long day1 = fd - (7 * (woy - min)); if (calsys.getYearFromFixedDate(day1) != y) { min++; } // Make sure the same thing for the max week fd += 7 * (max - internalGet(WEEK_OF_YEAR)); if (calsys.getYearFromFixedDate(fd) != y) { max--; } break; } // Handle cutover here. long fd = getCurrentFixedDate(); BaseCalendar cal; if (gregorianCutoverYear == gregorianCutoverYearJulian) { cal = getCutoverCalendarSystem(); } else if (y == gregorianCutoverYear) { cal = gcal; } else { cal = getJulianCalendarSystem(); } long day1 = fd - (7 * (woy - min)); // Make sure that the min week has the current DAY_OF_WEEK if (cal.getYearFromFixedDate(day1) != y) { min++; } // Make sure the same thing for the max week fd += 7 * (max - woy); cal = (fd >= gregorianCutoverDate) ? gcal : getJulianCalendarSystem(); if (cal.getYearFromFixedDate(fd) != y) { max--; } // value: the new WEEK_OF_YEAR which must be converted // to month and day of month. value = getRolledValue(woy, amount, min, max) - 1; BaseCalendar.Date d = getCalendarDate(day1 + value * 7); set(MONTH, d.getMonth() - 1); set(DAY_OF_MONTH, d.getDayOfMonth()); return; } case WEEK_OF_MONTH: { boolean isCutoverYear = isCutoverYear(cdate.getNormalizedYear()); // dow: relative day of week from first day of week int dow = internalGet(DAY_OF_WEEK) - getFirstDayOfWeek(); if (dow < 0) { dow += 7; } long fd = getCurrentFixedDate(); long month1; // fixed date of the first day (usually 1) of the month int monthLength; // actual month length if (isCutoverYear) { month1 = getFixedDateMonth1(cdate, fd); monthLength = actualMonthLength(); } else { month1 = fd - internalGet(DAY_OF_MONTH) + 1; monthLength = calsys.getMonthLength(cdate); } // the first day of week of the month. long monthDay1st = calsys.getDayOfWeekDateOnOrBefore(month1 + 6, getFirstDayOfWeek()); // if the week has enough days to form a week, the // week starts from the previous month. if ((int)(monthDay1st - month1) >= getMinimalDaysInFirstWeek()) { monthDay1st -= 7; } max = getActualMaximum(field); // value: the new WEEK_OF_MONTH value int value = getRolledValue(internalGet(field), amount, 1, max) - 1; // nfd: fixed date of the rolled date long nfd = monthDay1st + value * 7 + dow; // Unlike WEEK_OF_YEAR, we need to change day of week if the // nfd is out of the month. if (nfd < month1) { nfd = month1; } else if (nfd >= (month1 + monthLength)) { nfd = month1 + monthLength - 1; } int dayOfMonth; if (isCutoverYear) { // If we are in the cutover year, convert nfd to // its calendar date and use dayOfMonth. BaseCalendar.Date d = getCalendarDate(nfd); dayOfMonth = d.getDayOfMonth(); } else { dayOfMonth = (int)(nfd - month1) + 1; } set(DAY_OF_MONTH, dayOfMonth); return; } case DAY_OF_MONTH: { if (!isCutoverYear(cdate.getNormalizedYear())) { max = calsys.getMonthLength(cdate); break; } // Cutover year handling long fd = getCurrentFixedDate(); long month1 = getFixedDateMonth1(cdate, fd); // It may not be a regular month. Convert the date and range to // the relative values, perform the roll, and // convert the result back to the rolled date. int value = getRolledValue((int)(fd - month1), amount, 0, actualMonthLength() - 1); BaseCalendar.Date d = getCalendarDate(month1 + value); assert d.getMonth()-1 == internalGet(MONTH); set(DAY_OF_MONTH, d.getDayOfMonth()); return; } case DAY_OF_YEAR: { max = getActualMaximum(field); if (!isCutoverYear(cdate.getNormalizedYear())) { break; } // Handle cutover here. long fd = getCurrentFixedDate(); long jan1 = fd - internalGet(DAY_OF_YEAR) + 1; int value = getRolledValue((int)(fd - jan1) + 1, amount, min, max); BaseCalendar.Date d = getCalendarDate(jan1 + value - 1); set(MONTH, d.getMonth() - 1); set(DAY_OF_MONTH, d.getDayOfMonth()); return; } case DAY_OF_WEEK: { if (!isCutoverYear(cdate.getNormalizedYear())) { // If the week of year is in the same year, we can // just change DAY_OF_WEEK. int weekOfYear = internalGet(WEEK_OF_YEAR); if (weekOfYear > 1 && weekOfYear < 52) { set(WEEK_OF_YEAR, weekOfYear); // update stamp[WEEK_OF_YEAR] max = SATURDAY; break; } } // We need to handle it in a different way around year // boundaries and in the cutover year. Note that // changing era and year values violates the roll // rule: not changing larger calendar fields... amount %= 7; if (amount == 0) { return; } long fd = getCurrentFixedDate(); long dowFirst = calsys.getDayOfWeekDateOnOrBefore(fd, getFirstDayOfWeek()); fd += amount; if (fd < dowFirst) { fd += 7; } else if (fd >= dowFirst + 7) { fd -= 7; } BaseCalendar.Date d = getCalendarDate(fd); set(ERA, (d.getNormalizedYear() <= 0 ? BCE : CE)); set(d.getYear(), d.getMonth() - 1, d.getDayOfMonth()); return; } case DAY_OF_WEEK_IN_MONTH: { min = 1; // after normalized, min should be 1. if (!isCutoverYear(cdate.getNormalizedYear())) { int dom = internalGet(DAY_OF_MONTH); int monthLength = calsys.getMonthLength(cdate); int lastDays = monthLength % 7; max = monthLength / 7; int x = (dom - 1) % 7; if (x < lastDays) { max++; } set(DAY_OF_WEEK, internalGet(DAY_OF_WEEK)); break; } // Cutover year handling long fd = getCurrentFixedDate(); long month1 = getFixedDateMonth1(cdate, fd); int monthLength = actualMonthLength(); int lastDays = monthLength % 7; max = monthLength / 7; int x = (int)(fd - month1) % 7; if (x < lastDays) { max++; } int value = getRolledValue(internalGet(field), amount, min, max) - 1; fd = month1 + value * 7 + x; BaseCalendar cal = (fd >= gregorianCutoverDate) ? gcal : getJulianCalendarSystem(); BaseCalendar.Date d = (BaseCalendar.Date) cal.newCalendarDate(TimeZone.NO_TIMEZONE); cal.getCalendarDateFromFixedDate(d, fd); set(DAY_OF_MONTH, d.getDayOfMonth()); return; } } set(field, getRolledValue(internalGet(field), amount, min, max)); }
// in java-util/GregorianCalendar.java
protected void computeTime() { // In non-lenient mode, perform brief checking of calendar // fields which have been set externally. Through this // checking, the field values are stored in originalFields[] // to see if any of them are normalized later. if (!isLenient()) { if (originalFields == null) { originalFields = new int[FIELD_COUNT]; } for (int field = 0; field < FIELD_COUNT; field++) { int value = internalGet(field); if (isExternallySet(field)) { // Quick validation for any out of range values if (value < getMinimum(field) || value > getMaximum(field)) { throw new IllegalArgumentException(getFieldName(field)); } } originalFields[field] = value; } } // Let the super class determine which calendar fields to be // used to calculate the time. int fieldMask = selectFields(); // The year defaults to the epoch start. We don't check // fieldMask for YEAR because YEAR is a mandatory field to // determine the date. int year = isSet(YEAR) ? internalGet(YEAR) : EPOCH_YEAR; int era = internalGetEra(); if (era == BCE) { year = 1 - year; } else if (era != CE) { // Even in lenient mode we disallow ERA values other than CE & BCE. // (The same normalization rule as add()/roll() could be // applied here in lenient mode. But this checking is kept // unchanged for compatibility as of 1.5.) throw new IllegalArgumentException("Invalid era"); } // If year is 0 or negative, we need to set the ERA value later. if (year <= 0 && !isSet(ERA)) { fieldMask |= ERA_MASK; setFieldsComputed(ERA_MASK); } // Calculate the time of day. We rely on the convention that // an UNSET field has 0. long timeOfDay = 0; if (isFieldSet(fieldMask, HOUR_OF_DAY)) { timeOfDay += (long) internalGet(HOUR_OF_DAY); } else { timeOfDay += internalGet(HOUR); // The default value of AM_PM is 0 which designates AM. if (isFieldSet(fieldMask, AM_PM)) { timeOfDay += 12 * internalGet(AM_PM); } } timeOfDay *= 60; timeOfDay += internalGet(MINUTE); timeOfDay *= 60; timeOfDay += internalGet(SECOND); timeOfDay *= 1000; timeOfDay += internalGet(MILLISECOND); // Convert the time of day to the number of days and the // millisecond offset from midnight. long fixedDate = timeOfDay / ONE_DAY; timeOfDay %= ONE_DAY; while (timeOfDay < 0) { timeOfDay += ONE_DAY; --fixedDate; } // Calculate the fixed date since January 1, 1 (Gregorian). calculateFixedDate: { long gfd, jfd; if (year > gregorianCutoverYear && year > gregorianCutoverYearJulian) { gfd = fixedDate + getFixedDate(gcal, year, fieldMask); if (gfd >= gregorianCutoverDate) { fixedDate = gfd; break calculateFixedDate; } jfd = fixedDate + getFixedDate(getJulianCalendarSystem(), year, fieldMask); } else if (year < gregorianCutoverYear && year < gregorianCutoverYearJulian) { jfd = fixedDate + getFixedDate(getJulianCalendarSystem(), year, fieldMask); if (jfd < gregorianCutoverDate) { fixedDate = jfd; break calculateFixedDate; } gfd = fixedDate + getFixedDate(gcal, year, fieldMask); } else { gfd = fixedDate + getFixedDate(gcal, year, fieldMask); jfd = fixedDate + getFixedDate(getJulianCalendarSystem(), year, fieldMask); } // Now we have to determine which calendar date it is. if (gfd >= gregorianCutoverDate) { if (jfd >= gregorianCutoverDate) { fixedDate = gfd; } else { // The date is in an "overlapping" period. No way // to disambiguate it. Determine it using the // previous date calculation. if (calsys == gcal || calsys == null) { fixedDate = gfd; } else { fixedDate = jfd; } } } else { if (jfd < gregorianCutoverDate) { fixedDate = jfd; } else { // The date is in a "missing" period. if (!isLenient()) { throw new IllegalArgumentException("the specified date doesn't exist"); } // Take the Julian date for compatibility, which // will produce a Gregorian date. fixedDate = jfd; } } } // millis represents local wall-clock time in milliseconds. long millis = (fixedDate - EPOCH_OFFSET) * ONE_DAY + timeOfDay; // Compute the time zone offset and DST offset. There are two potential // ambiguities here. We'll assume a 2:00 am (wall time) switchover time // for discussion purposes here. // 1. The transition into DST. Here, a designated time of 2:00 am - 2:59 am // can be in standard or in DST depending. However, 2:00 am is an invalid // representation (the representation jumps from 1:59:59 am Std to 3:00:00 am DST). // We assume standard time. // 2. The transition out of DST. Here, a designated time of 1:00 am - 1:59 am // can be in standard or DST. Both are valid representations (the rep // jumps from 1:59:59 DST to 1:00:00 Std). // Again, we assume standard time. // We use the TimeZone object, unless the user has explicitly set the ZONE_OFFSET // or DST_OFFSET fields; then we use those fields. TimeZone zone = getZone(); if (zoneOffsets == null) { zoneOffsets = new int[2]; } int tzMask = fieldMask & (ZONE_OFFSET_MASK|DST_OFFSET_MASK); if (tzMask != (ZONE_OFFSET_MASK|DST_OFFSET_MASK)) { if (zone instanceof ZoneInfo) { ((ZoneInfo)zone).getOffsetsByWall(millis, zoneOffsets); } else { int gmtOffset = isFieldSet(fieldMask, ZONE_OFFSET) ? internalGet(ZONE_OFFSET) : zone.getRawOffset(); zone.getOffsets(millis - gmtOffset, zoneOffsets); } } if (tzMask != 0) { if (isFieldSet(tzMask, ZONE_OFFSET)) { zoneOffsets[0] = internalGet(ZONE_OFFSET); } if (isFieldSet(tzMask, DST_OFFSET)) { zoneOffsets[1] = internalGet(DST_OFFSET); } } // Adjust the time zone offset values to get the UTC time. millis -= zoneOffsets[0] + zoneOffsets[1]; // Set this calendar's time in milliseconds time = millis; int mask = computeFields(fieldMask | getSetStateFields(), tzMask); if (!isLenient()) { for (int field = 0; field < FIELD_COUNT; field++) { if (!isExternallySet(field)) { continue; } if (originalFields[field] != internalGet(field)) { // Restore the original field values System.arraycopy(originalFields, 0, fields, 0, fields.length); throw new IllegalArgumentException(getFieldName(field)); } } } setFieldsNormalized(mask); }
0 0 1
            
// in java-util/Calendar.java
catch (IllegalArgumentException e) {}
0 0
runtime (Domain) IllegalFormatCodePointException
public class IllegalFormatCodePointException extends IllegalFormatException {

    private static final long serialVersionUID = 19080630L;

    private int c;

    /**
     * Constructs an instance of this class with the specified illegal code
     * point as defined by {@link Character#isValidCodePoint}.
     *
     * @param  c
     *         The illegal Unicode code point
     */
    public IllegalFormatCodePointException(int c) {
	this.c = c;
    }

    /**
     * Returns the illegal code point as defined by {@link
     * Character#isValidCodePoint}.
     *
     * @return  The illegal Unicode code point
     */
    public int getCodePoint() {
	return c;
    }

    public String getMessage() {
	return String.format("Code point = %#x", c);
    }
}
3
            
// in java-util/Formatter.java
private void printCharacter(Object arg) throws IOException { if (arg == null) { print("null"); return; } String s = null; if (arg instanceof Character) { s = ((Character)arg).toString(); } else if (arg instanceof Byte) { byte i = ((Byte)arg).byteValue(); if (Character.isValidCodePoint(i)) s = new String(Character.toChars(i)); else throw new IllegalFormatCodePointException(i); } else if (arg instanceof Short) { short i = ((Short)arg).shortValue(); if (Character.isValidCodePoint(i)) s = new String(Character.toChars(i)); else throw new IllegalFormatCodePointException(i); } else if (arg instanceof Integer) { int i = ((Integer)arg).intValue(); if (Character.isValidCodePoint(i)) s = new String(Character.toChars(i)); else throw new IllegalFormatCodePointException(i); } else { failConversion(c, arg); } print(s); }
0 0 0 0 0
runtime (Domain) IllegalFormatConversionException
public class IllegalFormatConversionException extends IllegalFormatException {

    private static final long serialVersionUID = 17000126L;

    private char c;
    private Class arg;

    /**
     * Constructs an instance of this class with the mismatched conversion and
     * the corresponding argument class.
     *
     * @param  c
     *         Inapplicable conversion
     *
     * @param  arg
     *         Class of the mismatched argument
     */
    public IllegalFormatConversionException(char c, Class<?> arg) {
	if (arg == null)
	    throw new NullPointerException();
	this.c = c;
	this.arg = arg;
    }

    /**
     * Returns the inapplicable conversion.
     *
     * @return  The inapplicable conversion
     */
    public char getConversion() {
	return c;
    }

    /**
     * Returns the class of the mismatched argument.
     *
     * @return   The class of the mismatched argument
     */
    public Class<?> getArgumentClass() {
	return arg;
    }

    // javadoc inherited from Throwable.java
    public String getMessage() {
	return String.format("%c != %s", c, arg.getName());
    }
}
1
            
// in java-util/Formatter.java
private void failConversion(char c, Object arg) { throw new IllegalFormatConversionException(c, arg.getClass()); }
0 0 0 0 0
runtime (Domain) IllegalFormatException
public class IllegalFormatException extends IllegalArgumentException {

    private static final long serialVersionUID = 18830826L;

    // package-private to prevent explicit instantiation
    IllegalFormatException() { }
}
0 0 0 0 0 0
runtime (Domain) IllegalFormatFlagsException
public class IllegalFormatFlagsException extends IllegalFormatException {

    private static final long serialVersionUID = 790824L;

    private String flags;

    /**
     * Constructs an instance of this class with the specified flags.
     *
     * @param  f
     *         The set of format flags which contain an illegal combination
     */
    public IllegalFormatFlagsException(String f) {
 	if (f == null)
 	    throw new NullPointerException();
	this.flags = f;
    }

    /**
     * Returns the set of flags which contains an illegal combination.
     *
     * @return  The flags
     */
    public String getFlags() {
	return flags;
    }

    public String getMessage() {
	return "Flags = '" + flags + "'";
    }
}
3
            
// in java-util/Formatter.java
private void checkNumeric() { if (width != -1 && width < 0) throw new IllegalFormatWidthException(width); if (precision != -1 && precision < 0) throw new IllegalFormatPrecisionException(precision); // '-' and '0' require a width if (width == -1 && (f.contains(Flags.LEFT_JUSTIFY) || f.contains(Flags.ZERO_PAD))) throw new MissingFormatWidthException(toString()); // bad combination if ((f.contains(Flags.PLUS) && f.contains(Flags.LEADING_SPACE)) || (f.contains(Flags.LEFT_JUSTIFY) && f.contains(Flags.ZERO_PAD))) throw new IllegalFormatFlagsException(f.toString()); }
// in java-util/Formatter.java
private void checkText() { if (precision != -1) throw new IllegalFormatPrecisionException(precision); switch (c) { case Conversion.PERCENT_SIGN: if (f.valueOf() != Flags.LEFT_JUSTIFY.valueOf() && f.valueOf() != Flags.NONE.valueOf()) throw new IllegalFormatFlagsException(f.toString()); // '-' requires a width if (width == -1 && f.contains(Flags.LEFT_JUSTIFY)) throw new MissingFormatWidthException(toString()); break; case Conversion.LINE_SEPARATOR: if (width != -1) throw new IllegalFormatWidthException(width); if (f.valueOf() != Flags.NONE.valueOf()) throw new IllegalFormatFlagsException(f.toString()); break; default: assert false; } }
0 0 0 0 0
runtime (Domain) IllegalFormatPrecisionException
public class IllegalFormatPrecisionException extends IllegalFormatException {

    private static final long serialVersionUID = 18711008L;

    private int p;

    /**
     * Constructs an instance of this class with the specified precision.
     *
     * @param  p
     *         The precision
     */
    public IllegalFormatPrecisionException(int p) {
	this.p = p;
    }

    /**
     * Returns the precision
     *
     * @return  The precision
     */
    public int getPrecision() {
	return p;
    }

    public String getMessage() {
	return Integer.toString(p);
    }
}
6
            
// in java-util/Formatter.java
private int precision(String s) { precision = -1; if (s != null) { try { // remove the '.' precision = Integer.parseInt(s.substring(1)); if (precision < 0) throw new IllegalFormatPrecisionException(precision); } catch (NumberFormatException x) { assert(false); } } return precision; }
// in java-util/Formatter.java
private void checkDateTime() { if (precision != -1) throw new IllegalFormatPrecisionException(precision); if (!DateTime.isValid(c)) throw new UnknownFormatConversionException("t" + c); checkBadFlags(Flags.ALTERNATE, Flags.PLUS, Flags.LEADING_SPACE, Flags.ZERO_PAD, Flags.GROUP, Flags.PARENTHESES); // '-' requires a width if (width == -1 && f.contains(Flags.LEFT_JUSTIFY)) throw new MissingFormatWidthException(toString()); }
// in java-util/Formatter.java
private void checkCharacter() { if (precision != -1) throw new IllegalFormatPrecisionException(precision); checkBadFlags(Flags.ALTERNATE, Flags.PLUS, Flags.LEADING_SPACE, Flags.ZERO_PAD, Flags.GROUP, Flags.PARENTHESES); // '-' requires a width if (width == -1 && f.contains(Flags.LEFT_JUSTIFY)) throw new MissingFormatWidthException(toString()); }
// in java-util/Formatter.java
private void checkInteger() { checkNumeric(); if (precision != -1) throw new IllegalFormatPrecisionException(precision); if (c == Conversion.DECIMAL_INTEGER) checkBadFlags(Flags.ALTERNATE); else if (c == Conversion.OCTAL_INTEGER) checkBadFlags(Flags.GROUP); else checkBadFlags(Flags.GROUP); }
// in java-util/Formatter.java
private void checkNumeric() { if (width != -1 && width < 0) throw new IllegalFormatWidthException(width); if (precision != -1 && precision < 0) throw new IllegalFormatPrecisionException(precision); // '-' and '0' require a width if (width == -1 && (f.contains(Flags.LEFT_JUSTIFY) || f.contains(Flags.ZERO_PAD))) throw new MissingFormatWidthException(toString()); // bad combination if ((f.contains(Flags.PLUS) && f.contains(Flags.LEADING_SPACE)) || (f.contains(Flags.LEFT_JUSTIFY) && f.contains(Flags.ZERO_PAD))) throw new IllegalFormatFlagsException(f.toString()); }
// in java-util/Formatter.java
private void checkText() { if (precision != -1) throw new IllegalFormatPrecisionException(precision); switch (c) { case Conversion.PERCENT_SIGN: if (f.valueOf() != Flags.LEFT_JUSTIFY.valueOf() && f.valueOf() != Flags.NONE.valueOf()) throw new IllegalFormatFlagsException(f.toString()); // '-' requires a width if (width == -1 && f.contains(Flags.LEFT_JUSTIFY)) throw new MissingFormatWidthException(toString()); break; case Conversion.LINE_SEPARATOR: if (width != -1) throw new IllegalFormatWidthException(width); if (f.valueOf() != Flags.NONE.valueOf()) throw new IllegalFormatFlagsException(f.toString()); break; default: assert false; } }
0 0 0 0 0
runtime (Domain) IllegalFormatWidthException
public class IllegalFormatWidthException extends IllegalFormatException {

    private static final long serialVersionUID = 16660902L;

    private int w;

    /**
     * Constructs an instance of this class with the specified width.
     *
     * @param  w
     *         The width
     */
    public IllegalFormatWidthException(int w) {
	this.w = w;
    }

    /**
     * Returns the width
     *
     * @return  The width
     */
    public int getWidth() {
	return w;
    }

    public String getMessage() {
	return Integer.toString(w);
    }
}
3
            
// in java-util/Formatter.java
private int width(String s) { width = -1; if (s != null) { try { width = Integer.parseInt(s); if (width < 0) throw new IllegalFormatWidthException(width); } catch (NumberFormatException x) { assert(false); } } return width; }
// in java-util/Formatter.java
private void checkNumeric() { if (width != -1 && width < 0) throw new IllegalFormatWidthException(width); if (precision != -1 && precision < 0) throw new IllegalFormatPrecisionException(precision); // '-' and '0' require a width if (width == -1 && (f.contains(Flags.LEFT_JUSTIFY) || f.contains(Flags.ZERO_PAD))) throw new MissingFormatWidthException(toString()); // bad combination if ((f.contains(Flags.PLUS) && f.contains(Flags.LEADING_SPACE)) || (f.contains(Flags.LEFT_JUSTIFY) && f.contains(Flags.ZERO_PAD))) throw new IllegalFormatFlagsException(f.toString()); }
// in java-util/Formatter.java
private void checkText() { if (precision != -1) throw new IllegalFormatPrecisionException(precision); switch (c) { case Conversion.PERCENT_SIGN: if (f.valueOf() != Flags.LEFT_JUSTIFY.valueOf() && f.valueOf() != Flags.NONE.valueOf()) throw new IllegalFormatFlagsException(f.toString()); // '-' requires a width if (width == -1 && f.contains(Flags.LEFT_JUSTIFY)) throw new MissingFormatWidthException(toString()); break; case Conversion.LINE_SEPARATOR: if (width != -1) throw new IllegalFormatWidthException(width); if (f.valueOf() != Flags.NONE.valueOf()) throw new IllegalFormatFlagsException(f.toString()); break; default: assert false; } }
0 0 0 0 0
runtime (Lib) IllegalStateException 31
            
// in java-util/LinkedList.java
public void remove() { checkForComodification(); Entry<E> lastNext = lastReturned.next; try { LinkedList.this.remove(lastReturned); } catch (NoSuchElementException e) { throw new IllegalStateException(); } if (next==lastReturned) next = lastNext; else nextIndex--; lastReturned = header; expectedModCount++; }
// in java-util/LinkedList.java
public void set(E e) { if (lastReturned == header) throw new IllegalStateException(); checkForComodification(); lastReturned.element = e; }
// in java-util/TreeMap.java
public void remove() { if (lastReturned == null) throw new IllegalStateException(); if (modCount != expectedModCount) throw new ConcurrentModificationException(); // deleted entries are replaced by their successors if (lastReturned.left != null && lastReturned.right != null) next = lastReturned; deleteEntry(lastReturned); expectedModCount = modCount; lastReturned = null; }
// in java-util/TreeMap.java
final void removeAscending() { if (lastReturned == null) throw new IllegalStateException(); if (m.modCount != expectedModCount) throw new ConcurrentModificationException(); // deleted entries are replaced by their successors if (lastReturned.left != null && lastReturned.right != null) next = lastReturned; m.deleteEntry(lastReturned); lastReturned = null; expectedModCount = m.modCount; }
// in java-util/TreeMap.java
final void removeDescending() { if (lastReturned == null) throw new IllegalStateException(); if (m.modCount != expectedModCount) throw new ConcurrentModificationException(); m.deleteEntry(lastReturned); lastReturned = null; expectedModCount = m.modCount; }
// in java-util/ArrayDeque.java
private void doubleCapacity() { assert head == tail; int p = head; int n = elements.length; int r = n - p; // number of elements to the right of p int newCapacity = n << 1; if (newCapacity < 0) throw new IllegalStateException("Sorry, deque too big"); Object[] a = new Object[newCapacity]; System.arraycopy(elements, p, a, 0, r); System.arraycopy(elements, 0, a, r, p); elements = (E[])a; head = 0; tail = n; }
// in java-util/ArrayDeque.java
public void remove() { if (lastRet < 0) throw new IllegalStateException(); if (delete(lastRet)) { // if left-shifted, undo increment in next() cursor = (cursor - 1) & (elements.length - 1); fence = tail; } lastRet = -1; }
// in java-util/ArrayDeque.java
public void remove() { if (lastRet < 0) throw new IllegalStateException(); if (!delete(lastRet)) { cursor = (cursor + 1) & (elements.length - 1); fence = head; } lastRet = -1; }
// in java-util/WeakHashMap.java
public void remove() { if (lastReturned == null) throw new IllegalStateException(); if (modCount != expectedModCount) throw new ConcurrentModificationException(); WeakHashMap.this.remove(currentKey); expectedModCount = modCount; lastReturned = null; currentKey = null; }
// in java-util/LinkedHashMap.java
public void remove() { if (lastReturned == null) throw new IllegalStateException(); if (modCount != expectedModCount) throw new ConcurrentModificationException(); LinkedHashMap.this.remove(lastReturned.key); lastReturned = null; expectedModCount = modCount; }
// in java-util/Scanner.java
private void useTypeCache() { if (closed) throw new IllegalStateException("Scanner closed"); position = hasNextPosition; hasNextPattern = null; typeCache = null; }
// in java-util/Scanner.java
private void ensureOpen() { if (closed) throw new IllegalStateException("Scanner closed"); }
// in java-util/Scanner.java
public MatchResult match() { if (!matchValid) throw new IllegalStateException("No match result available"); return matcher.toMatchResult(); }
// in java-util/Timer.java
private void sched(TimerTask task, long time, long period) { if (time < 0) throw new IllegalArgumentException("Illegal execution time."); synchronized(queue) { if (!thread.newTasksMayBeScheduled) throw new IllegalStateException("Timer already cancelled."); synchronized(task.lock) { if (task.state != TimerTask.VIRGIN) throw new IllegalStateException( "Task already scheduled or cancelled"); task.nextExecutionTime = time; task.period = period; task.state = TimerTask.SCHEDULED; } queue.add(task); if (queue.getMin() == task) queue.notify(); } }
// in java-util/AbstractQueue.java
public boolean add(E e) { if (offer(e)) return true; else throw new IllegalStateException("Queue full"); }
// in java-util/AbstractList.java
public void remove() { if (lastRet == -1) throw new IllegalStateException(); checkForComodification(); try { AbstractList.this.remove(lastRet); if (lastRet < cursor) cursor--; lastRet = -1; expectedModCount = modCount; } catch (IndexOutOfBoundsException e) { throw new ConcurrentModificationException(); } }
// in java-util/AbstractList.java
public void set(E e) { if (lastRet == -1) throw new IllegalStateException(); checkForComodification(); try { AbstractList.this.set(lastRet, e); expectedModCount = modCount; } catch (IndexOutOfBoundsException ex) { throw new ConcurrentModificationException(); } }
// in java-util/HashMap.java
public void remove() { if (current == null) throw new IllegalStateException(); if (modCount != expectedModCount) throw new ConcurrentModificationException(); Object k = current.key; current = null; HashMap.this.removeEntryForKey(k); expectedModCount = modCount; }
// in java-util/RegularEnumSet.java
public void remove() { if (lastReturned == 0) throw new IllegalStateException(); elements -= lastReturned; lastReturned = 0; }
// in java-util/IdentityHashMap.java
private void resize(int newCapacity) { // assert (newCapacity & -newCapacity) == newCapacity; // power of 2 int newLength = newCapacity * 2; Object[] oldTable = table; int oldLength = oldTable.length; if (oldLength == 2*MAXIMUM_CAPACITY) { // can't expand any further if (threshold == MAXIMUM_CAPACITY-1) throw new IllegalStateException("Capacity exhausted."); threshold = MAXIMUM_CAPACITY-1; // Gigantic map! return; } if (oldLength >= newLength) return; Object[] newTable = new Object[newLength]; threshold = newLength / 3; for (int j = 0; j < oldLength; j += 2) { Object key = oldTable[j]; if (key != null) { Object value = oldTable[j+1]; oldTable[j] = null; oldTable[j+1] = null; int i = hash(key, newLength); while (newTable[i] != null) i = nextKeyIndex(i, newLength); newTable[i] = key; newTable[i + 1] = value; } } table = newTable; }
// in java-util/IdentityHashMap.java
public void remove() { if (lastReturnedIndex == -1) throw new IllegalStateException(); if (modCount != expectedModCount) throw new ConcurrentModificationException(); expectedModCount = ++modCount; int deletedSlot = lastReturnedIndex; lastReturnedIndex = -1; size--; // back up index to revisit new contents after deletion index = deletedSlot; indexValid = false; // Removal code proceeds as in closeDeletion except that // it must catch the rare case where an element already // seen is swapped into a vacant slot that will be later // traversed by this iterator. We cannot allow future // next() calls to return it again. The likelihood of // this occurring under 2/3 load factor is very slim, but // when it does happen, we must make a copy of the rest of // the table to use for the rest of the traversal. Since // this can only happen when we are near the end of the table, // even in these rare cases, this is not very expensive in // time or space. Object[] tab = traversalTable; int len = tab.length; int d = deletedSlot; K key = (K) tab[d]; tab[d] = null; // vacate the slot tab[d + 1] = null; // If traversing a copy, remove in real table. // We can skip gap-closure on copy. if (tab != IdentityHashMap.this.table) { IdentityHashMap.this.remove(key); expectedModCount = modCount; return; } Object item; for (int i = nextKeyIndex(d, len); (item = tab[i]) != null; i = nextKeyIndex(i, len)) { int r = hash(item, len); // See closeDeletion for explanation of this conditional if ((i < r && (r <= d || d <= i)) || (r <= d && d <= i)) { // If we are about to swap an already-seen element // into a slot that may later be returned by next(), // then clone the rest of table for use in future // next() calls. It is OK that our copy will have // a gap in the "wrong" place, since it will never // be used for searching anyway. if (i < deletedSlot && d >= deletedSlot && traversalTable == IdentityHashMap.this.table) { int remaining = len - deletedSlot; Object[] newTable = new Object[remaining]; System.arraycopy(tab, deletedSlot, newTable, 0, remaining); traversalTable = newTable; index = 0; } tab[d] = item; tab[d + 1] = tab[i + 1]; tab[i] = null; tab[i + 1] = null; d = i; } }
// in java-util/IdentityHashMap.java
public K getKey() { // Provide a better exception than out of bounds index if (lastReturnedIndex < 0) throw new IllegalStateException("Entry was removed"); return (K) unmaskNull(traversalTable[lastReturnedIndex]); }
// in java-util/IdentityHashMap.java
public V getValue() { // Provide a better exception than out of bounds index if (lastReturnedIndex < 0) throw new IllegalStateException("Entry was removed"); return (V) traversalTable[lastReturnedIndex+1]; }
// in java-util/IdentityHashMap.java
public V setValue(V value) { // It would be mean-spirited to proceed here if remove() called if (lastReturnedIndex < 0) throw new IllegalStateException("Entry was removed"); V oldValue = (V) traversalTable[lastReturnedIndex+1]; traversalTable[lastReturnedIndex+1] = value; // if shadowing, force into main table if (traversalTable != IdentityHashMap.this.table) put((K) traversalTable[lastReturnedIndex], value); return oldValue; }
// in java-util/PriorityQueue.java
public void remove() { if (expectedModCount != modCount) throw new ConcurrentModificationException(); if (lastRet != -1) { E moved = PriorityQueue.this.removeAt(lastRet); lastRet = -1; if (moved == null) cursor--; else { if (forgetMeNot == null) forgetMeNot = new ArrayDeque<E>(); forgetMeNot.add(moved); } } else if (lastRetElt != null) { PriorityQueue.this.removeEq(lastRetElt); lastRetElt = null; } else { throw new IllegalStateException(); } expectedModCount = modCount; }
// in java-util/EnumMap.java
private void checkLastReturnedIndex() { if (lastReturnedIndex < 0) throw new IllegalStateException(); }
// in java-util/EnumMap.java
private void checkLastReturnedIndexForEntryUse() { if (lastReturnedIndex < 0) throw new IllegalStateException("Entry was removed"); }
// in java-util/JumboEnumSet.java
public void remove() { if (lastReturned == 0) throw new IllegalStateException(); elements[lastReturnedIndex] -= lastReturned; size--; lastReturned = 0; }
// in java-util/Hashtable.java
public void remove() { if (!iterator) throw new UnsupportedOperationException(); if (lastReturned == null) throw new IllegalStateException("Hashtable Enumerator"); if (modCount != expectedModCount) throw new ConcurrentModificationException(); synchronized(Hashtable.this) { Entry[] tab = Hashtable.this.table; int index = (lastReturned.hash & 0x7FFFFFFF) % tab.length; for (Entry<K,V> e = tab[index], prev = null; e != null; prev = e, e = e.next) { if (e == lastReturned) { modCount++; expectedModCount++; if (prev == null) tab[index] = e.next; else prev.next = e.next; count--; lastReturned = null; return; } } throw new ConcurrentModificationException(); } }
// in java-util/Hashtable.java
public void remove() { throw new IllegalStateException("Hashtable Iterator"); }
1
            
// in java-util/LinkedList.java
catch (NoSuchElementException e) { throw new IllegalStateException(); }
0 0 0 0
unknown (Lib) IndexOutOfBoundsException 34
            
// in java-util/Vector.java
public synchronized int lastIndexOf(Object o, int index) { if (index >= elementCount) throw new IndexOutOfBoundsException(index + " >= "+ elementCount); if (o == null) { for (int i = index; i >= 0; i--) if (elementData[i]==null) return i; } else { for (int i = index; i >= 0; i--) if (o.equals(elementData[i])) return i; } return -1; }
// in java-util/LinkedList.java
public boolean addAll(int index, Collection<? extends E> c) { if (index < 0 || index > size) throw new IndexOutOfBoundsException("Index: "+index+ ", Size: "+size); Object[] a = c.toArray(); int numNew = a.length; if (numNew==0) return false; modCount++; Entry<E> successor = (index==size ? header : entry(index)); Entry<E> predecessor = successor.previous; for (int i=0; i<numNew; i++) { Entry<E> e = new Entry<E>((E)a[i], successor, predecessor); predecessor.next = e; predecessor = e; } successor.previous = predecessor; size += numNew; return true; }
// in java-util/LinkedList.java
private Entry<E> entry(int index) { if (index < 0 || index >= size) throw new IndexOutOfBoundsException("Index: "+index+ ", Size: "+size); Entry<E> e = header; if (index < (size >> 1)) { for (int i = 0; i <= index; i++) e = e.next; } else { for (int i = size; i > index; i--) e = e.previous; } return e; }
// in java-util/AbstractSequentialList.java
public E get(int index) { try { return listIterator(index).next(); } catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); } }
// in java-util/AbstractSequentialList.java
public E set(int index, E element) { try { ListIterator<E> e = listIterator(index); E oldVal = e.next(); e.set(element); return oldVal; } catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); } }
// in java-util/AbstractSequentialList.java
public void add(int index, E element) { try { listIterator(index).add(element); } catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); } }
// in java-util/AbstractSequentialList.java
public E remove(int index) { try { ListIterator<E> e = listIterator(index); E outCast = e.next(); e.remove(); return outCast; } catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); } }
// in java-util/AbstractSequentialList.java
public boolean addAll(int index, Collection<? extends E> c) { try { boolean modified = false; ListIterator<E> e1 = listIterator(index); Iterator<? extends E> e2 = c.iterator(); while (e2.hasNext()) { e1.add(e2.next()); modified = true; } return modified; } catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); } }
// in java-util/AbstractList.java
public ListIterator<E> listIterator(final int index) { if (index<0 || index>size()) throw new IndexOutOfBoundsException("Index: "+index); return new ListItr(index); }
// in java-util/AbstractList.java
public void add(int index, E element) { if (index<0 || index>size) throw new IndexOutOfBoundsException(); checkForComodification(); l.add(index+offset, element); expectedModCount = l.modCount; size++; modCount++; }
// in java-util/AbstractList.java
public boolean addAll(int index, Collection<? extends E> c) { if (index<0 || index>size) throw new IndexOutOfBoundsException( "Index: "+index+", Size: "+size); int cSize = c.size(); if (cSize==0) return false; checkForComodification(); l.addAll(offset+index, c); expectedModCount = l.modCount; size += cSize; modCount++; return true; }
// in java-util/AbstractList.java
public ListIterator<E> listIterator(final int index) { checkForComodification(); if (index<0 || index>size) throw new IndexOutOfBoundsException( "Index: "+index+", Size: "+size); return new ListIterator<E>() { private ListIterator<E> i = l.listIterator(index+offset); public boolean hasNext() { return nextIndex() < size; } public E next() { if (hasNext()) return i.next(); else throw new NoSuchElementException(); } public boolean hasPrevious() { return previousIndex() >= 0; } public E previous() { if (hasPrevious()) return i.previous(); else throw new NoSuchElementException(); } public int nextIndex() { return i.nextIndex() - offset; } public int previousIndex() { return i.previousIndex() - offset; } public void remove() { i.remove(); expectedModCount = l.modCount; size--; modCount++; } public void set(E e) { i.set(e); } public void add(E e) { i.add(e); expectedModCount = l.modCount; size++; modCount++; } }; }
// in java-util/AbstractList.java
private void rangeCheck(int index) { if (index<0 || index>=size) throw new IndexOutOfBoundsException("Index: "+index+ ",Size: "+size); }
// in java-util/ArrayList.java
public void add(int index, E element) { if (index > size || index < 0) throw new IndexOutOfBoundsException( "Index: "+index+", Size: "+size); ensureCapacity(size+1); // Increments modCount!! System.arraycopy(elementData, index, elementData, index + 1, size - index); elementData[index] = element; size++; }
// in java-util/ArrayList.java
public boolean addAll(int index, Collection<? extends E> c) { if (index > size || index < 0) throw new IndexOutOfBoundsException( "Index: " + index + ", Size: " + size); Object[] a = c.toArray(); int numNew = a.length; ensureCapacity(size + numNew); // Increments modCount int numMoved = size - index; if (numMoved > 0) System.arraycopy(elementData, index, elementData, index + numNew, numMoved); System.arraycopy(a, 0, elementData, index, numNew); size += numNew; return numNew != 0; }
// in java-util/ArrayList.java
private void RangeCheck(int index) { if (index >= size) throw new IndexOutOfBoundsException( "Index: "+index+", Size: "+size); }
// in java-util/BitSet.java
private static void checkRange(int fromIndex, int toIndex) { if (fromIndex < 0) throw new IndexOutOfBoundsException("fromIndex < 0: " + fromIndex); if (toIndex < 0) throw new IndexOutOfBoundsException("toIndex < 0: " + toIndex); if (fromIndex > toIndex) throw new IndexOutOfBoundsException("fromIndex: " + fromIndex + " > toIndex: " + toIndex); }
// in java-util/BitSet.java
public void flip(int bitIndex) { if (bitIndex < 0) throw new IndexOutOfBoundsException("bitIndex < 0: " + bitIndex); int wordIndex = wordIndex(bitIndex); expandTo(wordIndex); words[wordIndex] ^= (1L << bitIndex); recalculateWordsInUse(); checkInvariants(); }
// in java-util/BitSet.java
public void set(int bitIndex) { if (bitIndex < 0) throw new IndexOutOfBoundsException("bitIndex < 0: " + bitIndex); int wordIndex = wordIndex(bitIndex); expandTo(wordIndex); words[wordIndex] |= (1L << bitIndex); // Restores invariants checkInvariants(); }
// in java-util/BitSet.java
public void clear(int bitIndex) { if (bitIndex < 0) throw new IndexOutOfBoundsException("bitIndex < 0: " + bitIndex); int wordIndex = wordIndex(bitIndex); if (wordIndex >= wordsInUse) return; words[wordIndex] &= ~(1L << bitIndex); recalculateWordsInUse(); checkInvariants(); }
// in java-util/BitSet.java
public boolean get(int bitIndex) { if (bitIndex < 0) throw new IndexOutOfBoundsException("bitIndex < 0: " + bitIndex); checkInvariants(); int wordIndex = wordIndex(bitIndex); return (wordIndex < wordsInUse) && ((words[wordIndex] & (1L << bitIndex)) != 0); }
// in java-util/BitSet.java
public int nextSetBit(int fromIndex) { if (fromIndex < 0) throw new IndexOutOfBoundsException("fromIndex < 0: " + fromIndex); checkInvariants(); int u = wordIndex(fromIndex); if (u >= wordsInUse) return -1; long word = words[u] & (WORD_MASK << fromIndex); while (true) { if (word != 0) return (u * BITS_PER_WORD) + Long.numberOfTrailingZeros(word); if (++u == wordsInUse) return -1; word = words[u]; } }
// in java-util/BitSet.java
public int nextClearBit(int fromIndex) { // Neither spec nor implementation handle bitsets of maximal length. // See 4816253. if (fromIndex < 0) throw new IndexOutOfBoundsException("fromIndex < 0: " + fromIndex); checkInvariants(); int u = wordIndex(fromIndex); if (u >= wordsInUse) return fromIndex; long word = ~words[u] & (WORD_MASK << fromIndex); while (true) { if (word != 0) return (u * BITS_PER_WORD) + Long.numberOfTrailingZeros(word); if (++u == wordsInUse) return wordsInUse * BITS_PER_WORD; word = ~words[u]; } }
// in java-util/Collections.java
public static <T> void copy(List<? super T> dest, List<? extends T> src) { int srcSize = src.size(); if (srcSize > dest.size()) throw new IndexOutOfBoundsException("Source does not fit in dest"); if (srcSize < COPY_THRESHOLD || (src instanceof RandomAccess && dest instanceof RandomAccess)) { for (int i=0; i<srcSize; i++) dest.set(i, src.get(i)); } else { ListIterator<? super T> di=dest.listIterator(); ListIterator<? extends T> si=src.listIterator(); for (int i=0; i<srcSize; i++) { di.next(); di.set(si.next()); } } }
// in java-util/Collections.java
public Object get(int index) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/Collections.java
public E get(int index) { if (index != 0) throw new IndexOutOfBoundsException("Index: "+index+", Size: 1"); return element; }
// in java-util/Collections.java
public E get(int index) { if (index < 0 || index >= n) throw new IndexOutOfBoundsException("Index: "+index+ ", Size: "+n); return element; }
// in java-util/Collections.java
public List<E> subList(int fromIndex, int toIndex) { if (fromIndex < 0) throw new IndexOutOfBoundsException("fromIndex = " + fromIndex); if (toIndex > n) throw new IndexOutOfBoundsException("toIndex = " + toIndex); if (fromIndex > toIndex) throw new IllegalArgumentException("fromIndex(" + fromIndex + ") > toIndex(" + toIndex + ")"); return new CopiesList(toIndex - fromIndex, element); }
5
            
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
0 5
            
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException e) { checkForComodification(); throw new NoSuchElementException(); }
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException e) { throw new ConcurrentModificationException(); }
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException e) { checkForComodification(); throw new NoSuchElementException(); }
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException ex) { throw new ConcurrentModificationException(); }
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException ex) { throw new ConcurrentModificationException(); }
5
            
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException e) { checkForComodification(); throw new NoSuchElementException(); }
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException e) { throw new ConcurrentModificationException(); }
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException e) { checkForComodification(); throw new NoSuchElementException(); }
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException ex) { throw new ConcurrentModificationException(); }
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException ex) { throw new ConcurrentModificationException(); }
5
runtime (Domain) InputMismatchException
public
class InputMismatchException extends NoSuchElementException {
    /**
     * Constructs an <code>InputMismatchException</code> with <tt>null</tt> 
     * as its error message string.
     */
    public InputMismatchException() {
	super();
    }

    /**
     * Constructs an <code>InputMismatchException</code>, saving a reference 
     * to the error message string <tt>s</tt> for later retrieval by the 
     * <tt>getMessage</tt> method.
     *
     * @param   s   the detail message.
     */
    public InputMismatchException(String s) {
	super(s);
    }
}
9
            
// in java-util/Scanner.java
private void throwFor() { skipped = false; if ((sourceClosed) && (position == buf.limit())) throw new NoSuchElementException(); else throw new InputMismatchException(); }
// in java-util/Scanner.java
public byte nextByte(int radix) { // Check cached result if ((typeCache != null) && (typeCache instanceof Byte) && this.radix == radix) { byte val = ((Byte)typeCache).byteValue(); useTypeCache(); return val; } setRadix(radix); clearCaches(); // Search for next byte try { String s = next(integerPattern()); if (matcher.group(SIMPLE_GROUP_INDEX) == null) s = processIntegerToken(s); return Byte.parseByte(s, radix); } catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); } }
// in java-util/Scanner.java
public short nextShort(int radix) { // Check cached result if ((typeCache != null) && (typeCache instanceof Short) && this.radix == radix) { short val = ((Short)typeCache).shortValue(); useTypeCache(); return val; } setRadix(radix); clearCaches(); // Search for next short try { String s = next(integerPattern()); if (matcher.group(SIMPLE_GROUP_INDEX) == null) s = processIntegerToken(s); return Short.parseShort(s, radix); } catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); } }
// in java-util/Scanner.java
public int nextInt(int radix) { // Check cached result if ((typeCache != null) && (typeCache instanceof Integer) && this.radix == radix) { int val = ((Integer)typeCache).intValue(); useTypeCache(); return val; } setRadix(radix); clearCaches(); // Search for next int try { String s = next(integerPattern()); if (matcher.group(SIMPLE_GROUP_INDEX) == null) s = processIntegerToken(s); return Integer.parseInt(s, radix); } catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); } }
// in java-util/Scanner.java
public long nextLong(int radix) { // Check cached result if ((typeCache != null) && (typeCache instanceof Long) && this.radix == radix) { long val = ((Long)typeCache).longValue(); useTypeCache(); return val; } setRadix(radix); clearCaches(); try { String s = next(integerPattern()); if (matcher.group(SIMPLE_GROUP_INDEX) == null) s = processIntegerToken(s); return Long.parseLong(s, radix); } catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); } }
// in java-util/Scanner.java
public float nextFloat() { // Check cached result if ((typeCache != null) && (typeCache instanceof Float)) { float val = ((Float)typeCache).floatValue(); useTypeCache(); return val; } setRadix(10); clearCaches(); try { return Float.parseFloat(processFloatToken(next(floatPattern()))); } catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); } }
// in java-util/Scanner.java
public double nextDouble() { // Check cached result if ((typeCache != null) && (typeCache instanceof Double)) { double val = ((Double)typeCache).doubleValue(); useTypeCache(); return val; } setRadix(10); clearCaches(); // Search for next float try { return Double.parseDouble(processFloatToken(next(floatPattern()))); } catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); } }
// in java-util/Scanner.java
public BigInteger nextBigInteger(int radix) { // Check cached result if ((typeCache != null) && (typeCache instanceof BigInteger) && this.radix == radix) { BigInteger val = (BigInteger)typeCache; useTypeCache(); return val; } setRadix(radix); clearCaches(); // Search for next int try { String s = next(integerPattern()); if (matcher.group(SIMPLE_GROUP_INDEX) == null) s = processIntegerToken(s); return new BigInteger(s, radix); } catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); } }
// in java-util/Scanner.java
public BigDecimal nextBigDecimal() { // Check cached result if ((typeCache != null) && (typeCache instanceof BigDecimal)) { BigDecimal val = (BigDecimal)typeCache; useTypeCache(); return val; } setRadix(10); clearCaches(); // Search for next float try { String s = processFloatToken(next(decimalPattern())); return new BigDecimal(s); } catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); } }
8
            
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
0 0 0 0
unknown (Lib) InternalError 24
            
// in java-util/Vector.java
public synchronized Object clone() { try { Vector<E> v = (Vector<E>) super.clone(); v.elementData = Arrays.copyOf(elementData, elementCount); v.modCount = 0; return v; } catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); } }
// in java-util/UUID.java
public static UUID nameUUIDFromBytes(byte[] name) { MessageDigest md; try { md = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException nsae) { throw new InternalError("MD5 not supported"); } byte[] md5Bytes = md.digest(name); md5Bytes[6] &= 0x0f; /* clear version */ md5Bytes[6] |= 0x30; /* set to version 3 */ md5Bytes[8] &= 0x3f; /* clear variant */ md5Bytes[8] |= 0x80; /* set to IETF variant */ return new UUID(md5Bytes); }
// in java-util/ResourceBundle.java
public Object clone() { try { CacheKey clone = (CacheKey) super.clone(); if (loaderRef != null) { clone.loaderRef = new LoaderReference(loaderRef.get(), referenceQueue, clone); } // Clear the reference to a Throwable clone.cause = null; return clone; } catch (CloneNotSupportedException e) { //this should never happen throw new InternalError(); } }
// in java-util/LinkedList.java
public Object clone() { LinkedList<E> clone = null; try { clone = (LinkedList<E>) super.clone(); } catch (CloneNotSupportedException e) { throw new InternalError(); } // Put clone into "virgin" state clone.header = new Entry<E>(null, null, null); clone.header.next = clone.header.previous = clone.header; clone.size = 0; clone.modCount = 0; // Initialize clone with our elements for (Entry<E> e = header.next; e != header; e = e.next) clone.add(e.element); return clone; }
// in java-util/TreeMap.java
public Object clone() { TreeMap<K,V> clone = null; try { clone = (TreeMap<K,V>) super.clone(); } catch (CloneNotSupportedException e) { throw new InternalError(); } // Put clone into "virgin" state (except for comparator) clone.root = null; clone.size = 0; clone.modCount = 0; clone.entrySet = null; clone.navigableKeySet = null; clone.descendingMap = null; // Initialize clone with our mappings try { clone.buildFromSorted(size, entrySet().iterator(), null, null); } catch (java.io.IOException cannotHappen) { } catch (ClassNotFoundException cannotHappen) { } return clone; }
// in java-util/TreeMap.java
public Set<Map.Entry<K,V>> entrySet() { throw new InternalError(); }
// in java-util/TreeMap.java
public K lastKey() { throw new InternalError(); }
// in java-util/TreeMap.java
public K firstKey() { throw new InternalError(); }
// in java-util/TreeMap.java
public SortedMap<K,V> subMap(K fromKey, K toKey) { throw new InternalError(); }
// in java-util/TreeMap.java
public SortedMap<K,V> headMap(K toKey) { throw new InternalError(); }
// in java-util/TreeMap.java
public SortedMap<K,V> tailMap(K fromKey) { throw new InternalError(); }
// in java-util/TreeMap.java
public Comparator<? super K> comparator() { throw new InternalError(); }
// in java-util/Currency.java
public Object run() { try { Class data = Class.forName("java.util.CurrencyData"); mainTable = (String) data.getDeclaredField("mainTable").get(data); scCutOverTimes = (long[]) data.getDeclaredField("scCutOverTimes").get(data); scOldCurrencies = (String[]) data.getDeclaredField("scOldCurrencies").get(data); scNewCurrencies = (String[]) data.getDeclaredField("scNewCurrencies").get(data); scOldCurrenciesDFD = (int[]) data.getDeclaredField("scOldCurrenciesDFD").get(data); scNewCurrenciesDFD = (int[]) data.getDeclaredField("scNewCurrenciesDFD").get(data); otherCurrencies = (String) data.getDeclaredField("otherCurrencies").get(data); otherCurrenciesDFD = (int[]) data.getDeclaredField("otherCurrenciesDFD").get(data); } catch (ClassNotFoundException e) { throw new InternalError(); } catch (NoSuchFieldException e) { throw new InternalError(); } catch (IllegalAccessException e) { throw new InternalError(); } return null; }
// in java-util/HashSet.java
public Object clone() { try { HashSet<E> newSet = (HashSet<E>) super.clone(); newSet.map = (HashMap<E, Object>) map.clone(); return newSet; } catch (CloneNotSupportedException e) { throw new InternalError(); } }
// in java-util/ArrayList.java
public Object clone() { try { ArrayList<E> v = (ArrayList<E>) super.clone(); v.elementData = Arrays.copyOf(elementData, size); v.modCount = 0; return v; } catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); } }
// in java-util/TimeZone.java
public Object clone() { try { TimeZone other = (TimeZone) super.clone(); other.ID = ID; return other; } catch (CloneNotSupportedException e) { throw new InternalError(); } }
// in java-util/IdentityHashMap.java
public Object clone() { try { IdentityHashMap<K,V> m = (IdentityHashMap<K,V>) super.clone(); m.entrySet = null; m.table = (Object[])table.clone(); return m; } catch (CloneNotSupportedException e) { throw new InternalError(); } }
// in java-util/BitSet.java
public Object clone() { if (! sizeIsSticky) trimToSize(); try { BitSet result = (BitSet) super.clone(); result.words = words.clone(); result.checkInvariants(); return result; } catch (CloneNotSupportedException e) { throw new InternalError(); } }
// in java-util/Hashtable.java
public synchronized Object clone() { try { Hashtable<K,V> t = (Hashtable<K,V>) super.clone(); t.table = new Entry[table.length]; for (int i = table.length ; i-- > 0 ; ) { t.table[i] = (table[i] != null) ? (Entry<K,V>) table[i].clone() : null; } t.keySet = null; t.entrySet = null; t.values = null; t.modCount = 0; return t; } catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); } }
// in java-util/Calendar.java
public Object clone() { try { Calendar other = (Calendar) super.clone(); other.fields = new int[FIELD_COUNT]; other.isSet = new boolean[FIELD_COUNT]; other.stamp = new int[FIELD_COUNT]; for (int i = 0; i < FIELD_COUNT; i++) { other.fields[i] = fields[i]; other.stamp[i] = stamp[i]; other.isSet[i] = isSet[i]; } other.zone = (TimeZone) zone.clone(); return other; } catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); } }
// in java-util/Locale.java
public Object clone() { try { Locale that = (Locale)super.clone(); return that; } catch (CloneNotSupportedException e) { throw new InternalError(); } }
// in java-util/TreeSet.java
public Object clone() { TreeSet<E> clone = null; try { clone = (TreeSet<E>) super.clone(); } catch (CloneNotSupportedException e) { throw new InternalError(); } clone.m = new TreeMap<E,Object>(m); return clone; }
17
            
// in java-util/Vector.java
catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); }
// in java-util/UUID.java
catch (NoSuchAlgorithmException nsae) { throw new InternalError("MD5 not supported"); }
// in java-util/ResourceBundle.java
catch (CloneNotSupportedException e) { //this should never happen throw new InternalError(); }
// in java-util/LinkedList.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/TreeMap.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/Currency.java
catch (ClassNotFoundException e) { throw new InternalError(); }
// in java-util/Currency.java
catch (NoSuchFieldException e) { throw new InternalError(); }
// in java-util/Currency.java
catch (IllegalAccessException e) { throw new InternalError(); }
// in java-util/HashSet.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/ArrayList.java
catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); }
// in java-util/TimeZone.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/IdentityHashMap.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/BitSet.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/Hashtable.java
catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); }
// in java-util/Calendar.java
catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); }
// in java-util/Locale.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
// in java-util/TreeSet.java
catch (CloneNotSupportedException e) { throw new InternalError(); }
0 0 0 0
unknown (Lib) InterruptedException 0 0 0 1
            
// in java-util/Timer.java
catch(InterruptedException e) { }
0 0
checked (Domain) InvalidPropertiesFormatException
public class InvalidPropertiesFormatException extends IOException {
    /**
     * Constructs an InvalidPropertiesFormatException with the specified
     * cause.
     *
     * @param  cause the cause (which is saved for later retrieval by the
     *         {@link Throwable#getCause()} method).
     */
    public InvalidPropertiesFormatException(Throwable cause) {
        super(cause==null ? null : cause.toString());
        this.initCause(cause);
    }

   /**
    * Constructs an InvalidPropertiesFormatException with the specified
    * detail message.
    *
    * @param   message   the detail message. The detail message is saved for 
    *          later retrieval by the {@link Throwable#getMessage()} method.
    */
    public InvalidPropertiesFormatException(String message) {
        super(message);
    }

    /**
     * Throws NotSerializableException, since InvalidPropertiesFormatException
     * objects are not intended to be serializable.
     */
    private void writeObject(java.io.ObjectOutputStream out)
        throws NotSerializableException 
    {
        throw new NotSerializableException("Not serializable.");
    }

    /**
     * Throws NotSerializableException, since InvalidPropertiesFormatException
     * objects are not intended to be serializable.
     */
    private void readObject(java.io.ObjectInputStream in)
        throws NotSerializableException 
    {
        throw new NotSerializableException("Not serializable.");
    }

}
2
            
// in java-util/XMLUtils.java
static void load(Properties props, InputStream in) throws IOException, InvalidPropertiesFormatException { Document doc = null; try { doc = getLoadingDoc(in); } catch (SAXException saxe) { throw new InvalidPropertiesFormatException(saxe); } Element propertiesElement = (Element)doc.getChildNodes().item(1); String xmlVersion = propertiesElement.getAttribute("version"); if (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0) throw new InvalidPropertiesFormatException( "Exported Properties file format version " + xmlVersion + " is not supported. This java installation can read" + " versions " + EXTERNAL_XML_VERSION + " or older. You" + " may need to install a newer version of JDK."); importProperties(props, propertiesElement); }
1
            
// in java-util/XMLUtils.java
catch (SAXException saxe) { throw new InvalidPropertiesFormatException(saxe); }
2
            
// in java-util/Properties.java
public synchronized void loadFromXML(InputStream in) throws IOException, InvalidPropertiesFormatException { if (in == null) throw new NullPointerException(); XMLUtils.load(this, in); in.close(); }
// in java-util/XMLUtils.java
static void load(Properties props, InputStream in) throws IOException, InvalidPropertiesFormatException { Document doc = null; try { doc = getLoadingDoc(in); } catch (SAXException saxe) { throw new InvalidPropertiesFormatException(saxe); } Element propertiesElement = (Element)doc.getChildNodes().item(1); String xmlVersion = propertiesElement.getAttribute("version"); if (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0) throw new InvalidPropertiesFormatException( "Exported Properties file format version " + xmlVersion + " is not supported. This java installation can read" + " versions " + EXTERNAL_XML_VERSION + " or older. You" + " may need to install a newer version of JDK."); importProperties(props, propertiesElement); }
0 0 0
unknown (Lib) LinkageError 0 0 0 1
            
// in java-util/ResourceBundle.java
catch (LinkageError error) { // We need to handle the LinkageError case due to // inconsistent case-sensitivity in ClassLoader. // See 6572242 for details. cacheKey.setCause(error); }
0 0
runtime (Domain) MissingFormatArgumentException
public class MissingFormatArgumentException extends IllegalFormatException {

    private static final long serialVersionUID = 19190115L;

    private String s;

    /**
     * Constructs an instance of this class with the unmatched format
     * specifier.
     *
     * @param  s
     *         Format specifier which does not have a corresponding argument
     */
    public MissingFormatArgumentException(String s) {
	if (s == null)
	    throw new NullPointerException();
	this.s = s;
    }

    /**
     * Returns the unmatched format specifier.
     *
     * @return  The unmatched format specifier
     */
    public String getFormatSpecifier() {
	return s;
    }

    public String getMessage() {
	return "Format specifier '" + s + "'";
    }
}
3
            
// in java-util/Formatter.java
public Formatter format(Locale l, String format, Object ... args) { ensureOpen(); // index of last argument referenced int last = -1; // last ordinary index int lasto = -1; FormatString[] fsa = parse(format); for (int i = 0; i < fsa.length; i++) { FormatString fs = fsa[i]; int index = fs.index(); try { switch (index) { case -2: // fixed string, "%n", or "%%" fs.print(null, l); break; case -1: // relative index if (last < 0 || (args != null && last > args.length - 1)) throw new MissingFormatArgumentException(fs.toString()); fs.print((args == null ? null : args[last]), l); break; case 0: // ordinary index lasto++; last = lasto; if (args != null && lasto > args.length - 1) throw new MissingFormatArgumentException(fs.toString()); fs.print((args == null ? null : args[lasto]), l); break; default: // explicit index last = index - 1; if (args != null && last > args.length - 1) throw new MissingFormatArgumentException(fs.toString()); fs.print((args == null ? null : args[last]), l); break; } } catch (IOException x) { lastException = x; } } return this; }
0 0 0 0 0
runtime (Domain) MissingFormatWidthException
public class MissingFormatWidthException extends IllegalFormatException {

    private static final long serialVersionUID = 15560123L;

    private String s;

    /**
     * Constructs an instance of this class with the specified format
     * specifier. 
     *
     * @param  s
     *         The format specifier which does not have a width
     */
    public MissingFormatWidthException(String s) {
	if (s == null)
	    throw new NullPointerException();
	this.s = s;
    }

    /**
     * Returns the format specifier which does not have a width.
     *
     * @return  The format specifier which does not have a width
     */
    public String getFormatSpecifier() {
	return s;
    }

    public String getMessage() {
	return s;
    }
}
5
            
// in java-util/Formatter.java
private void checkGeneral() { if ((c == Conversion.BOOLEAN || c == Conversion.HASHCODE) && f.contains(Flags.ALTERNATE)) failMismatch(Flags.ALTERNATE, c); // '-' requires a width if (width == -1 && f.contains(Flags.LEFT_JUSTIFY)) throw new MissingFormatWidthException(toString()); checkBadFlags(Flags.PLUS, Flags.LEADING_SPACE, Flags.ZERO_PAD, Flags.GROUP, Flags.PARENTHESES); }
// in java-util/Formatter.java
private void checkDateTime() { if (precision != -1) throw new IllegalFormatPrecisionException(precision); if (!DateTime.isValid(c)) throw new UnknownFormatConversionException("t" + c); checkBadFlags(Flags.ALTERNATE, Flags.PLUS, Flags.LEADING_SPACE, Flags.ZERO_PAD, Flags.GROUP, Flags.PARENTHESES); // '-' requires a width if (width == -1 && f.contains(Flags.LEFT_JUSTIFY)) throw new MissingFormatWidthException(toString()); }
// in java-util/Formatter.java
private void checkCharacter() { if (precision != -1) throw new IllegalFormatPrecisionException(precision); checkBadFlags(Flags.ALTERNATE, Flags.PLUS, Flags.LEADING_SPACE, Flags.ZERO_PAD, Flags.GROUP, Flags.PARENTHESES); // '-' requires a width if (width == -1 && f.contains(Flags.LEFT_JUSTIFY)) throw new MissingFormatWidthException(toString()); }
// in java-util/Formatter.java
private void checkNumeric() { if (width != -1 && width < 0) throw new IllegalFormatWidthException(width); if (precision != -1 && precision < 0) throw new IllegalFormatPrecisionException(precision); // '-' and '0' require a width if (width == -1 && (f.contains(Flags.LEFT_JUSTIFY) || f.contains(Flags.ZERO_PAD))) throw new MissingFormatWidthException(toString()); // bad combination if ((f.contains(Flags.PLUS) && f.contains(Flags.LEADING_SPACE)) || (f.contains(Flags.LEFT_JUSTIFY) && f.contains(Flags.ZERO_PAD))) throw new IllegalFormatFlagsException(f.toString()); }
// in java-util/Formatter.java
private void checkText() { if (precision != -1) throw new IllegalFormatPrecisionException(precision); switch (c) { case Conversion.PERCENT_SIGN: if (f.valueOf() != Flags.LEFT_JUSTIFY.valueOf() && f.valueOf() != Flags.NONE.valueOf()) throw new IllegalFormatFlagsException(f.toString()); // '-' requires a width if (width == -1 && f.contains(Flags.LEFT_JUSTIFY)) throw new MissingFormatWidthException(toString()); break; case Conversion.LINE_SEPARATOR: if (width != -1) throw new IllegalFormatWidthException(width); if (f.valueOf() != Flags.NONE.valueOf()) throw new IllegalFormatFlagsException(f.toString()); break; default: assert false; } }
0 0 0 0 0
runtime (Domain) MissingResourceException
public
class MissingResourceException extends RuntimeException {

    /**
     * Constructs a MissingResourceException with the specified information.
     * A detail message is a String that describes this particular exception.
     * @param s the detail message
     * @param className the name of the resource class
     * @param key the key for the missing resource.
     */
    public MissingResourceException(String s, String className, String key) {
        super(s);
        this.className = className;
        this.key = key;
    }

    /**
     * Constructs a <code>MissingResourceException</code> with
     * <code>message</code>, <code>className</code>, <code>key</code>,
     * and <code>cause</code>. This constructor is package private for
     * use by <code>ResourceBundle.getBundle</code>.
     *
     * @param message
     *        the detail message
     * @param className
     *        the name of the resource class
     * @param key
     *        the key for the missing resource.
     * @param cause
     *        the cause (which is saved for later retrieval by the
     *        {@link Throwable.getCause()} method). (A null value is
     *        permitted, and indicates that the cause is nonexistent
     *        or unknown.)
     */
    MissingResourceException(String message, String className, String key, Throwable cause) {
	super(message, cause);
        this.className = className;
        this.key = key;
    }

    /**
     * Gets parameter passed by constructor.
     *
     * @return the name of the resource class
     */
    public String getClassName() {
        return className;
    }

    /**
     * Gets parameter passed by constructor.
     *
     * @return the key for the missing resource
     */
    public String getKey() {
        return key;
    }

    //============ privates ============

    // serialization compatibility with JDK1.1
    private static final long serialVersionUID = -4876345176062000401L;

    /**
     * The class name of the resource bundle requested by the user.
     * @serial
     */
    private String className;

    /**
     * The name of the specific resource requested by the user.
     * @serial
     */
    private String key;
}
4
            
// in java-util/ResourceBundle.java
public final Object getObject(String key) { Object obj = handleGetObject(key); if (obj == null) { if (parent != null) { obj = parent.getObject(key); } if (obj == null) throw new MissingResourceException("Can't find resource for bundle " +this.getClass().getName() +", key "+key, this.getClass().getName(), key); } return obj; }
// in java-util/ResourceBundle.java
private static final void throwMissingResourceException(String baseName, Locale locale, Throwable cause) { // If the cause is a MissingResourceException, avoid creating // a long chain. (6355009) if (cause instanceof MissingResourceException) { cause = null; } throw new MissingResourceException("Can't find bundle for base name " + baseName + ", locale " + locale, baseName + "_" + locale, // className "", // key cause); }
// in java-util/Locale.java
public String getISO3Language() throws MissingResourceException { String language3 = getISO3Code(language, LocaleISOData.isoLanguageTable); if (language3 == null) { throw new MissingResourceException("Couldn't find 3-letter language code for " + language, "FormatData_" + toString(), "ShortLanguage"); } return language3; }
// in java-util/Locale.java
public String getISO3Country() throws MissingResourceException { String country3 = getISO3Code(country, LocaleISOData.isoCountryTable); if (country3 == null) { throw new MissingResourceException("Couldn't find 3-letter country code for " + country, "FormatData_" + toString(), "ShortCountry"); } return country3; }
0 2
            
// in java-util/Locale.java
public String getISO3Language() throws MissingResourceException { String language3 = getISO3Code(language, LocaleISOData.isoLanguageTable); if (language3 == null) { throw new MissingResourceException("Couldn't find 3-letter language code for " + language, "FormatData_" + toString(), "ShortLanguage"); } return language3; }
// in java-util/Locale.java
public String getISO3Country() throws MissingResourceException { String country3 = getISO3Code(country, LocaleISOData.isoCountryTable); if (country3 == null) { throw new MissingResourceException("Couldn't find 3-letter country code for " + country, "FormatData_" + toString(), "ShortCountry"); } return country3; }
3
            
// in java-util/Currency.java
catch (MissingResourceException e) { // use currency code as symbol of last resort return currencyCode; }
// in java-util/Locale.java
catch (MissingResourceException e) { }
// in java-util/Locale.java
catch (MissingResourceException e) { }
0 0
unknown (Lib) NegativeArraySizeException 1 0 0 0 0 0
unknown (Lib) NoSuchAlgorithmException 0 0 0 1
            
// in java-util/UUID.java
catch (NoSuchAlgorithmException nsae) { throw new InternalError("MD5 not supported"); }
1
            
// in java-util/UUID.java
catch (NoSuchAlgorithmException nsae) { throw new InternalError("MD5 not supported"); }
0
runtime (Domain) NoSuchElementException
public
class NoSuchElementException extends RuntimeException {
    /**
     * Constructs a <code>NoSuchElementException</code> with <tt>null</tt> 
     * as its error message string.
     */
    public NoSuchElementException() {
	super();
    }

    /**
     * Constructs a <code>NoSuchElementException</code>, saving a reference 
     * to the error message string <tt>s</tt> for later retrieval by the 
     * <tt>getMessage</tt> method.
     *
     * @param   s   the detail message.
     */
    public NoSuchElementException(String s) {
	super(s);
    }
}
46
            
// in java-util/Vector.java
public E nextElement() { synchronized (Vector.this) { if (count < elementCount) { return (E)elementData[count++]; } } throw new NoSuchElementException("Vector Enumeration"); }
// in java-util/Vector.java
public synchronized E firstElement() { if (elementCount == 0) { throw new NoSuchElementException(); } return (E)elementData[0]; }
// in java-util/Vector.java
public synchronized E lastElement() { if (elementCount == 0) { throw new NoSuchElementException(); } return (E)elementData[elementCount - 1]; }
// in java-util/LinkedList.java
public E getFirst() { if (size==0) throw new NoSuchElementException(); return header.next.element; }
// in java-util/LinkedList.java
public E getLast() { if (size==0) throw new NoSuchElementException(); return header.previous.element; }
// in java-util/LinkedList.java
public E next() { checkForComodification(); if (nextIndex == size) throw new NoSuchElementException(); lastReturned = next; next = next.next; nextIndex++; return lastReturned.element; }
// in java-util/LinkedList.java
public E previous() { if (nextIndex == 0) throw new NoSuchElementException(); lastReturned = next = next.previous; nextIndex--; checkForComodification(); return lastReturned.element; }
// in java-util/LinkedList.java
private E remove(Entry<E> e) { if (e == header) throw new NoSuchElementException(); E result = e.element; e.previous.next = e.next; e.next.previous = e.previous; e.next = e.previous = null; e.element = null; size--; modCount++; return result; }
// in java-util/TreeMap.java
final Entry<K,V> nextEntry() { Entry<K,V> e = next; if (e == null) throw new NoSuchElementException(); if (modCount != expectedModCount) throw new ConcurrentModificationException(); next = successor(e); lastReturned = e; return e; }
// in java-util/TreeMap.java
final Entry<K,V> prevEntry() { Entry<K,V> e = next; if (e == null) throw new NoSuchElementException(); if (modCount != expectedModCount) throw new ConcurrentModificationException(); next = predecessor(e); lastReturned = e; return e; }
// in java-util/TreeMap.java
static <K> K key(Entry<K,?> e) { if (e==null) throw new NoSuchElementException(); return e.key; }
// in java-util/TreeMap.java
final TreeMap.Entry<K,V> nextEntry() { TreeMap.Entry<K,V> e = next; if (e == null || e.key == fenceKey) throw new NoSuchElementException(); if (m.modCount != expectedModCount) throw new ConcurrentModificationException(); next = successor(e); lastReturned = e; return e; }
// in java-util/TreeMap.java
final TreeMap.Entry<K,V> prevEntry() { TreeMap.Entry<K,V> e = next; if (e == null || e.key == fenceKey) throw new NoSuchElementException(); if (m.modCount != expectedModCount) throw new ConcurrentModificationException(); next = predecessor(e); lastReturned = e; return e; }
// in java-util/ArrayDeque.java
public E removeFirst() { E x = pollFirst(); if (x == null) throw new NoSuchElementException(); return x; }
// in java-util/ArrayDeque.java
public E removeLast() { E x = pollLast(); if (x == null) throw new NoSuchElementException(); return x; }
// in java-util/ArrayDeque.java
public E getFirst() { E x = elements[head]; if (x == null) throw new NoSuchElementException(); return x; }
// in java-util/ArrayDeque.java
public E getLast() { E x = elements[(tail - 1) & (elements.length - 1)]; if (x == null) throw new NoSuchElementException(); return x; }
// in java-util/ArrayDeque.java
public E next() { if (cursor == fence) throw new NoSuchElementException(); E result = elements[cursor]; // This check doesn't catch all possible comodifications, // but does catch the ones that corrupt traversal if (tail != fence || result == null) throw new ConcurrentModificationException(); lastRet = cursor; cursor = (cursor + 1) & (elements.length - 1); return result; }
// in java-util/ArrayDeque.java
public E next() { if (cursor == fence) throw new NoSuchElementException(); cursor = (cursor - 1) & (elements.length - 1); E result = elements[cursor]; if (head != fence || result == null) throw new ConcurrentModificationException(); lastRet = cursor; return result; }
// in java-util/WeakHashMap.java
protected Entry<K,V> nextEntry() { if (modCount != expectedModCount) throw new ConcurrentModificationException(); if (nextKey == null && !hasNext()) throw new NoSuchElementException(); lastReturned = entry; entry = entry.next; currentKey = nextKey; nextKey = null; return lastReturned; }
// in java-util/LinkedHashMap.java
Entry<K,V> nextEntry() { if (modCount != expectedModCount) throw new ConcurrentModificationException(); if (nextEntry == header) throw new NoSuchElementException(); Entry<K,V> e = lastReturned = nextEntry; nextEntry = e.after; return e; }
// in java-util/Scanner.java
private void throwFor() { skipped = false; if ((sourceClosed) && (position == buf.limit())) throw new NoSuchElementException(); else throw new InputMismatchException(); }
// in java-util/Scanner.java
public String nextLine() { if (hasNextPattern == linePattern()) return getCachedResult(); clearCaches(); String result = findWithinHorizon(linePattern, 0); if (result == null) throw new NoSuchElementException("No line found"); MatchResult mr = this.match(); String lineSep = mr.group(1); if (lineSep != null) result = result.substring(0, result.length() - lineSep.length()); if (result == null) throw new NoSuchElementException(); else return result; }
// in java-util/Scanner.java
public Scanner skip(Pattern pattern) { ensureOpen(); if (pattern == null) throw new NullPointerException(); clearCaches(); // Search for the pattern while (true) { String token = matchPatternInBuffer(pattern); if (token != null) { matchValid = true; position = matcher.end(); return this; } if (needInput) readInput(); else throw new NoSuchElementException(); } }
// in java-util/AbstractQueue.java
public E remove() { E x = poll(); if (x != null) return x; else throw new NoSuchElementException(); }
// in java-util/AbstractQueue.java
public E element() { E x = peek(); if (x != null) return x; else throw new NoSuchElementException(); }
// in java-util/AbstractList.java
public E next() { checkForComodification(); try { E next = get(cursor); lastRet = cursor++; return next; } catch (IndexOutOfBoundsException e) { checkForComodification(); throw new NoSuchElementException(); } }
// in java-util/AbstractList.java
public E previous() { checkForComodification(); try { int i = cursor - 1; E previous = get(i); lastRet = cursor = i; return previous; } catch (IndexOutOfBoundsException e) { checkForComodification(); throw new NoSuchElementException(); } }
// in java-util/AbstractList.java
public E next() { if (hasNext()) return i.next(); else throw new NoSuchElementException(); }
// in java-util/AbstractList.java
public E previous() { if (hasPrevious()) return i.previous(); else throw new NoSuchElementException(); }
// in java-util/HashMap.java
final Entry<K,V> nextEntry() { if (modCount != expectedModCount) throw new ConcurrentModificationException(); Entry<K,V> e = next; if (e == null) throw new NoSuchElementException(); if ((next = e.next) == null) { Entry[] t = table; while (index < t.length && (next = t[index++]) == null) ; } current = e; return e; }
// in java-util/RegularEnumSet.java
public E next() { if (unseen == 0) throw new NoSuchElementException(); lastReturned = unseen & -unseen; unseen -= lastReturned; return (E) universe[Long.numberOfTrailingZeros(lastReturned)]; }
// in java-util/ServiceLoader.java
public S next() { if (!hasNext()) { throw new NoSuchElementException(); } String cn = nextName; nextName = null; try { S p = service.cast(Class.forName(cn, true, loader) .newInstance()); providers.put(cn, p); return p; } catch (ClassNotFoundException x) { fail(service, "Provider " + cn + " not found"); } catch (Throwable x) { fail(service, "Provider " + cn + " could not be instantiated: " + x, x); } throw new Error(); // This cannot happen }
// in java-util/IdentityHashMap.java
protected int nextIndex() { if (modCount != expectedModCount) throw new ConcurrentModificationException(); if (!indexValid && !hasNext()) throw new NoSuchElementException(); indexValid = false; lastReturnedIndex = index; index += 2; return lastReturnedIndex; }
// in java-util/PriorityQueue.java
public E next() { if (expectedModCount != modCount) throw new ConcurrentModificationException(); if (cursor < size) return (E) queue[lastRet = cursor++]; if (forgetMeNot != null) { lastRet = -1; lastRetElt = forgetMeNot.poll(); if (lastRetElt != null) return lastRetElt; } throw new NoSuchElementException(); }
// in java-util/EnumMap.java
public K next() { if (!hasNext()) throw new NoSuchElementException(); lastReturnedIndex = index++; return keyUniverse[lastReturnedIndex]; }
// in java-util/EnumMap.java
public V next() { if (!hasNext()) throw new NoSuchElementException(); lastReturnedIndex = index++; return unmaskNull(vals[lastReturnedIndex]); }
// in java-util/EnumMap.java
public Map.Entry<K,V> next() { if (!hasNext()) throw new NoSuchElementException(); lastReturnedIndex = index++; return this; }
// in java-util/JumboEnumSet.java
public E next() { if (!hasNext()) throw new NoSuchElementException(); lastReturned = unseen & -unseen; lastReturnedIndex = unseenIndex; unseen -= lastReturned; return (E) universe[(lastReturnedIndex << 6) + Long.numberOfTrailingZeros(lastReturned)]; }
// in java-util/StringTokenizer.java
public String nextToken() { /* * If next position already computed in hasMoreElements() and * delimiters have changed between the computation and this invocation, * then use the computed value. */ currentPosition = (newPosition >= 0 && !delimsChanged) ? newPosition : skipDelimiters(currentPosition); /* Reset these anyway */ delimsChanged = false; newPosition = -1; if (currentPosition >= maxPosition) throw new NoSuchElementException(); int start = currentPosition; currentPosition = scanToken(currentPosition); return str.substring(start, currentPosition); }
// in java-util/Hashtable.java
public T nextElement() { Entry<K,V> et = entry; int i = index; Entry[] t = table; /* Use locals for faster loop iteration */ while (et == null && i > 0) { et = t[--i]; } entry = et; index = i; if (et != null) { Entry<K,V> e = lastReturned = entry; entry = e.next; return type == KEYS ? (T)e.key : (type == VALUES ? (T)e.value : (T)e); } throw new NoSuchElementException("Hashtable Enumerator"); }
// in java-util/Hashtable.java
public Object nextElement() { throw new NoSuchElementException("Hashtable Enumerator"); }
// in java-util/Hashtable.java
public Object next() { throw new NoSuchElementException("Hashtable Iterator"); }
// in java-util/Collections.java
public Object next() { throw new NoSuchElementException(); }
// in java-util/Collections.java
public E next() { if (hasNext) { hasNext = false; return element; } throw new NoSuchElementException(); }
2
            
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException e) { checkForComodification(); throw new NoSuchElementException(); }
// in java-util/AbstractList.java
catch (IndexOutOfBoundsException e) { checkForComodification(); throw new NoSuchElementException(); }
0 6
            
// in java-util/LinkedList.java
catch (NoSuchElementException e) { throw new IllegalStateException(); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
6
            
// in java-util/LinkedList.java
catch (NoSuchElementException e) { throw new IllegalStateException(); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
// in java-util/AbstractSequentialList.java
catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); }
1
unknown (Lib) NoSuchFieldException 0 0 0 1
            
// in java-util/Currency.java
catch (NoSuchFieldException e) { throw new InternalError(); }
1
            
// in java-util/Currency.java
catch (NoSuchFieldException e) { throw new InternalError(); }
0
unknown (Lib) NotSerializableException 2
            
// in java-util/InvalidPropertiesFormatException.java
private void writeObject(java.io.ObjectOutputStream out) throws NotSerializableException { throw new NotSerializableException("Not serializable."); }
// in java-util/InvalidPropertiesFormatException.java
private void readObject(java.io.ObjectInputStream in) throws NotSerializableException { throw new NotSerializableException("Not serializable."); }
0 2
            
// in java-util/InvalidPropertiesFormatException.java
private void writeObject(java.io.ObjectOutputStream out) throws NotSerializableException { throw new NotSerializableException("Not serializable."); }
// in java-util/InvalidPropertiesFormatException.java
private void readObject(java.io.ObjectInputStream in) throws NotSerializableException { throw new NotSerializableException("Not serializable."); }
0 0 0
runtime (Lib) NullPointerException 62
            
// in java-util/ResourceBundle.java
public static ResourceBundle getBundle(String baseName, Locale locale, ClassLoader loader) { if (loader == null) { throw new NullPointerException(); } return getBundleImpl(baseName, locale, loader, Control.INSTANCE); }
// in java-util/ResourceBundle.java
public static ResourceBundle getBundle(String baseName, Locale targetLocale, ClassLoader loader, Control control) { if (loader == null || control == null) { throw new NullPointerException(); } return getBundleImpl(baseName, targetLocale, loader, control); }
// in java-util/ResourceBundle.java
private static ResourceBundle getBundleImpl(String baseName, Locale locale, ClassLoader loader, Control control) { if (locale == null || control == null) { throw new NullPointerException(); } // We create a CacheKey here for use by this call. The base // name and loader will never change during the bundle loading // process. We have to make sure that the locale is set before // using it as a cache key. CacheKey cacheKey = new CacheKey(baseName, locale, loader); ResourceBundle bundle = null; // Quick lookup of the cache. BundleReference bundleRef = cacheList.get(cacheKey); if (bundleRef != null) { bundle = bundleRef.get(); bundleRef = null; } // If this bundle and all of its parents are valid (not expired), // then return this bundle. If any of the bundles is expired, we // don't call control.needsReload here but instead drop into the // complete loading process below. if (isValidBundle(bundle) && hasValidParentChain(bundle)) { return bundle; } // No valid bundle was found in the cache, so we need to load the // resource bundle and its parents. boolean isKnownControl = (control == Control.INSTANCE) || (control instanceof SingleFormatControl); List<String> formats = control.getFormats(baseName); if (!isKnownControl && !checkList(formats)) { throw new IllegalArgumentException("Invalid Control: getFormats"); } ResourceBundle baseBundle = null; for (Locale targetLocale = locale; targetLocale != null; targetLocale = control.getFallbackLocale(baseName, targetLocale)) { List<Locale> candidateLocales = control.getCandidateLocales(baseName, targetLocale); if (!isKnownControl && !checkList(candidateLocales)) { throw new IllegalArgumentException("Invalid Control: getCandidateLocales"); } bundle = findBundle(cacheKey, candidateLocales, formats, 0, control, baseBundle); // If the loaded bundle is the base bundle and exactly for the // requested locale or the only candidate locale, then take the // bundle as the resulting one. If the loaded bundle is the base // bundle, it's put on hold until we finish processing all // fallback locales. if (isValidBundle(bundle)) { boolean isBaseBundle = Locale.ROOT.equals(bundle.locale); if (!isBaseBundle || bundle.locale.equals(locale) || (candidateLocales.size() == 1 && bundle.locale.equals(candidateLocales.get(0)))) { break; } // If the base bundle has been loaded, keep the reference in // baseBundle so that we can avoid any redundant loading in case // the control specify not to cache bundles. if (isBaseBundle && baseBundle == null) { baseBundle = bundle; } } } if (bundle == null) { if (baseBundle == null) { throwMissingResourceException(baseName, locale, cacheKey.getCause()); } bundle = baseBundle; } return bundle; }
// in java-util/ResourceBundle.java
public static final void clearCache(ClassLoader loader) { if (loader == null) { throw new NullPointerException(); } Set<CacheKey> set = cacheList.keySet(); for (CacheKey key : set) { if (key.getLoader() == loader) { set.remove(key); } } }
// in java-util/ResourceBundle.java
public boolean containsKey(String key) { if (key == null) { throw new NullPointerException(); } for (ResourceBundle rb = this; rb != null; rb = rb.parent) { if (rb.handleKeySet().contains(key)) { return true; } } return false; }
// in java-util/ResourceBundle.java
public List<String> getFormats(String baseName) { if (baseName == null) { throw new NullPointerException(); } return FORMAT_DEFAULT; }
// in java-util/ResourceBundle.java
public List<Locale> getCandidateLocales(String baseName, Locale locale) { if (baseName == null) { throw new NullPointerException(); } String language = locale.getLanguage(); String country = locale.getCountry(); String variant = locale.getVariant(); List<Locale> locales = new ArrayList<Locale>(4); if (variant.length() > 0) { locales.add(locale); } if (country.length() > 0) { locales.add((locales.size() == 0) ? locale : Locale.getInstance(language, country, "")); } if (language.length() > 0) { locales.add((locales.size() == 0) ? locale : Locale.getInstance(language, "", "")); } locales.add(Locale.ROOT); return locales; }
// in java-util/ResourceBundle.java
public Locale getFallbackLocale(String baseName, Locale locale) { if (baseName == null) { throw new NullPointerException(); } Locale defaultLocale = Locale.getDefault(); return locale.equals(defaultLocale) ? null : defaultLocale; }
// in java-util/ResourceBundle.java
public long getTimeToLive(String baseName, Locale locale) { if (baseName == null || locale == null) { throw new NullPointerException(); } return TTL_NO_EXPIRATION_CONTROL; }
// in java-util/ResourceBundle.java
public boolean needsReload(String baseName, Locale locale, String format, ClassLoader loader, ResourceBundle bundle, long loadTime) { if (bundle == null) { throw new NullPointerException(); } if (format.equals("java.class") || format.equals("java.properties")) { format = format.substring(5); } boolean result = false; try { String resourceName = toResourceName(toBundleName(baseName, locale), format); URL url = loader.getResource(resourceName); if (url != null) { long lastModified = 0; URLConnection connection = url.openConnection(); if (connection != null) { // disable caches to get the correct data connection.setUseCaches(false); if (connection instanceof JarURLConnection) { JarEntry ent = ((JarURLConnection)connection).getJarEntry(); if (ent != null) { lastModified = ent.getTime(); if (lastModified == -1) { lastModified = 0; } } } else { lastModified = connection.getLastModified(); } } result = lastModified >= loadTime; } } catch (NullPointerException npe) { throw npe; } catch (Exception e) { // ignore other exceptions } return result; }
// in java-util/ResourceBundle.java
public List<String> getFormats(String baseName) { if (baseName == null) { throw new NullPointerException(); } return formats; }
// in java-util/ResourceBundle.java
public Locale getFallbackLocale(String baseName, Locale locale) { if (baseName == null || locale == null) { throw new NullPointerException(); } return null; }
// in java-util/TreeMap.java
final Entry<K,V> getEntry(Object key) { // Offload comparator-based version for sake of performance if (comparator != null) return getEntryUsingComparator(key); if (key == null) throw new NullPointerException(); Comparable<? super K> k = (Comparable<? super K>) key; Entry<K,V> p = root; while (p != null) { int cmp = k.compareTo(p.key); if (cmp < 0) p = p.left; else if (cmp > 0) p = p.right; else return p; } return null; }
// in java-util/TreeMap.java
public V put(K key, V value) { Entry<K,V> t = root; if (t == null) { // TBD: // 5045147: (coll) Adding null to an empty TreeSet should // throw NullPointerException // // compare(key, key); // type check root = new Entry<K,V>(key, value, null); size = 1; modCount++; return null; } int cmp; Entry<K,V> parent; // split comparator and comparable paths Comparator<? super K> cpr = comparator; if (cpr != null) { do { parent = t; cmp = cpr.compare(key, t.key); if (cmp < 0) t = t.left; else if (cmp > 0) t = t.right; else return t.setValue(value); } while (t != null); } else { if (key == null) throw new NullPointerException(); Comparable<? super K> k = (Comparable<? super K>) key; do { parent = t; cmp = k.compareTo(t.key); if (cmp < 0) t = t.left; else if (cmp > 0) t = t.right; else return t.setValue(value); } while (t != null); } Entry<K,V> e = new Entry<K,V>(key, value, parent); if (cmp < 0) parent.left = e; else parent.right = e; fixAfterInsertion(e); size++; modCount++; return null; }
// in java-util/Currency.java
public static Currency getInstance(Locale locale) { String country = locale.getCountry(); if (country == null) { throw new NullPointerException(); } if (country.length() != 2) { throw new IllegalArgumentException(); } char char1 = country.charAt(0); char char2 = country.charAt(1); int tableEntry = getMainTableEntry(char1, char2); if ((tableEntry & COUNTRY_TYPE_MASK) == SIMPLE_CASE_COUNTRY_MASK && tableEntry != INVALID_COUNTRY_ENTRY) { char finalChar = (char) ((tableEntry & SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK) + 'A'); int defaultFractionDigits = (tableEntry & SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK) >> SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT; StringBuffer sb = new StringBuffer(country); sb.append(finalChar); return getInstance(sb.toString(), defaultFractionDigits); } else { // special cases if (tableEntry == INVALID_COUNTRY_ENTRY) { throw new IllegalArgumentException(); } if (tableEntry == COUNTRY_WITHOUT_CURRENCY_ENTRY) { return null; } else { int index = (tableEntry & SPECIAL_CASE_COUNTRY_INDEX_MASK) - SPECIAL_CASE_COUNTRY_INDEX_DELTA; if (scCutOverTimes[index] == Long.MAX_VALUE || System.currentTimeMillis() < scCutOverTimes[index]) { return getInstance(scOldCurrencies[index], scOldCurrenciesDFD[index]); } else { return getInstance(scNewCurrencies[index], scNewCurrenciesDFD[index]); } } } }
// in java-util/ArrayDeque.java
public void addFirst(E e) { if (e == null) throw new NullPointerException(); elements[head = (head - 1) & (elements.length - 1)] = e; if (head == tail) doubleCapacity(); }
// in java-util/ArrayDeque.java
public void addLast(E e) { if (e == null) throw new NullPointerException(); elements[tail] = e; if ( (tail = (tail + 1) & (elements.length - 1)) == head) doubleCapacity(); }
// in java-util/Scanner.java
private static Readable makeReadable(InputStream source, String charsetName) { if (source == null) throw new NullPointerException("source"); InputStreamReader isr = null; try { isr = new InputStreamReader(source, charsetName); } catch (UnsupportedEncodingException uee) { IllegalArgumentException iae = new IllegalArgumentException(); iae.initCause(uee); throw iae; } return isr; }
// in java-util/Scanner.java
private static Readable makeReadable(ReadableByteChannel source) { if (source == null) throw new NullPointerException("source"); String defaultCharsetName = java.nio.charset.Charset.defaultCharset().name(); return Channels.newReader(source, java.nio.charset.Charset.defaultCharset().name()); }
// in java-util/Scanner.java
private static Readable makeReadable(ReadableByteChannel source, String charsetName) { if (source == null) throw new NullPointerException("source"); if (!Charset.isSupported(charsetName)) throw new IllegalArgumentException(charsetName); return Channels.newReader(source, charsetName); }
// in java-util/Scanner.java
public boolean hasNext(Pattern pattern) { ensureOpen(); if (pattern == null) throw new NullPointerException(); hasNextPattern = null; saveState(); while (true) { if (getCompleteTokenInBuffer(pattern) != null) { matchValid = true; cacheResult(); return revertState(true); } if (needInput) readInput(); else return revertState(false); } }
// in java-util/Scanner.java
public String next(Pattern pattern) { ensureOpen(); if (pattern == null) throw new NullPointerException(); // Did we already find this pattern? if (hasNextPattern == pattern) return getCachedResult(); clearCaches(); // Search for the pattern while (true) { String token = getCompleteTokenInBuffer(pattern); if (token != null) { matchValid = true; skipped = false; return token; } if (needInput) readInput(); else throwFor(); } }
// in java-util/Scanner.java
public String findInLine(Pattern pattern) { ensureOpen(); if (pattern == null) throw new NullPointerException(); clearCaches(); // Expand buffer to include the next newline or end of input int endPosition = 0; saveState(); while (true) { String token = findPatternInBuffer(separatorPattern(), 0); if (token != null) { endPosition = matcher.start(); break; // up to next newline } if (needInput) { readInput(); } else { endPosition = buf.limit(); break; // up to end of input } } revertState(); int horizonForLine = endPosition - position; // If there is nothing between the current pos and the next // newline simply return null, invoking findWithinHorizon // with "horizon=0" will scan beyond the line bound. if (horizonForLine == 0) return null; // Search for the pattern return findWithinHorizon(pattern, horizonForLine); }
// in java-util/Scanner.java
public String findWithinHorizon(Pattern pattern, int horizon) { ensureOpen(); if (pattern == null) throw new NullPointerException(); if (horizon < 0) throw new IllegalArgumentException("horizon < 0"); clearCaches(); // Search for the pattern while (true) { String token = findPatternInBuffer(pattern, horizon); if (token != null) { matchValid = true; return token; } if (needInput) readInput(); else break; // up to end of input } return null; }
// in java-util/Scanner.java
public Scanner skip(Pattern pattern) { ensureOpen(); if (pattern == null) throw new NullPointerException(); clearCaches(); // Search for the pattern while (true) { String token = matchPatternInBuffer(pattern); if (token != null) { matchValid = true; position = matcher.end(); return this; } if (needInput) readInput(); else throw new NoSuchElementException(); } }
// in java-util/Observable.java
public synchronized void addObserver(Observer o) { if (o == null) throw new NullPointerException(); if (!obs.contains(o)) { obs.addElement(o); } }
// in java-util/AbstractQueue.java
public boolean addAll(Collection<? extends E> c) { if (c == null) throw new NullPointerException(); if (c == this) throw new IllegalArgumentException(); boolean modified = false; Iterator<? extends E> e = c.iterator(); while (e.hasNext()) { if (add(e.next())) modified = true; } return modified; }
// in java-util/TimeZone.java
public void setID(String ID) { if (ID == null) { throw new NullPointerException(); } this.ID = ID; }
// in java-util/Properties.java
public synchronized void loadFromXML(InputStream in) throws IOException, InvalidPropertiesFormatException { if (in == null) throw new NullPointerException(); XMLUtils.load(this, in); in.close(); }
// in java-util/Properties.java
public synchronized void storeToXML(OutputStream os, String comment) throws IOException { if (os == null) throw new NullPointerException(); storeToXML(os, comment, "UTF-8"); }
// in java-util/Properties.java
public synchronized void storeToXML(OutputStream os, String comment, String encoding) throws IOException { if (os == null) throw new NullPointerException(); XMLUtils.save(this, os, comment, encoding); }
// in java-util/PriorityQueue.java
public boolean offer(E e) { if (e == null) throw new NullPointerException(); modCount++; int i = size; if (i >= queue.length) grow(i + 1); size = i + 1; if (i == 0) queue[0] = e; else siftUp(i, e); return true; }
// in java-util/PropertyPermission.java
private void init(int mask) { if ((mask & ALL) != mask) throw new IllegalArgumentException("invalid actions mask"); if (mask == NONE) throw new IllegalArgumentException("invalid actions mask"); if (getName() == null) throw new NullPointerException("name can't be null"); this.mask = mask; }
// in java-util/StringTokenizer.java
private int skipDelimiters(int startPos) { if (delimiters == null) throw new NullPointerException(); int position = startPos; while (!retDelims && position < maxPosition) { if (!hasSurrogates) { char c = str.charAt(position); if ((c > maxDelimCodePoint) || (delimiters.indexOf(c) < 0)) break; position++; } else { int c = str.codePointAt(position); if ((c > maxDelimCodePoint) || !isDelimiter(c)) { break; } position += Character.charCount(c); } } return position; }
// in java-util/Hashtable.java
public synchronized boolean contains(Object value) { if (value == null) { throw new NullPointerException(); } Entry tab[] = table; for (int i = tab.length ; i-- > 0 ;) { for (Entry<K,V> e = tab[i] ; e != null ; e = e.next) { if (e.value.equals(value)) { return true; } } } return false; }
// in java-util/Hashtable.java
public synchronized V put(K key, V value) { // Make sure the value is not null if (value == null) { throw new NullPointerException(); } // Makes sure the key is not already in the hashtable. Entry tab[] = table; int hash = key.hashCode(); int index = (hash & 0x7FFFFFFF) % tab.length; for (Entry<K,V> e = tab[index] ; e != null ; e = e.next) { if ((e.hash == hash) && e.key.equals(key)) { V old = e.value; e.value = value; return old; } } modCount++; if (count >= threshold) { // Rehash the table if the threshold is exceeded rehash(); tab = table; index = (hash & 0x7FFFFFFF) % tab.length; } // Creates the new entry. Entry<K,V> e = tab[index]; tab[index] = new Entry<K,V>(hash, key, value, e); count++; return null; }
// in java-util/Hashtable.java
public V setValue(V value) { if (value == null) throw new NullPointerException(); V oldValue = this.value; this.value = value; return oldValue; }
// in java-util/Calendar.java
boolean checkDisplayNameParams(int field, int style, int minStyle, int maxStyle, Locale locale, int fieldMask) { if (field < 0 || field >= fields.length || style < minStyle || style > maxStyle) { throw new IllegalArgumentException(); } if (locale == null) { throw new NullPointerException(); } return isFieldSet(fieldMask, field); }
// in java-util/ListResourceBundle.java
public final Object handleGetObject(String key) { // lazily load the lookup hashtable. if (lookup == null) { loadLookup(); } if (key == null) { throw new NullPointerException(); } return lookup.get(key); // this class ignores locales }
// in java-util/ListResourceBundle.java
private synchronized void loadLookup() { if (lookup != null) return; Object[][] contents = getContents(); HashMap<String,Object> temp = new HashMap<String,Object>(contents.length); for (int i = 0; i < contents.length; ++i) { // key must be non-null String, value must be non-null String key = (String) contents[i][0]; Object value = contents[i][1]; if (key == null || value == null) { throw new NullPointerException(); } temp.put(key, value); } lookup = temp; }
// in java-util/Locale.java
static Locale getInstance(String language, String country, String variant) { if (language== null || country == null || variant == null) { throw new NullPointerException(); } StringBuilder sb = new StringBuilder(); sb.append(language).append('_').append(country).append('_').append(variant); String key = sb.toString(); Locale locale = cache.get(key); if (locale == null) { locale = new Locale(language, country, variant); Locale l = cache.putIfAbsent(key, locale); if (l != null) { locale = l; } } return locale; }
// in java-util/Locale.java
public static synchronized void setDefault(Locale newLocale) { if (newLocale == null) throw new NullPointerException("Can't set default locale to NULL"); SecurityManager sm = System.getSecurityManager(); if (sm != null) sm.checkPermission(new PropertyPermission ("user.language", "write")); defaultLocale = newLocale; }
// in java-util/Locale.java
private String getDisplayString(String code, Locale inLocale, int type) { if (code.length() == 0) { return ""; } if (inLocale == null) { throw new NullPointerException(); } try { OpenListResourceBundle bundle = LocaleData.getLocaleNames(inLocale); String key = (type == DISPLAY_VARIANT ? "%%"+code : code); String result = null; // Check whether a provider can provide an implementation that's closer // to the requested locale than what the Java runtime itself can provide. LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(LocaleNameProvider.class); if (pool.hasProviders()) { result = pool.getLocalizedObject( LocaleNameGetter.INSTANCE, inLocale, bundle, key, type, code); } if (result == null) { result = bundle.getString(key); } if (result != null) { return result; } } catch (Exception e) { // just fall through } return code; }
// in java-util/PropertyResourceBundle.java
public Object handleGetObject(String key) { if (key == null) { throw new NullPointerException(); } return lookup.get(key); }
0 0 6
            
// in java-util/ResourceBundle.java
catch (NullPointerException e) { }
// in java-util/ResourceBundle.java
catch (NullPointerException npe) { throw npe; }
// in java-util/TimeZone.java
catch (NullPointerException e) { zoneID = GMT_ID; }
// in java-util/AbstractSet.java
catch (NullPointerException unused) { return false; }
// in java-util/AbstractMap.java
catch (NullPointerException unused) { return false; }
// in java-util/Hashtable.java
catch (NullPointerException unused) { return false; }
1
            
// in java-util/ResourceBundle.java
catch (NullPointerException npe) { throw npe; }
0
unknown (Lib) NumberFormatException 0 0 0 19
            
// in java-util/Scanner.java
catch (NumberFormatException nfe) { result = false; }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { result = false; }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { result = false; }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { result = false; }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { result = false; }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { result = false; }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { result = false; }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { result = false; }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Formatter.java
catch (NumberFormatException x) { assert(false); }
// in java-util/Formatter.java
catch (NumberFormatException x) { assert(false); }
// in java-util/Formatter.java
catch (NumberFormatException x) { assert(false); }
8
            
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
// in java-util/Scanner.java
catch (NumberFormatException nfe) { position = matcher.start(); // don't skip bad token throw new InputMismatchException(nfe.getMessage()); }
8
unknown (Lib) OutOfMemoryError 2
            
// in java-util/AbstractCollection.java
private static <T> T[] finishToArray(T[] r, Iterator<?> it) { int i = r.length; while (it.hasNext()) { int cap = r.length; if (i == cap) { int newCap = ((cap / 2) + 1) * 3; if (newCap <= cap) { // integer overflow if (cap == Integer.MAX_VALUE) throw new OutOfMemoryError ("Required array size too large"); newCap = Integer.MAX_VALUE; } r = Arrays.copyOf(r, newCap); } r[i++] = (T)it.next(); } // trim if overallocated return (i == r.length) ? r : Arrays.copyOf(r, i); }
// in java-util/PriorityQueue.java
private void grow(int minCapacity) { if (minCapacity < 0) // overflow throw new OutOfMemoryError(); int oldCapacity = queue.length; // Double size if small; else grow by 50% int newCapacity = ((oldCapacity < 64)? ((oldCapacity + 1) * 2): ((oldCapacity / 2) * 3)); if (newCapacity < 0) // overflow newCapacity = Integer.MAX_VALUE; if (newCapacity < minCapacity) newCapacity = minCapacity; queue = Arrays.copyOf(queue, newCapacity); }
0 0 0 0 0
unknown (Lib) ParserConfigurationException 0 0 0 2
            
// in java-util/XMLUtils.java
catch (ParserConfigurationException x) { throw new Error(x); }
// in java-util/XMLUtils.java
catch (ParserConfigurationException pce) { assert(false); }
1
            
// in java-util/XMLUtils.java
catch (ParserConfigurationException x) { throw new Error(x); }
1
unknown (Lib) PrivilegedActionException 0 0 0 2
            
// in java-util/ResourceBundle.java
catch (PrivilegedActionException e) { throw (IOException) e.getException(); }
// in java-util/Calendar.java
catch (PrivilegedActionException pae) { Exception e = pae.getException(); if (!(e instanceof OptionalDataException)) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } else if (e instanceof IOException) { throw (IOException) e; } else if (e instanceof ClassNotFoundException) { throw (ClassNotFoundException) e; } throw new RuntimeException(e); } }
5
            
// in java-util/ResourceBundle.java
catch (PrivilegedActionException e) { throw (IOException) e.getException(); }
// in java-util/Calendar.java
catch (PrivilegedActionException pae) { Exception e = pae.getException(); if (!(e instanceof OptionalDataException)) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } else if (e instanceof IOException) { throw (IOException) e; } else if (e instanceof ClassNotFoundException) { throw (ClassNotFoundException) e; } throw new RuntimeException(e); } }
1
runtime (Lib) RuntimeException 1
            
// in java-util/Calendar.java
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { final ObjectInputStream input = stream; input.defaultReadObject(); stamp = new int[FIELD_COUNT]; // Starting with version 2 (not implemented yet), we expect that // fields[], isSet[], isTimeSet, and areFieldsSet may not be // streamed out anymore. We expect 'time' to be correct. if (serialVersionOnStream >= 2) { isTimeSet = true; if (fields == null) fields = new int[FIELD_COUNT]; if (isSet == null) isSet = new boolean[FIELD_COUNT]; } else if (serialVersionOnStream >= 0) { for (int i=0; i<FIELD_COUNT; ++i) stamp[i] = isSet[i] ? COMPUTED : UNSET; } serialVersionOnStream = currentSerialVersion; // If there's a ZoneInfo object, use it for zone. ZoneInfo zi = null; try { zi = AccessController.doPrivileged( new PrivilegedExceptionAction<ZoneInfo>() { public ZoneInfo run() throws Exception { return (ZoneInfo) input.readObject(); } }, CalendarAccessControlContext.INSTANCE); } catch (PrivilegedActionException pae) { Exception e = pae.getException(); if (!(e instanceof OptionalDataException)) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } else if (e instanceof IOException) { throw (IOException) e; } else if (e instanceof ClassNotFoundException) { throw (ClassNotFoundException) e; } throw new RuntimeException(e); } } if (zi != null) { zone = zi; } // If the deserialized object has a SimpleTimeZone, try to // replace it with a ZoneInfo equivalent (as of 1.4) in order // to be compatible with the SimpleTimeZone-based // implementation as much as possible. if (zone instanceof SimpleTimeZone) { String id = zone.getID(); TimeZone tz = TimeZone.getTimeZone(id); if (tz != null && tz.hasSameRules(zone) && tz.getID().equals(id)) { zone = tz; } } }
1
            
// in java-util/Calendar.java
catch (PrivilegedActionException pae) { Exception e = pae.getException(); if (!(e instanceof OptionalDataException)) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } else if (e instanceof IOException) { throw (IOException) e; } else if (e instanceof ClassNotFoundException) { throw (ClassNotFoundException) e; } throw new RuntimeException(e); } }
0 0 0 0
unknown (Lib) SAXException 1
            
// in java-util/XMLUtils.java
public InputSource resolveEntity(String pid, String sid) throws SAXException { if (sid.equals(PROPS_DTD_URI)) { InputSource is; is = new InputSource(new StringReader(PROPS_DTD)); is.setSystemId(PROPS_DTD_URI); return is; } throw new SAXException("Invalid system identifier: " + sid); }
0 5
            
// in java-util/XMLUtils.java
static Document getLoadingDoc(InputStream in) throws SAXException, IOException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setIgnoringElementContentWhitespace(true); dbf.setValidating(true); dbf.setCoalescing(true); dbf.setIgnoringComments(true); try { DocumentBuilder db = dbf.newDocumentBuilder(); db.setEntityResolver(new Resolver()); db.setErrorHandler(new EH()); InputSource is = new InputSource(in); return db.parse(is); } catch (ParserConfigurationException x) { throw new Error(x); } }
// in java-util/XMLUtils.java
public InputSource resolveEntity(String pid, String sid) throws SAXException { if (sid.equals(PROPS_DTD_URI)) { InputSource is; is = new InputSource(new StringReader(PROPS_DTD)); is.setSystemId(PROPS_DTD_URI); return is; } throw new SAXException("Invalid system identifier: " + sid); }
// in java-util/XMLUtils.java
public void error(SAXParseException x) throws SAXException { throw x; }
// in java-util/XMLUtils.java
public void fatalError(SAXParseException x) throws SAXException { throw x; }
// in java-util/XMLUtils.java
public void warning(SAXParseException x) throws SAXException { throw x; }
1
            
// in java-util/XMLUtils.java
catch (SAXException saxe) { throw new InvalidPropertiesFormatException(saxe); }
1
            
// in java-util/XMLUtils.java
catch (SAXException saxe) { throw new InvalidPropertiesFormatException(saxe); }
0
unknown (Lib) SecurityException 1
            
// in java-util/PropertyPermission.java
public void add(Permission permission) { if (! (permission instanceof PropertyPermission)) throw new IllegalArgumentException("invalid permission: "+ permission); if (isReadOnly()) throw new SecurityException( "attempt to add a Permission to a readonly PermissionCollection"); PropertyPermission pp = (PropertyPermission) permission; String propName = pp.getName(); synchronized (this) { PropertyPermission existing = (PropertyPermission) perms.get(propName); if (existing != null) { int oldMask = existing.getMask(); int newMask = pp.getMask(); if (oldMask != newMask) { int effective = oldMask | newMask; String actions = PropertyPermission.getActions(effective); perms.put(propName, new PropertyPermission(propName, actions)); } } else { perms.put(propName, permission); } } if (!all_allowed) { if (propName.equals("*")) all_allowed = true; } }
0 0 1
            
// in java-util/TimeZone.java
catch (SecurityException e) { hasPermission = false; }
0 0
runtime (Domain) ServiceConfigurationError
public class ServiceConfigurationError
    extends Error
{

    private static final long serialVersionUID = 74132770414881L;

    /**
     * Constructs a new instance with the specified message.
     *
     * @param  msg  The message, or <tt>null</tt> if there is no message
     *
     */
    public ServiceConfigurationError(String msg) {
	super(msg);
    }

    /**
     * Constructs a new instance with the specified message and cause.
     *
     * @param  msg  The message, or <tt>null</tt> if there is no message
     *
     * @param  cause  The cause, or <tt>null</tt> if the cause is nonexistent
     *                or unknown
     */
    public ServiceConfigurationError(String msg, Throwable cause) {
	super(msg, cause);
    }

}
2
            
// in java-util/ServiceLoader.java
private static void fail(Class service, String msg, Throwable cause) throws ServiceConfigurationError { throw new ServiceConfigurationError(service.getName() + ": " + msg, cause); }
// in java-util/ServiceLoader.java
private static void fail(Class service, String msg) throws ServiceConfigurationError { throw new ServiceConfigurationError(service.getName() + ": " + msg); }
0 5
            
// in java-util/ServiceLoader.java
private static void fail(Class service, String msg, Throwable cause) throws ServiceConfigurationError { throw new ServiceConfigurationError(service.getName() + ": " + msg, cause); }
// in java-util/ServiceLoader.java
private static void fail(Class service, String msg) throws ServiceConfigurationError { throw new ServiceConfigurationError(service.getName() + ": " + msg); }
// in java-util/ServiceLoader.java
private static void fail(Class service, URL u, int line, String msg) throws ServiceConfigurationError { fail(service, u + ":" + line + ": " + msg); }
// in java-util/ServiceLoader.java
private int parseLine(Class service, URL u, BufferedReader r, int lc, List<String> names) throws IOException, ServiceConfigurationError { String ln = r.readLine(); if (ln == null) { return -1; } int ci = ln.indexOf('#'); if (ci >= 0) ln = ln.substring(0, ci); ln = ln.trim(); int n = ln.length(); if (n != 0) { if ((ln.indexOf(' ') >= 0) || (ln.indexOf('\t') >= 0)) fail(service, u, lc, "Illegal configuration-file syntax"); int cp = ln.codePointAt(0); if (!Character.isJavaIdentifierStart(cp)) fail(service, u, lc, "Illegal provider-class name: " + ln); for (int i = Character.charCount(cp); i < n; i += Character.charCount(cp)) { cp = ln.codePointAt(i); if (!Character.isJavaIdentifierPart(cp) && (cp != '.')) fail(service, u, lc, "Illegal provider-class name: " + ln); } if (!providers.containsKey(ln) && !names.contains(ln)) names.add(ln); } return lc + 1; }
// in java-util/ServiceLoader.java
private Iterator<String> parse(Class service, URL u) throws ServiceConfigurationError { InputStream in = null; BufferedReader r = null; ArrayList<String> names = new ArrayList<String>(); try { in = u.openStream(); r = new BufferedReader(new InputStreamReader(in, "utf-8")); int lc = 1; while ((lc = parseLine(service, u, r, lc, names)) >= 0); } catch (IOException x) { fail(service, "Error reading configuration file", x); } finally { try { if (r != null) r.close(); if (in != null) in.close(); } catch (IOException y) { fail(service, "Error closing configuration file", y); } } return names.iterator(); }
0 0 0
checked (Lib) Throwable 0 0 1
            
// in java-util/Timer.java
protected void finalize() throws Throwable { synchronized(queue) { thread.newTasksMayBeScheduled = false; queue.notify(); // In case queue is empty. } }
1
            
// in java-util/ServiceLoader.java
catch (Throwable x) { fail(service, "Provider " + cn + " could not be instantiated: " + x, x); }
0 0
checked (Domain) TooManyListenersException
public class TooManyListenersException extends Exception {

    /**
     * Constructs a TooManyListenersException with no detail message.
     * A detail message is a String that describes this particular exception.
     */

    public TooManyListenersException() {
	super();
    }

    /**
     * Constructs a TooManyListenersException with the specified detail message.
     * A detail message is a String that describes this particular exception.
     * @param s the detail message
     */

    public TooManyListenersException(String s) {
	super(s);
    }
}
0 0 0 0 0 0
unknown (Lib) TransformerConfigurationException 0 0 0 1
            
// in java-util/XMLUtils.java
catch (TransformerConfigurationException tce) { assert(false); }
0 0
unknown (Lib) TransformerException 0 0 0 1
            
// in java-util/XMLUtils.java
catch (TransformerException te) { IOException ioe = new IOException(); ioe.initCause(te); throw ioe; }
1
            
// in java-util/XMLUtils.java
catch (TransformerException te) { IOException ioe = new IOException(); ioe.initCause(te); throw ioe; }
0
runtime (Domain) UnknownFormatConversionException
public class UnknownFormatConversionException extends IllegalFormatException {

    private static final long serialVersionUID = 19060418L;

    private String s;

    /**
     * Constructs an instance of this class with the unknown conversion.
     *
     * @param  s
     *         Unknown conversion
     */
    public UnknownFormatConversionException(String s) {
	if (s == null)
	    throw new NullPointerException();
	this.s = s;
    }

    /**
     * Returns the unknown conversion.
     *
     * @return  The unknown conversion.
     */
    public String getConversion() {
	return s;
    }

    // javadoc inherited from Throwable.java
    public String getMessage() {
	return String.format("Conversion = '%s'", s);
    }
}
4
            
// in java-util/Formatter.java
private void checkText(String s) { int idx; // If there are any '%' in the given string, we got a bad format // specifier. if ((idx = s.indexOf('%')) != -1) { char c = (idx > s.length() - 2 ? '%' : s.charAt(idx + 1)); throw new UnknownFormatConversionException(String.valueOf(c)); } }
// in java-util/Formatter.java
private char conversion(String s) { c = s.charAt(0); if (!dt) { if (!Conversion.isValid(c)) throw new UnknownFormatConversionException(String.valueOf(c)); if (Character.isUpperCase(c)) f.add(Flags.UPPERCASE); c = Character.toLowerCase(c); if (Conversion.isText(c)) index = -2; } return c; }
// in java-util/Formatter.java
private void checkDateTime() { if (precision != -1) throw new IllegalFormatPrecisionException(precision); if (!DateTime.isValid(c)) throw new UnknownFormatConversionException("t" + c); checkBadFlags(Flags.ALTERNATE, Flags.PLUS, Flags.LEADING_SPACE, Flags.ZERO_PAD, Flags.GROUP, Flags.PARENTHESES); // '-' requires a width if (width == -1 && f.contains(Flags.LEFT_JUSTIFY)) throw new MissingFormatWidthException(toString()); }
0 0 0 0 0
runtime (Domain) UnknownFormatFlagsException
public class UnknownFormatFlagsException extends IllegalFormatException {

    private static final long serialVersionUID = 19370506L;

    private String flags;

    /**
     * Constructs an instance of this class with the specified flags.
     *
     * @param  f
     *         The set of format flags which contain an unknown flag
     */
    public UnknownFormatFlagsException(String f) {
 	if (f == null)
 	    throw new NullPointerException();
	this.flags = f;
    }

    /**
     * Returns the set of flags which contains an unknown flag.
     *
     * @return  The flags
     */
    public String getFlags() {
	return flags;
    }

    // javadoc inherited from Throwable.java
    public String getMessage() {
	return "Flags = " + flags;
    }
}
1
            
// in java-util/Formatter.java
private static Flags parse(char c) { switch (c) { case '-': return LEFT_JUSTIFY; case '#': return ALTERNATE; case '+': return PLUS; case ' ': return LEADING_SPACE; case '0': return ZERO_PAD; case ',': return GROUP; case '(': return PARENTHESES; case '<': return PREVIOUS; default: throw new UnknownFormatFlagsException(String.valueOf(c)); } }
0 0 0 0 0
unknown (Lib) UnsupportedEncodingException 0 0 6 1
            
// in java-util/Scanner.java
catch (UnsupportedEncodingException uee) { IllegalArgumentException iae = new IllegalArgumentException(); iae.initCause(uee); throw iae; }
1
            
// in java-util/Scanner.java
catch (UnsupportedEncodingException uee) { IllegalArgumentException iae = new IllegalArgumentException(); iae.initCause(uee); throw iae; }
0
runtime (Lib) UnsupportedOperationException 37
            
// in java-util/UUID.java
public long timestamp() { if (version() != 1) { throw new UnsupportedOperationException("Not a time-based UUID"); } long result = timestamp; if (result < 0) { result = (mostSigBits & 0x0000000000000FFFL) << 48; result |= ((mostSigBits >> 16) & 0xFFFFL) << 32; result |= mostSigBits >>> 32; timestamp = result; } return result; }
// in java-util/UUID.java
public int clockSequence() { if (version() != 1) { throw new UnsupportedOperationException("Not a time-based UUID"); } if (sequence < 0) { sequence = (int)((leastSigBits & 0x3FFF000000000000L) >>> 48); } return sequence; }
// in java-util/UUID.java
public long node() { if (version() != 1) { throw new UnsupportedOperationException("Not a time-based UUID"); } if (node < 0) { node = leastSigBits & 0x0000FFFFFFFFFFFFL; } return node; }
// in java-util/Scanner.java
public void remove() { throw new UnsupportedOperationException(); }
// in java-util/AbstractList.java
public E set(int index, E element) { throw new UnsupportedOperationException(); }
// in java-util/AbstractList.java
public void add(int index, E element) { throw new UnsupportedOperationException(); }
// in java-util/AbstractList.java
public E remove(int index) { throw new UnsupportedOperationException(); }
// in java-util/AbstractCollection.java
public boolean add(E e) { throw new UnsupportedOperationException(); }
// in java-util/ServiceLoader.java
public void remove() { throw new UnsupportedOperationException(); }
// in java-util/ServiceLoader.java
public void remove() { throw new UnsupportedOperationException(); }
// in java-util/AbstractMap.java
public V put(K key, V value) { throw new UnsupportedOperationException(); }
// in java-util/AbstractMap.java
public V setValue(V value) { throw new UnsupportedOperationException(); }
// in java-util/Hashtable.java
public void remove() { if (!iterator) throw new UnsupportedOperationException(); if (lastReturned == null) throw new IllegalStateException("Hashtable Enumerator"); if (modCount != expectedModCount) throw new ConcurrentModificationException(); synchronized(Hashtable.this) { Entry[] tab = Hashtable.this.table; int index = (lastReturned.hash & 0x7FFFFFFF) % tab.length; for (Entry<K,V> e = tab[index], prev = null; e != null; prev = e, e = e.next) { if (e == lastReturned) { modCount++; expectedModCount++; if (prev == null) tab[index] = e.next; else prev.next = e.next; count--; lastReturned = null; return; } } throw new ConcurrentModificationException(); } }
// in java-util/Collections.java
public void remove() { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public boolean add(E e){ throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public boolean remove(Object o) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public boolean addAll(Collection<? extends E> coll) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public boolean removeAll(Collection<?> coll) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public boolean retainAll(Collection<?> coll) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public void clear() { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public E set(int index, E element) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public void add(int index, E element) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public E remove(int index) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public boolean addAll(int index, Collection<? extends E> c) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public void remove() { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public void set(E e) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public void add(E e) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public V put(K key, V value) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public V remove(Object key) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public void putAll(Map<? extends K, ? extends V> m) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public void clear() { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public void remove() { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public V setValue(V value) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public boolean add(Map.Entry<K, V> e){ throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public boolean addAll(Collection<? extends Map.Entry<K, V>> coll) { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public void remove() { throw new UnsupportedOperationException(); }
// in java-util/Collections.java
public void remove() { throw new UnsupportedOperationException(); }
0 0 0 0 0

Miscellanous Metrics

nF = Number of Finally 5
nF = Number of Try-Finally (without catch) 3
Number of Methods with Finally (nMF) 6 / 2581 (0.2%)
Number of Finally with a Continue 0
Number of Finally with a Return 0
Number of Finally with a Throw 0
Number of Finally with a Break 0
Number of different exception types thrown 35
Number of Domain exception types thrown 19
Number of different exception types caught 25
Number of Domain exception types caught 2
Number of exception declarations in signatures 153
Number of different exceptions types declared in method signatures 16
Number of library exceptions types declared in method signatures 13
Number of Domain exceptions types declared in method signatures 3
Number of Catch with a continue 0
Number of Catch with a return 7
Number of Catch with a Break 0
nbIf = Number of If 2364
nbFor = Number of For 337
Number of Method with an if 914 / 2581
Number of Methods with a for 272 / 2581
Number of Method starting with a try 20 / 2581 (0.8%)
Number of Expressions 23077
Number of Expressions in try 770 (3.3%)