RFR: 8277983: Remove unused fields from s.n.w.p.j.JarURLConnection

Daniel Fuchs dfuchs at openjdk.java.net
Tue Jan 25 17:24:35 UTC 2022


On Wed, 1 Dec 2021 18:36:30 GMT, Сергей Цыпанов <duke at openjdk.java.net> wrote:

> There are some fields that are unused in current implementation of `JarURLConnection`:
> - debug
> - jarFileURL
> - permission
> - jarFileURLConnection (inherited one can be used)
> - entryName (can be taken from super-class)
> 
> They can be safely removed reducing object footprint. Before:
> 
> sun.net.www.protocol.jar.JarURLConnection object internals:
>  OFFSET  SIZE                        TYPE DESCRIPTION                               VALUE
>       0    12                             (object header)                           N/A
>      12     4                         int URLConnection.connectTimeout              N/A
>      16     8                        long URLConnection.ifModifiedSince             N/A
>      24     4                         int URLConnection.readTimeout                 N/A
>      28     1                     boolean URLConnection.doInput                     N/A
>      29     1                     boolean URLConnection.doOutput                    N/A
>      30     1                     boolean URLConnection.allowUserInteraction        N/A
>      31     1                     boolean URLConnection.useCaches                   N/A
>      32     1                     boolean URLConnection.connected                   N/A
>      33     3                             (alignment/padding gap)                  
>      36     4                java.net.URL URLConnection.url                         N/A
>      40     4   sun.net.www.MessageHeader URLConnection.requests                    N/A
>      44     4                java.net.URL JarURLConnection.jarFileURL               N/A
>      48     4            java.lang.String JarURLConnection.entryName                N/A
>      52     4      java.net.URLConnection JarURLConnection.jarFileURLConnection     N/A
>      56     4                java.net.URL JarURLConnection.jarFileURL               N/A
>      60     4    java.security.Permission JarURLConnection.permission               N/A
>      64     4      java.net.URLConnection JarURLConnection.jarFileURLConnection     N/A
>      68     4            java.lang.String JarURLConnection.entryName                N/A
>      72     4      java.util.jar.JarEntry JarURLConnection.jarEntry                 N/A
>      76     4       java.util.jar.JarFile JarURLConnection.jarFile                  N/A
>      80     4            java.lang.String JarURLConnection.contentType              N/A
>      84     4                             (loss due to the next object alignment)
> Instance size: 88 bytes
> Space losses: 3 bytes internal + 4 bytes external = 7 bytes total
> 
> After:
> 
> sun.net.www.protocol.jar.JarURLConnection object internals:
>  OFFSET  SIZE                        TYPE DESCRIPTION                               VALUE
>       0    12                             (object header)                           N/A
>      12     4                         int URLConnection.connectTimeout              N/A
>      16     8                        long URLConnection.ifModifiedSince             N/A
>      24     4                         int URLConnection.readTimeout                 N/A
>      28     1                     boolean URLConnection.doInput                     N/A
>      29     1                     boolean URLConnection.doOutput                    N/A
>      30     1                     boolean URLConnection.allowUserInteraction        N/A
>      31     1                     boolean URLConnection.useCaches                   N/A
>      32     1                     boolean URLConnection.connected                   N/A
>      33     3                             (alignment/padding gap)                  
>      36     4                java.net.URL URLConnection.url                         N/A
>      40     4   sun.net.www.MessageHeader URLConnection.requests                    N/A
>      44     4                java.net.URL JarURLConnection.jarFileURL               N/A
>      48     4            java.lang.String JarURLConnection.entryName                N/A
>      52     4      java.net.URLConnection JarURLConnection.jarFileURLConnection     N/A
>      56     4      java.util.jar.JarEntry JarURLConnection.jarEntry                 N/A
>      60     4       java.util.jar.JarFile JarURLConnection.jarFile                  N/A
>      64     4            java.lang.String JarURLConnection.contentType              N/A
>      68     4                             (loss due to the next object alignment)
> Instance size: 72 bytes
> Space losses: 3 bytes internal + 4 bytes external = 7 bytes total

LGTM

Drop me a note after integrating and I will sponsor.

-------------

Marked as reviewed by dfuchs (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/6649


More information about the net-dev mailing list