mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8323794: Remove unused jimage compressor plugin configuration
Reviewed-by: jlaskey, mchung
This commit is contained in:
parent
7be9f1d054
commit
8b29e127c2
13 changed files with 47 additions and 84 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -27,7 +27,6 @@ package jdk.internal.jimage.decompressor;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Objects;
|
||||
import jdk.internal.jimage.decompressor.ResourceDecompressor.StringsProvider;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -45,19 +44,25 @@ public final class CompressedResourceHeader {
|
|||
|
||||
private static final int SIZE = 29;
|
||||
public static final int MAGIC = 0xCAFEFAFA;
|
||||
|
||||
// Standard header offsets
|
||||
private static final int MAGIC_OFFSET = 0; // 4 bytes
|
||||
private static final int COMPRESSED_OFFSET = 4; // 8 bytes
|
||||
private static final int UNCOMPRESSED_OFFSET = 12; // 8 bytes
|
||||
private static final int DECOMPRESSOR_NAME_OFFSET = 20; // 4 bytes, followed by 4 byte gap
|
||||
private static final int IS_TERMINAL_OFFSET = 28; // 1 byte
|
||||
|
||||
private final long uncompressedSize;
|
||||
private final long compressedSize;
|
||||
private final int decompressorNameOffset;
|
||||
private final int contentOffset;
|
||||
private final boolean isTerminal;
|
||||
|
||||
public CompressedResourceHeader(long compressedSize,
|
||||
long uncompressedSize, int decompressorNameOffset, int contentOffset,
|
||||
long uncompressedSize, int decompressorNameOffset,
|
||||
boolean isTerminal) {
|
||||
this.compressedSize = compressedSize;
|
||||
this.uncompressedSize = uncompressedSize;
|
||||
this.decompressorNameOffset = decompressorNameOffset;
|
||||
this.contentOffset = contentOffset;
|
||||
this.isTerminal = isTerminal;
|
||||
}
|
||||
|
||||
|
@ -69,18 +74,6 @@ public final class CompressedResourceHeader {
|
|||
return decompressorNameOffset;
|
||||
}
|
||||
|
||||
public int getContentOffset() {
|
||||
return contentOffset;
|
||||
}
|
||||
|
||||
public String getStoredContent(StringsProvider provider) {
|
||||
Objects.requireNonNull(provider);
|
||||
if(contentOffset == -1) {
|
||||
return null;
|
||||
}
|
||||
return provider.getString(contentOffset);
|
||||
}
|
||||
|
||||
public long getUncompressedSize() {
|
||||
return uncompressedSize;
|
||||
}
|
||||
|
@ -97,7 +90,8 @@ public final class CompressedResourceHeader {
|
|||
buffer.putLong(compressedSize);
|
||||
buffer.putLong(uncompressedSize);
|
||||
buffer.putInt(decompressorNameOffset);
|
||||
buffer.putInt(contentOffset);
|
||||
// Compatibility
|
||||
buffer.putInt(-1);
|
||||
buffer.put(isTerminal ? (byte)1 : (byte)0);
|
||||
return buffer.array();
|
||||
}
|
||||
|
@ -115,16 +109,16 @@ public final class CompressedResourceHeader {
|
|||
}
|
||||
ByteBuffer buffer = ByteBuffer.wrap(resource, 0, SIZE);
|
||||
buffer.order(order);
|
||||
int magic = buffer.getInt();
|
||||
if(magic != MAGIC) {
|
||||
int magic = buffer.getInt(MAGIC_OFFSET);
|
||||
if (magic != MAGIC) {
|
||||
return null;
|
||||
}
|
||||
long size = buffer.getLong();
|
||||
long uncompressedSize = buffer.getLong();
|
||||
int decompressorNameOffset = buffer.getInt();
|
||||
int contentIndex = buffer.getInt();
|
||||
byte isTerminal = buffer.get();
|
||||
long size = buffer.getLong(COMPRESSED_OFFSET);
|
||||
long uncompressedSize = buffer.getLong(UNCOMPRESSED_OFFSET);
|
||||
int decompressorNameOffset = buffer.getInt(DECOMPRESSOR_NAME_OFFSET);
|
||||
// skip unused 'contentOffset' int
|
||||
byte isTerminal = buffer.get(IS_TERMINAL_OFFSET);
|
||||
return new CompressedResourceHeader(size, uncompressedSize,
|
||||
decompressorNameOffset, contentIndex, isTerminal == 1);
|
||||
decompressorNameOffset, isTerminal == 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -24,14 +24,11 @@
|
|||
*/
|
||||
package jdk.internal.jimage.decompressor;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Properties;
|
||||
import jdk.internal.jimage.decompressor.ResourceDecompressor.StringsProvider;
|
||||
|
||||
/**
|
||||
|
@ -75,17 +72,8 @@ public final class Decompressor {
|
|||
if (pluginName == null) {
|
||||
throw new IOException("Plugin name not found");
|
||||
}
|
||||
String storedContent = header.getStoredContent(provider);
|
||||
Properties props = new Properties();
|
||||
if (storedContent != null) {
|
||||
try (ByteArrayInputStream stream
|
||||
= new ByteArrayInputStream(storedContent.
|
||||
getBytes(StandardCharsets.UTF_8));) {
|
||||
props.loadFromXML(stream);
|
||||
}
|
||||
}
|
||||
decompressor = ResourceDecompressorRepository.
|
||||
newResourceDecompressor(props, pluginName);
|
||||
newResourceDecompressor(pluginName);
|
||||
if (decompressor == null) {
|
||||
throw new IOException("Plugin not found: " + pluginName);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -25,7 +25,6 @@
|
|||
package jdk.internal.jimage.decompressor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -54,12 +53,10 @@ public abstract class ResourceDecompressorFactory {
|
|||
|
||||
/**
|
||||
* To build a new decompressor.
|
||||
* @param properties Contains configuration.
|
||||
* @return A new decompressor.
|
||||
* @throws IOException
|
||||
*/
|
||||
public abstract ResourceDecompressor newDecompressor(Properties properties)
|
||||
throws IOException;
|
||||
public abstract ResourceDecompressor newDecompressor() throws IOException;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -27,7 +27,6 @@ package jdk.internal.jimage.decompressor;
|
|||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -54,17 +53,15 @@ public final class ResourceDecompressorRepository {
|
|||
|
||||
/**
|
||||
* Build a new decompressor for the passed name.
|
||||
* @param properties Contains plugin configuration.
|
||||
* @param name The plugin name to build.
|
||||
* @return A decompressor or null if not found
|
||||
* @throws IOException
|
||||
*/
|
||||
public static ResourceDecompressor newResourceDecompressor(Properties properties,
|
||||
String name) throws IOException {
|
||||
public static ResourceDecompressor newResourceDecompressor(String name) throws IOException {
|
||||
|
||||
ResourceDecompressorFactory fact = factories.get(name);
|
||||
if (fact != null) {
|
||||
return fact.newDecompressor(properties);
|
||||
return fact.newDecompressor();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -33,7 +33,6 @@ import java.nio.ByteBuffer;
|
|||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -228,9 +227,7 @@ public class StringSharingDecompressor implements ResourceDecompressor {
|
|||
return StringSharingDecompressorFactory.NAME;
|
||||
}
|
||||
|
||||
public StringSharingDecompressor(Properties properties) {
|
||||
|
||||
}
|
||||
public StringSharingDecompressor() {}
|
||||
|
||||
@Override
|
||||
public byte[] decompress(StringsProvider reader, byte[] content,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -25,7 +25,6 @@
|
|||
package jdk.internal.jimage.decompressor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -45,8 +44,8 @@ public class StringSharingDecompressorFactory extends ResourceDecompressorFactor
|
|||
}
|
||||
|
||||
@Override
|
||||
public ResourceDecompressor newDecompressor(Properties properties)
|
||||
public ResourceDecompressor newDecompressor()
|
||||
throws IOException {
|
||||
return new StringSharingDecompressor(properties);
|
||||
return new StringSharingDecompressor();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
*/
|
||||
package jdk.internal.jimage.decompressor;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.zip.Inflater;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -25,7 +25,6 @@
|
|||
package jdk.internal.jimage.decompressor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -44,7 +43,7 @@ public final class ZipDecompressorFactory extends ResourceDecompressorFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ResourceDecompressor newDecompressor(Properties properties)
|
||||
public ResourceDecompressor newDecompressor()
|
||||
throws IOException {
|
||||
return new ZipDecompressor();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue