APIdia Launch Partner
Top Inners Fields Constructors Methods
sun.tools.jar

pack-priv final Class Validator

extends Object
Class Inheritance
Imports
java.io.BufferedInputStream, .File, .FileInputStream, .IOException, .InputStream, java.lang.module.ModuleDescriptor, .ModuleDescriptor.Exports, .ModuleDescriptor.Opens, .ModuleDescriptor.Provides, .ModuleDescriptor.Requires, java.util.Collections, .HashMap, .HashSet, .LinkedHashMap, .List, .Map, .Set, .TreeMap, java.util.function.Function, .IntSupplier, java.util.regex.Pattern, java.util.stream.Collectors, java.util.jar.Attributes, .Manifest, java.util.zip.ZipEntry, .ZipFile, .ZipInputStream

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
Validator.EntryValidator

Validate base on entries in CEN and LOC.

pack-priv static class

Field Summary

Modifier and TypeField and Description
private final Map<String, FingerPrint>
private Set<String>
private static final Pattern
INVALID_ZIP_ENTRY_NAME_PATTERN

Regex expression to verify that the Zip Entry file name: - is not an absolute path - the file name is not '.' or '..' - does not contain a backslash, '\' - does not contain a drive letter - path element does not include '.' or '..'

private boolean
private final Main
private ModuleDescriptor
private String
private final ZipFile
private final ZipInputStream

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private void
checkAutomaticModuleName()

Checks whether an Automatic-Module-Name entry is valid and also verifies it to the name given by a compiled module descriptor.

private boolean
private void
private boolean
private static String
className(String entryName)

private void
private void
private FingerPrint
private boolean
isConcealed(String className)

private static boolean
public static boolean

Returns:

true if a valid Zip Entry file name; false otherwise
isZipEntryNameValid
(String
ZIP entry name
entryName
)

Validate that the CEN/LOC file name header field adheres to PKWARE APPNOTE-6.3.3.TXT: 4.4.17.1 The name of the file, with optional relative path.

private FingerPrint
pack-priv static boolean
validate(Main main, File zipFile)

private boolean
public void
public void
private void
warn(String msg)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

classesback to summary
private final Map<String, FingerPrint> classes
concealedPkgsback to summary
private Set<String> concealedPkgs
INVALID_ZIP_ENTRY_NAME_PATTERNback to summary
private static final Pattern INVALID_ZIP_ENTRY_NAME_PATTERN

Regex expression to verify that the Zip Entry file name: - is not an absolute path - the file name is not '.' or '..' - does not contain a backslash, '\' - does not contain a drive letter - path element does not include '.' or '..'

isValidback to summary
private boolean isValid
mainback to summary
private final Main main
mdback to summary
private ModuleDescriptor md
mdNameback to summary
private String mdName
zfback to summary
private final ZipFile zf
zisback to summary
private final ZipInputStream zis

Constructor Detail

Validatorback to summary
private Validator(Main main, ZipFile zf, ZipInputStream zis)

Method Detail

checkAutomaticModuleNameback to summary
private void checkAutomaticModuleName()

Checks whether an Automatic-Module-Name entry is valid and also verifies it to the name given by a compiled module descriptor.

checkClassNameback to summary
private boolean checkClassName(FingerPrint fp)
checkModuleDescriptorback to summary
private void checkModuleDescriptor(String miName)
checkNestedClassback to summary
private boolean checkNestedClass(FingerPrint fp, Map<String, FingerPrint> outerClasses)
classNameback to summary
private static String className(String entryName)
errorback to summary
private void error(String msg)
errorAndInvalidback to summary
private void errorAndInvalid(String msg)
getFingerPrintback to summary
private FingerPrint getFingerPrint(ZipEntry ze)
isConcealedback to summary
private boolean isConcealed(String className)
isPlatformModuleback to summary
private static boolean isPlatformModule(String name)
isZipEntryNameValidback to summary
public static boolean isZipEntryNameValid(String entryName)

Validate that the CEN/LOC file name header field adheres to PKWARE APPNOTE-6.3.3.TXT: 4.4.17.1 The name of the file, with optional relative path. The path stored MUST not contain a drive or device letter, or a leading slash. All slashes MUST be forward slashes '/' as opposed to backwards slashes '\' for compatibility with Amiga and UNIX file systems etc. Also validate that the file name is not "." or "..", and that any name element is not equal to "." or ".."

Parameters
entryName:String

ZIP entry name

Returns:boolean

true if a valid Zip Entry file name; false otherwise

sameNameFingerPrintback to summary
private FingerPrint sameNameFingerPrint(FingerPrint fp1, FingerPrint fp2)
validateback to summary
pack-priv static boolean validate(Main main, File zipFile) throws IOException
validateback to summary
private boolean validate()
validateBaseback to summary
public void validateBase(Map<String, FingerPrint> fps)
validateVersionedback to summary
public void validateVersioned(Map<String, FingerPrint> fps)
warnback to summary
private void warn(String msg)
sun.tools.jar back to summary

private Class Validator.EntryValidator

extends Object
Class Inheritance

Validate base on entries in CEN and LOC. To ensure - Valid entry name - No duplicate entries - CEN and LOC should have same entries, in the same order NOTE: In order to check the encounter order based on the CEN listing, this implementation assumes CEN entries are to be added before adding any LOC entries. That is, addCenEntry should be called before calls to addLocEntry to ensure encounter order can be compared properly.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static record
Validator.EntryValidator.EntryEncounter

