From 4306f978fecb85ad49f5f147db6cf063305bf7b6 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Tue, 19 Jun 2018 00:09:48 +0200 Subject: [SCL] update that should make it a little easier to add custom lombok handlers. --- src/launch/lombok/launch/ShadowClassLoader.java | 27 ++++++++----------------- 1 file changed, 8 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/launch/lombok/launch/ShadowClassLoader.java b/src/launch/lombok/launch/ShadowClassLoader.java index 70c58fb6..cd11720a 100644 --- a/src/launch/lombok/launch/ShadowClassLoader.java +++ b/src/launch/lombok/launch/ShadowClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2016 The Project Lombok Authors. + * Copyright (C) 2014-2018 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -33,7 +33,6 @@ import java.net.MalformedURLException; import java.net.URI; import java.net.URL; import java.net.URLDecoder; -import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Collections; import java.util.Enumeration; @@ -73,6 +72,7 @@ import java.util.zip.ZipInputStream; * * If no overrides are present, the load order is as follows: *
  • First, if the resource is found in our own jar (trying ".SCL.sclSuffix" first for any resource request ending in ".class"), return that. + *
  • Next, check any jar files other than our own, loading them via this classloader, if they have a file META-INF/ShadowClassLoader that contains a line of text with sclSuffix. *
  • Next, ask the parent loader. * * @@ -117,9 +117,7 @@ class ShadowClassLoader extends ClassLoader { if (!pe.endsWith("/")) pe = pe + "/"; this.parentExclusion.add(pe); } - if (highlanders != null) for (String hl : highlanders) { - this.highlanders.add(hl); - } + if (highlanders != null) for (String hl : highlanders) this.highlanders.add(hl); if (selfBase != null) { SELF_BASE = selfBase; @@ -128,12 +126,7 @@ class ShadowClassLoader extends ClassLoader { String sclClassUrl = ShadowClassLoader.class.getResource("ShadowClassLoader.class").toString(); if (!sclClassUrl.endsWith(SELF_NAME)) throw new InternalError("ShadowLoader can't find itself."); SELF_BASE_LENGTH = sclClassUrl.length() - SELF_NAME.length(); - String decoded; - try { - decoded = URLDecoder.decode(sclClassUrl.substring(0, SELF_BASE_LENGTH), "UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new InternalError("UTF-8 not available"); - } + String decoded = urlDecode(sclClassUrl.substring(0, SELF_BASE_LENGTH)); SELF_BASE = decoded; } @@ -151,11 +144,11 @@ class ShadowClassLoader extends ClassLoader { } } } - + private final Map mapJarPathToTracker = new HashMap(); private static final Map mapTrackerToJarPath = new WeakHashMap(); private static final Map> mapTrackerToJarContents = new WeakHashMap>(); - + /** * This cache ensures that any given jar file is only opened once in order to determine the full contents of it. * We use 'trackers' to make sure that the bulk of the memory taken up by this cache (the list of strings representing the content of a jar file) @@ -324,13 +317,9 @@ class ShadowClassLoader extends ClassLoader { private static String urlDecode(String in) { try { - return URLDecoder.decode(in, Charset.defaultCharset().name()); + return URLDecoder.decode(in, "UTF-8"); } catch (UnsupportedEncodingException e) { - try { - return URLDecoder.decode(in, "UTF-8"); - } catch (UnsupportedEncodingException e1) { - return in; - } + throw new InternalError("UTF-8 not supported"); } } -- cgit