Created
February 21, 2020 06:42
-
-
Save jdoe1024/945cda9e72312147adb12cac0c7d5c2d to your computer and use it in GitHub Desktop.
Java classes/interfaces name collisions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# curl https://docs.oracle.com/en/java/javase/11/docs/api/allclasses.html | ./collision.py | |
# curl https://docs.oracle.com/javase/8/docs/api/allclasses-frame.html | ./collision.py | |
import sys, re, collections | |
def readall(fh): | |
data = '' | |
while True: | |
chunk = fh.read() | |
if len(chunk) == 0: | |
return data | |
data += chunk | |
def main(): | |
# <li><a href="javax/swing/AbstractAction.html" title="class in javax.swing" target="classFrame">AbstractAction</a></li> | |
# <li><a href="java.desktop/java/awt/desktop/AboutEvent.html" title="class in java.awt.desktop">AboutEvent</a></li> | |
good_base = set(['java', 'javax']) | |
html = readall(sys.stdin) | |
classes = collections.defaultdict(list) | |
for m in re.finditer(r'<li><a href="([^"]+)"([^>]*)>', html): | |
url = m.group(1) | |
# Remove extension and split | |
parts = url[:-5].split('/') | |
if parts[0].find('.') != -1: | |
# Strip module info if any (e.g., "java.desktop") | |
parts = parts[1:] | |
if parts[0] not in good_base: | |
# Ignore non java/javax base | |
continue | |
name = parts[-1] | |
path = '.'.join(parts) | |
classes[name].append(path) | |
count = 0 | |
for name in sorted(classes.iterkeys()): | |
paths = classes[name] | |
if len(paths) < 2: | |
continue | |
print('%s: %s' % (name, paths)) | |
count += 1 | |
print('Found %d collisions' % (count,)) | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AclEntry: ['java.nio.file.attribute.AclEntry', 'java.security.acl.AclEntry'] | |
AlreadyBoundException: ['java.nio.channels.AlreadyBoundException', 'java.rmi.AlreadyBoundException'] | |
Annotation: ['java.lang.annotation.Annotation', 'java.text.Annotation'] | |
Array: ['java.lang.reflect.Array', 'java.sql.Array'] | |
ArrayType: ['javax.lang.model.type.ArrayType', 'javax.management.openmbean.ArrayType'] | |
Attribute: ['javax.management.Attribute', 'javax.naming.directory.Attribute', 'javax.print.attribute.Attribute', 'javax.xml.stream.events.Attribute'] | |
AttributeList: ['javax.management.AttributeList', 'javax.swing.text.html.parser.AttributeList'] | |
AttributeSet: ['javax.print.attribute.AttributeSet', 'javax.swing.text.AttributeSet'] | |
Attributes: ['java.util.jar.Attributes', 'javax.naming.directory.Attributes'] | |
AuthenticationException: ['javax.naming.AuthenticationException', 'javax.security.sasl.AuthenticationException'] | |
Certificate: ['java.security.cert.Certificate', 'java.security.Certificate', 'javax.security.cert.Certificate'] | |
CertificateEncodingException: ['java.security.cert.CertificateEncodingException', 'javax.security.cert.CertificateEncodingException'] | |
CertificateException: ['java.security.cert.CertificateException', 'javax.security.cert.CertificateException'] | |
CertificateExpiredException: ['java.security.cert.CertificateExpiredException', 'javax.security.cert.CertificateExpiredException'] | |
CertificateNotYetValidException: ['java.security.cert.CertificateNotYetValidException', 'javax.security.cert.CertificateNotYetValidException'] | |
CertificateParsingException: ['java.security.cert.CertificateParsingException', 'javax.security.cert.CertificateParsingException'] | |
Configuration: ['java.lang.module.Configuration', 'javax.security.auth.login.Configuration'] | |
ConnectException: ['java.net.ConnectException', 'java.rmi.ConnectException'] | |
Control: ['javax.naming.ldap.Control', 'javax.sound.sampled.Control'] | |
DTD: ['javax.swing.text.html.parser.DTD', 'javax.xml.stream.events.DTD'] | |
Date: ['java.sql.Date', 'java.util.Date'] | |
DefaultLoaderRepository: ['javax.management.DefaultLoaderRepository', 'javax.management.loading.DefaultLoaderRepository'] | |
Duration: ['java.time.Duration', 'javax.xml.datatype.Duration'] | |
Element: ['javax.lang.model.element.Element', 'javax.swing.text.Element', 'javax.swing.text.html.parser.Element'] | |
FactoryConfigurationError: ['javax.xml.parsers.FactoryConfigurationError', 'javax.xml.stream.FactoryConfigurationError'] | |
FileFilter: ['java.io.FileFilter', 'javax.swing.filechooser.FileFilter'] | |
Formatter: ['java.util.Formatter', 'java.util.logging.Formatter'] | |
IntrospectionException: ['java.beans.IntrospectionException', 'javax.management.IntrospectionException'] | |
InvalidAttributeValueException: ['javax.management.InvalidAttributeValueException', 'javax.naming.directory.InvalidAttributeValueException'] | |
InvalidKeyException: ['java.security.InvalidKeyException', 'javax.management.openmbean.InvalidKeyException'] | |
List: ['java.awt.List', 'java.util.List'] | |
Manifest: ['java.util.jar.Manifest', 'javax.xml.crypto.dsig.Manifest'] | |
MarshalException: ['java.rmi.MarshalException', 'javax.xml.crypto.MarshalException'] | |
Modifier: ['java.lang.reflect.Modifier', 'javax.lang.model.element.Modifier'] | |
Name: ['javax.lang.model.element.Name', 'javax.naming.Name'] | |
OpenType: ['java.awt.font.OpenType', 'javax.management.openmbean.OpenType'] | |
ParagraphView: ['javax.swing.text.html.ParagraphView', 'javax.swing.text.ParagraphView'] | |
Permission: ['java.security.acl.Permission', 'java.security.Permission'] | |
Predicate: ['java.util.function.Predicate', 'javax.sql.rowset.Predicate'] | |
Proxy: ['java.lang.reflect.Proxy', 'java.net.Proxy'] | |
Reference: ['java.lang.ref.Reference', 'javax.naming.Reference', 'javax.xml.crypto.dsig.Reference'] | |
Statement: ['java.beans.Statement', 'java.sql.Statement'] | |
Timer: ['java.util.Timer', 'javax.management.timer.Timer', 'javax.swing.Timer'] | |
Timestamp: ['java.security.Timestamp', 'java.sql.Timestamp'] | |
ToolProvider: ['java.util.spi.ToolProvider', 'javax.tools.ToolProvider'] | |
TypeVariable: ['java.lang.reflect.TypeVariable', 'javax.lang.model.type.TypeVariable'] | |
Types: ['java.sql.Types', 'javax.lang.model.util.Types'] | |
UnknownHostException: ['java.net.UnknownHostException', 'java.rmi.UnknownHostException'] | |
WildcardType: ['java.lang.reflect.WildcardType', 'javax.lang.model.type.WildcardType'] | |
X509Certificate: ['java.security.cert.X509Certificate', 'javax.security.cert.X509Certificate'] | |
Found 50 collisions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AclEntry: ['java.nio.file.attribute.AclEntry', 'java.security.acl.AclEntry'] | |
Action: ['javax.swing.Action', 'javax.xml.ws.Action'] | |
AlreadyBoundException: ['java.nio.channels.AlreadyBoundException', 'java.rmi.AlreadyBoundException'] | |
Annotation: ['java.lang.annotation.Annotation', 'java.text.Annotation'] | |
Array: ['java.lang.reflect.Array', 'java.sql.Array'] | |
ArrayType: ['javax.lang.model.type.ArrayType', 'javax.management.openmbean.ArrayType'] | |
Attribute: ['javax.management.Attribute', 'javax.naming.directory.Attribute', 'javax.print.attribute.Attribute', 'javax.xml.stream.events.Attribute'] | |
AttributeList: ['javax.management.AttributeList', 'javax.swing.text.html.parser.AttributeList'] | |
AttributeSet: ['javax.print.attribute.AttributeSet', 'javax.swing.text.AttributeSet'] | |
Attributes: ['java.util.jar.Attributes', 'javax.naming.directory.Attributes'] | |
AuthenticationException: ['javax.naming.AuthenticationException', 'javax.security.sasl.AuthenticationException'] | |
Binding: ['javax.naming.Binding', 'javax.xml.ws.Binding'] | |
Certificate: ['java.security.cert.Certificate', 'java.security.Certificate', 'javax.security.cert.Certificate'] | |
CertificateEncodingException: ['java.security.cert.CertificateEncodingException', 'javax.security.cert.CertificateEncodingException'] | |
CertificateException: ['java.security.cert.CertificateException', 'javax.security.cert.CertificateException'] | |
CertificateExpiredException: ['java.security.cert.CertificateExpiredException', 'javax.security.cert.CertificateExpiredException'] | |
CertificateNotYetValidException: ['java.security.cert.CertificateNotYetValidException', 'javax.security.cert.CertificateNotYetValidException'] | |
CertificateParsingException: ['java.security.cert.CertificateParsingException', 'javax.security.cert.CertificateParsingException'] | |
ConnectException: ['java.net.ConnectException', 'java.rmi.ConnectException'] | |
Control: ['javax.naming.ldap.Control', 'javax.sound.sampled.Control'] | |
DTD: ['javax.swing.text.html.parser.DTD', 'javax.xml.stream.events.DTD'] | |
DataSource: ['javax.activation.DataSource', 'javax.sql.DataSource'] | |
Date: ['java.sql.Date', 'java.util.Date'] | |
DefaultLoaderRepository: ['javax.management.DefaultLoaderRepository', 'javax.management.loading.DefaultLoaderRepository'] | |
Duration: ['java.time.Duration', 'javax.xml.datatype.Duration'] | |
Element: ['javax.lang.model.element.Element', 'javax.swing.text.Element', 'javax.swing.text.html.parser.Element', 'javax.xml.bind.Element'] | |
FactoryConfigurationError: ['javax.xml.parsers.FactoryConfigurationError', 'javax.xml.stream.FactoryConfigurationError'] | |
FileFilter: ['java.io.FileFilter', 'javax.swing.filechooser.FileFilter'] | |
Formatter: ['java.util.Formatter', 'java.util.logging.Formatter'] | |
Handler: ['java.util.logging.Handler', 'javax.xml.ws.handler.Handler'] | |
IntrospectionException: ['java.beans.IntrospectionException', 'javax.management.IntrospectionException'] | |
InvalidAttributeValueException: ['javax.management.InvalidAttributeValueException', 'javax.naming.directory.InvalidAttributeValueException'] | |
InvalidKeyException: ['java.security.InvalidKeyException', 'javax.management.openmbean.InvalidKeyException'] | |
List: ['java.awt.List', 'java.util.List'] | |
Manifest: ['java.util.jar.Manifest', 'javax.xml.crypto.dsig.Manifest'] | |
MarshalException: ['java.rmi.MarshalException', 'javax.xml.bind.MarshalException', 'javax.xml.crypto.MarshalException'] | |
MimeTypeParseException: ['java.awt.datatransfer.MimeTypeParseException', 'javax.activation.MimeTypeParseException'] | |
Modifier: ['java.lang.reflect.Modifier', 'javax.lang.model.element.Modifier'] | |
Name: ['javax.lang.model.element.Name', 'javax.naming.Name', 'javax.xml.soap.Name'] | |
OpenType: ['java.awt.font.OpenType', 'javax.management.openmbean.OpenType'] | |
ParagraphView: ['javax.swing.text.html.ParagraphView', 'javax.swing.text.ParagraphView'] | |
Permission: ['java.security.acl.Permission', 'java.security.Permission'] | |
Policy: ['java.security.Policy', 'javax.security.auth.Policy'] | |
Predicate: ['java.util.function.Predicate', 'javax.sql.rowset.Predicate'] | |
ProtocolException: ['java.net.ProtocolException', 'javax.xml.ws.ProtocolException'] | |
Provider: ['java.security.Provider', 'javax.xml.ws.Provider', 'javax.xml.ws.spi.Provider'] | |
Proxy: ['java.lang.reflect.Proxy', 'java.net.Proxy'] | |
Reference: ['java.lang.ref.Reference', 'javax.naming.Reference', 'javax.xml.crypto.dsig.Reference'] | |
SOAPBinding: ['javax.jws.soap.SOAPBinding', 'javax.xml.ws.soap.SOAPBinding'] | |
Statement: ['java.beans.Statement', 'java.sql.Statement'] | |
Timer: ['java.util.Timer', 'javax.management.timer.Timer', 'javax.swing.Timer'] | |
Timestamp: ['java.security.Timestamp', 'java.sql.Timestamp'] | |
TypeVariable: ['java.lang.reflect.TypeVariable', 'javax.lang.model.type.TypeVariable'] | |
Types: ['java.sql.Types', 'javax.lang.model.util.Types'] | |
UnknownHostException: ['java.net.UnknownHostException', 'java.rmi.UnknownHostException'] | |
UnmarshalException: ['java.rmi.UnmarshalException', 'javax.xml.bind.UnmarshalException'] | |
Validator: ['javax.xml.bind.Validator', 'javax.xml.validation.Validator'] | |
WildcardType: ['java.lang.reflect.WildcardType', 'javax.lang.model.type.WildcardType'] | |
X509Certificate: ['java.security.cert.X509Certificate', 'javax.security.cert.X509Certificate'] | |
Found 59 collisions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment