Skip to content

Commit

Permalink
Repatch Image Reader Registry for WBMP Confusion
Browse files Browse the repository at this point in the history
Here's a workaround for 8ce20c9 that doesn't get in the way of modularity.
We can simply give our ICO reader precedence over all the WBMP readers.
This is kind of moot though since anywhere we are reading images we
should be requesting a reader given appropriate information from the
context, such as retrieving a reader from ImageIO using file extensions.
For now, since it's hard to tell which Java 7 subversion the bug was
patched, we can keep this small workaround.
  • Loading branch information
RobertBColton committed Jun 4, 2021
1 parent 47e4c74 commit befd847
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions org/lateralgm/main/LGM.java
Expand Up @@ -47,14 +47,18 @@
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Scanner;
import java.util.jar.JarFile;
import java.util.jar.Manifest;

import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.spi.IIORegistry;
import javax.imageio.spi.ImageReaderSpi;
import javax.swing.AbstractButton;
import javax.swing.Box;
import javax.swing.DefaultComboBoxModel;
Expand Down Expand Up @@ -125,7 +129,7 @@

public final class LGM
{
public static final String version = "1.8.231"; //$NON-NLS-1$
public static final String version = "1.8.232"; //$NON-NLS-1$

// TODO: This list holds the class loader for any loaded plugins which should be
// cleaned up and closed when the application closes.
Expand Down Expand Up @@ -158,7 +162,17 @@ public final class LGM

//Tweak service providers
IIORegistry reg = IIORegistry.getDefaultInstance();
reg.registerServiceProvider(new ICOImageReaderSPI());
ICOImageReaderSPI icoSPI = new ICOImageReaderSPI();
reg.registerServiceProvider(icoSPI);
//Java 6 confuses ICO as WBMP causing exception
//Patch: Make ICO reader take precedence over all WBMP readers.
//https://bugs.openjdk.java.net/browse/JDK-6633448
Iterator<ImageReader> wbmpReaders = ImageIO.getImageReadersByFormatName("wbmp"); //$NON-NLS-1$
while (wbmpReaders.hasNext())
{
ImageReader reader = wbmpReaders.next();
reg.setOrdering(ImageReaderSpi.class,icoSPI,reader.getOriginatingProvider());
}

//Setup workdir and tempdir
try
Expand Down

0 comments on commit befd847

Please sign in to comment.