A record to keep the encounter order in the directory and count of the appearances

pack-priv static record
Validator.EntryValidator.EntryInfo

Information used for validation for a entry in CEN and LOC.

Field Summary

Modifier and TypeField and Description
pack-priv int
pack-priv LinkedHashMap<String, Validator.EntryValidator.EntryInfo>
entries

Ordered deduplication set for entries

pack-priv int
pack-priv boolean
pack-priv static final Validator.EntryValidator.EntryEncounter

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
addCenEntry(ZipEntry cenEntry)

Record an entry apperance in CEN

public void
addLocEntry(ZipEntry locEntry)

Record an entry apperance in LOC We compare entry order based on the CEN.

private void
checkDuplicates(int count, String msg, String entryName)

Issue warning for duplicate entries

public void
validate()

Validate the jar entries by checking each entry in encounter order

private void
validateEntry(String entryName, Validator.EntryValidator.EntryInfo entryInfo)

Validation per entry observed.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cenEncounterOrderback to summary
pack-priv int cenEncounterOrder
entriesback to summary
pack-priv LinkedHashMap<String, Validator.EntryValidator.EntryInfo> entries

Ordered deduplication set for entries

locEncounterOrderback to summary
pack-priv int locEncounterOrder
outOfOrderback to summary
pack-priv boolean outOfOrder
PLACE_HOLDERback to summary
pack-priv static final Validator.EntryValidator.EntryEncounter PLACE_HOLDER

Constructor Detail

EntryValidatorback to summary
private EntryValidator()

Method Detail

addCenEntryback to summary
public void addCenEntry(ZipEntry cenEntry)

Record an entry apperance in CEN

addLocEntryback to summary
public void addLocEntry(ZipEntry locEntry)

Record an entry apperance in LOC We compare entry order based on the CEN. Thus do not increase LOC encounter order if the entry is only in LOC.

Note

This works because all CEN entries are added before adding LOC entries.

checkDuplicatesback to summary
private void checkDuplicates(int count, String msg, String entryName)

Issue warning for duplicate entries

validateback to summary
public void validate()

Validate the jar entries by checking each entry in encounter order

validateEntryback to summary
private void validateEntry(String entryName, Validator.EntryValidator.EntryInfo entryInfo)

Validation per entry observed. Each entry must appear at least once in the CEN or LOC.

sun.tools.jar back to summary

pack-priv final Record Validator.EntryValidator.EntryEncounter

extends Record
Class Inheritance
Record Components
order:int 
count:int 

A record to keep the encounter order in the directory and count of the appearances

Field Summary

Modifier and TypeField and Description
private final int
count

Record Component accessed by count().

private final int
order

Record Component accessed by order().

Constructor Summary

AccessConstructor and Description
pack-priv
EntryEncounter(int order, int count)

Method Summary

Modifier and TypeMethod and Description
public int
count()

Record Component getter of count.

public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

pack-priv Validator.EntryValidator.EntryEncounter
increase(IntSupplier
The supplier for the encounter order in the directory
encounterOrder
)

Add to the appearance count.

pack-priv boolean
isPlaceHolder()

True if this entry is not in the directory.

public int
order()

Record Component getter of order.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

countback to summary
private final int count

Record Component accessed by count().

orderback to summary
private final int order

Record Component accessed by order().

Constructor Detail

EntryEncounterback to summary
pack-priv EntryEncounter(int order, int count)

Method Detail

countback to summary
public int count()

Record Component getter of count.

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

increaseback to summary
pack-priv Validator.EntryValidator.EntryEncounter increase(IntSupplier encounterOrder)

Add to the appearance count.

Parameters
encounterOrder:IntSupplier

The supplier for the encounter order in the directory

isPlaceHolderback to summary
pack-priv boolean isPlaceHolder()

True if this entry is not in the directory.

orderback to summary
public int order()

Record Component getter of order.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

sun.tools.jar back to summary

pack-priv final Record Validator.EntryValidator.EntryInfo

extends Record
Class Inheritance
Record Components
cen:Validator.EntryValidator.EntryEncounter 
loc:Validator.EntryValidator.EntryEncounter 

Information used for validation for a entry in CEN and LOC.

Field Summary

Modifier and TypeField and Description
private final Validator.EntryValidator.EntryEncounter
cen

Record Component accessed by cen().

private final Validator.EntryValidator.EntryEncounter
loc

Record Component accessed by loc().

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Validator.EntryValidator.EntryEncounter
cen()

Record Component getter of cen.

public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public Validator.EntryValidator.EntryEncounter
loc()

Record Component getter of loc.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

cenback to summary
private final Validator.EntryValidator.EntryEncounter cen

Record Component accessed by cen().

locback to summary
private final Validator.EntryValidator.EntryEncounter loc

Record Component accessed by loc().

Constructor Detail

EntryInfoback to summary
pack-priv EntryInfo(Validator.EntryValidator.EntryEncounter cen, Validator.EntryValidator.EntryEncounter loc)

Method Detail

cenback to summary
public Validator.EntryValidator.EntryEncounter cen()

Record Component getter of cen.

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

locback to summary
public Validator.EntryValidator.EntryEncounter loc()

Record Component getter of loc.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

sun.tools.jar back to summary

pack-priv Class Validator.InvalidJarException

extends RuntimeException
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
pack-priv

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.lang.RuntimeException.serialVersionUID.

Constructor Detail

InvalidJarExceptionback to summary
pack-priv InvalidJarException(String msg)