Skip to content

Commit 660ec16

Browse files
committed
Fixed compilation of GWT edition
1 parent c70db60 commit 660ec16

File tree

7 files changed

+283
-13
lines changed

7 files changed

+283
-13
lines changed

build/build.properties

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
major-number: 2
77
minor-number: 4
88
# the last figure of the real release number: e.g. 1 in "2.2m1", "2.3rc1", "2.4.1"
9-
release-number:0
9+
release-number:1
1010
# choose among: final, snapshot, rc, milestone
1111
meta.release-type: snapshot
1212
version-minor: ${major-number}.${minor-number}
1313

1414
# Version of JDK required
1515
jdk.compilation.version: 1.8
16-
bundle.required-execution-environment: JavaSE-1.8
16+
bundle.required-execution-environment: JavaSE-1.7
1717

1818
# The base directory where a Restlet distributions is zipped
1919
# Each Restlet version will create its own file
@@ -75,3 +75,4 @@ port-number: 30000
7575

7676
# The list of generated editions ("," separated list)
7777
editions: jse,jee,android,gae,gwt,osgi
78+

build/tmpl/bundles/extractmanifestLibrary.tmpl

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
</#list>
1919
<java classname="aQute.bnd.main.bnd" fork="true">
2020
<arg value="buildx" />
21-
<arg value="-classpath" />
21+
<arg value="--classpath" />
2222
<arg value="<#list library.packages as package><#noparse>${lib}</#noparse>/${library.rootDirectory}/${package.name}.jar<#if package_has_next>,</#if></#list>" />
23-
<arg value="-noeclipse" />
24-
<arg value="-output" />
23+
<arg value="--noeclipse" />
24+
<arg value="--output" />
2525
<arg value="<#noparse>${temp}</#noparse>/${library.id}.jar" />
2626
<arg value="<#noparse>${temp}</#noparse>/definitions/libs/global.${library.id}.bnd" />
2727
<classpath refid="bnd-path" />
@@ -39,4 +39,4 @@
3939
<delete file="<#noparse>${temp}</#noparse>/${library.id}.jar" />
4040
</#list>
4141
</target>
42-
</project>
42+
</project>

build/tmpl/editions/generate-classes-extras.tmpl

+2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
<gwtCompileModule name="core" module="org.restlet.Restlet" />
55
<#elseif edition.id = "gae">
66
<#noparse>
7+
<!-- GAE now supports the standard public Java library
78
<gaeCodeChecker>
89
<jdkClassesWhiteLists dir="${tmpl}/editions" includes="gaeJdkClassesWhiteList.txt, extraGaeJdkClassesWhiteList.txt" />
910
<jdkMethodsLists dir="${tmpl}/editions" includes="gaeJdkMethodsList.txt" />
1011
<checkedClasses dir="${classes}" />
1112
</gaeCodeChecker>
13+
-->
1214
</#noparse>
1315
</#if>
1416
<!--

build/tmpl/text/changes.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ Changes log
44
===========
55

66
@version-full@ (@release-date@)
7+
8+
- 2.4 Milestone 1 (10/26/2017)
9+
10+
- Enhancements
11+
- Upgraded JDK version 1.8.
12+
- Mavenify the common source code
713
- Misc
814
- Removed deprecated extensions e4, JDBC, JSSLUtils, ROME, SDC, SIP, XDB, XStream.
915
- Deprecated extensions Javamail, Lucene, Nio, Wadl.
1016
- Refreshed copyright headers.
11-
- Upgraded JDK version 1.8.
1217
- Leveraged JDK's version of Base64.
1318
- Upgraded Jetty to version 9.3.21.v20170918. Leads to remove support of SPDY protocol.

libraries/org.simpleframework.xml_2.7/library.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<name>Simple XML</name>
33
<description>Simple XML.</description>
44
<version>2.7</version>
5-
<release>1</release>
5+
<release>3</release>
66
<homeUri>http://simple.sourceforge.net/</homeUri>
77
<downloadUri>http://simple.sourceforge.net/download.php</downloadUri>
88
<provider>Niall Gallagher</provider>
@@ -16,6 +16,7 @@
1616
</package>
1717
<distributions>
1818
<distribution id="classic" />
19+
<distribution id="maven" />
1920
</distributions>
2021
<javadocs>
2122
<link href="http://simple.sourceforge.net/download/stream/doc/javadoc/" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
/**
2+
* Copyright 2005-2014 Restlet
3+
*
4+
* The contents of this file are subject to the terms of one of the following
5+
* open source licenses: Apache 2.0 or or EPL 1.0 (the "Licenses"). You can
6+
* select the license that you prefer but you may not use this file except in
7+
* compliance with one of these Licenses.
8+
*
9+
* You can obtain a copy of the Apache 2.0 license at
10+
* http://www.opensource.org/licenses/apache-2.0
11+
*
12+
* You can obtain a copy of the EPL 1.0 license at
13+
* http://www.opensource.org/licenses/eclipse-1.0
14+
*
15+
* See the Licenses for the specific language governing permissions and
16+
* limitations under the Licenses.
17+
*
18+
* Alternatively, you can obtain a royalty free commercial license with less
19+
* limitations, transferable or non-transferable, directly at
20+
* http://restlet.com/products/restlet-framework
21+
*
22+
* Restlet is a registered trademark of Restlet S.A.S.
23+
*/
24+
25+
package org.restlet.engine.util;
26+
27+
import java.util.Arrays;
28+
29+
import org.restlet.engine.io.IoUtils;
30+
31+
/**
32+
* Minimal but fast Base64 codec.
33+
*
34+
* @author Ray Waldin (ray@waldin.net)
35+
*/
36+
public class Base64 {
37+
38+
/** alphabet used for encoding bytes into base64 */
39+
private static final char[] BASE64_DIGITS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
40+
.toCharArray();
41+
42+
/**
43+
* Decoding involves replacing each character with the character's value, or
44+
* position, from the above alphabet, and this table makes such lookups
45+
* quick and easy. Couldn't help myself with the corny name :)
46+
*/
47+
private static final byte[] DECODER_RING = new byte[128];
48+
49+
/**
50+
* Initializes the decoder ring.
51+
*/
52+
static {
53+
Arrays.fill(DECODER_RING, (byte) -1);
54+
int i = 0;
55+
for (final char c : BASE64_DIGITS) {
56+
DECODER_RING[c] = (byte) i++;
57+
}
58+
DECODER_RING['='] = 0;
59+
}
60+
61+
/**
62+
* Returns the byte value at a given position in a bytes array.
63+
*
64+
* @param data
65+
* The bytes array.
66+
* @param block
67+
* The block size.
68+
* @param off
69+
* The offset value.
70+
* @return The extracted byte.
71+
*/
72+
private final static int byteAt(byte[] data, int block, int off) {
73+
return unsign(data[(block * 3) + off]);
74+
}
75+
76+
/**
77+
* Decodes base64 characters into bytes. Newline characters found at block
78+
* boundaries will be ignored.
79+
*
80+
* @param chars
81+
* The characters array to decode.
82+
* @return The decoded byte array.
83+
*/
84+
public static byte[] decode(final char[] chars) {
85+
// prepare to ignore newline chars
86+
int newlineCount = 0;
87+
for (char c : chars) {
88+
switch (c) {
89+
case '\r':
90+
case '\n':
91+
newlineCount++;
92+
break;
93+
default:
94+
}
95+
}
96+
97+
int len = chars.length - newlineCount;
98+
99+
if (len % 4 != 0) {
100+
throw new IllegalArgumentException(
101+
"Base64.decode() requires input length to be a multiple of 4");
102+
}
103+
104+
int numBytes = ((len + 3) / 4) * 3;
105+
106+
// fix up length relative to padding
107+
if (len > 1) {
108+
if (chars[chars.length - 2] == '=') {
109+
numBytes -= 2;
110+
} else if (chars[chars.length - 1] == '=') {
111+
numBytes--;
112+
}
113+
}
114+
115+
byte[] result = new byte[numBytes];
116+
int newlineOffset = 0;
117+
118+
// decode each block of 4 chars into 3 bytes
119+
for (int i = 0; i < (len + 3) / 4; ++i) {
120+
int charOffset = newlineOffset + (i * 4);
121+
122+
final char c1 = chars[charOffset++];
123+
final char c2 = chars[charOffset++];
124+
final char c3 = chars[charOffset++];
125+
final char c4 = chars[charOffset++];
126+
127+
if (!(validChar(c1) && validChar(c2) && validChar(c3) && validChar(c4))) {
128+
throw new IllegalArgumentException(
129+
"Invalid Base64 character in block: '" + c1 + c2 + c3
130+
+ c4 + "'");
131+
}
132+
133+
// pack
134+
final int x = DECODER_RING[c1] << 18 | DECODER_RING[c2] << 12
135+
| (c3 == '=' ? 0 : DECODER_RING[c3] << 6)
136+
| (c4 == '=' ? 0 : DECODER_RING[c4]);
137+
138+
// unpack
139+
int byteOffset = i * 3;
140+
result[byteOffset++] = (byte) (x >> 16);
141+
if (c3 != '=') {
142+
result[byteOffset++] = (byte) ((x >> 8) & 0xFF);
143+
if (c4 != '=') {
144+
result[byteOffset++] = (byte) (x & 0xFF);
145+
}
146+
}
147+
148+
// skip newlines after block
149+
outer: while (chars.length > charOffset) {
150+
switch (chars[charOffset++]) {
151+
case '\r':
152+
case '\n':
153+
newlineOffset++;
154+
break;
155+
156+
default:
157+
break outer;
158+
}
159+
}
160+
}
161+
return result;
162+
};
163+
164+
/**
165+
* Decodes a base64 string into bytes. Newline characters found at block
166+
* boundaries will be ignored.
167+
*
168+
* @param encodedString
169+
* The string to decode.
170+
* @return The decoded byte array.
171+
*/
172+
public static byte[] decode(String encodedString) {
173+
return decode(encodedString.toCharArray());
174+
}
175+
176+
/**
177+
* Encodes an entire byte array into a Base64 string, with optional newlines
178+
* after every 76 characters.
179+
*
180+
* @param bytes
181+
* The byte array to encode.
182+
* @param newlines
183+
* Indicates whether or not newlines are desired.
184+
* @return The encoded string.
185+
*/
186+
public static String encode(byte[] bytes, boolean newlines) {
187+
return encode(bytes, 0, bytes.length, newlines);
188+
}
189+
190+
/**
191+
* Encodes specified bytes into a Base64 string, with optional newlines
192+
* after every 76 characters.
193+
*
194+
* @param bytes
195+
* The byte array to encode.
196+
* @param off
197+
* The starting offset.
198+
* @param len
199+
* The number of bytes to encode.
200+
* @param newlines
201+
* Indicates whether or not newlines are desired.
202+
*
203+
* @return The encoded string.
204+
*/
205+
public static String encode(byte[] bytes, int off, int len, boolean newlines) {
206+
char[] output = new char[(((len + 2) / 3) * 4)
207+
+ (newlines ? len / 43 : 0)];
208+
int pos = 0;
209+
210+
// encode each block of 3 bytes into 4 chars
211+
for (int i = 0; i < (len + 2) / 3; ++i) {
212+
int pad = 0;
213+
214+
if (len + 1 < (i + 1) * 3) {
215+
// two trailing '='s
216+
pad = 2;
217+
} else if (len < (i + 1) * 3) {
218+
// one trailing '='
219+
pad = 1;
220+
}
221+
222+
// pack
223+
int x = (byteAt(bytes, i, off) << 16)
224+
| (pad > 1 ? 0 : (byteAt(bytes, i, off + 1) << 8))
225+
| (pad > 0 ? 0 : (byteAt(bytes, i, off + 2)));
226+
227+
// unpack
228+
output[pos++] = BASE64_DIGITS[x >> 18];
229+
output[pos++] = BASE64_DIGITS[(x >> 12) & 0x3F];
230+
output[pos++] = pad > 1 ? '=' : BASE64_DIGITS[(x >> 6) & 0x3F];
231+
output[pos++] = pad > 0 ? '=' : BASE64_DIGITS[x & 0x3F];
232+
233+
if (newlines && ((i + 1) % 19 == 0)) {
234+
output[pos++] = '\n';
235+
}
236+
}
237+
return new String(output, 0, pos);
238+
}
239+
240+
/**
241+
* Computes the unsigned value of a byte.
242+
*
243+
* @param b
244+
* The input byte.
245+
* @return The output unsigned value.
246+
*/
247+
private final static int unsign(byte b) {
248+
return b < 0 ? b + 256 : b;
249+
}
250+
251+
/**
252+
* Indicates if the character is valid and can be decoded.
253+
*
254+
* @param c
255+
* The input character.
256+
* @return True if the character is valid.
257+
*/
258+
private final static boolean validChar(char c) {
259+
return (c < 128) && (DECODER_RING[c] != -1);
260+
}
261+
}

modules/org.restlet/src/main/java/org/restlet/engine/util/StringUtils.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private static class CharacterEntitySolver {
104104
*/
105105
public CharacterEntitySolver() {
106106
toName = new String[10000];
107-
toValue = new HashMap<>();
107+
toValue = new HashMap<String, Integer>();
108108
}
109109

110110
/**
@@ -160,12 +160,12 @@ public Integer getValue(String name) {
160160
private static List<CharacterEntity> xml10;
161161

162162
static {
163-
xml10 = new ArrayList<>();
163+
xml10 = new ArrayList<CharacterEntity>();
164164
xml10.add(new CharacterEntity(34, "quot"));
165165
xml10.add(new CharacterEntity(38, "amp"));
166166
xml10.add(new CharacterEntity(62, "gt"));
167167
xml10.add(new CharacterEntity(60, "lt"));
168-
htmlLat1 = new ArrayList<>();
168+
htmlLat1 = new ArrayList<CharacterEntity>();
169169
htmlLat1.add(new CharacterEntity(160, "nbsp"));
170170
htmlLat1.add(new CharacterEntity(161, "iexcl"));
171171
htmlLat1.add(new CharacterEntity(162, "cent"));
@@ -262,7 +262,7 @@ public Integer getValue(String name) {
262262
htmlLat1.add(new CharacterEntity(253, "yacute"));
263263
htmlLat1.add(new CharacterEntity(254, "thorn"));
264264
htmlLat1.add(new CharacterEntity(255, "yuml"));
265-
htmlSymbol = new ArrayList<>();
265+
htmlSymbol = new ArrayList<CharacterEntity>();
266266
htmlSymbol.add(new CharacterEntity(402, "fnof"));
267267
htmlSymbol.add(new CharacterEntity(913, "Alpha"));
268268
htmlSymbol.add(new CharacterEntity(914, "Beta"));
@@ -386,7 +386,7 @@ public Integer getValue(String name) {
386386
htmlSymbol.add(new CharacterEntity(9827, "clubs"));
387387
htmlSymbol.add(new CharacterEntity(9829, "hearts"));
388388
htmlSymbol.add(new CharacterEntity(9830, "diams"));
389-
htmlSpecial = new ArrayList<>();
389+
htmlSpecial = new ArrayList<CharacterEntity>();
390390
htmlSpecial.add(new CharacterEntity(34, "quot"));
391391
htmlSpecial.add(new CharacterEntity(38, "amp"));
392392
htmlSpecial.add(new CharacterEntity(39, "apos"));

0 commit comments

Comments
 (0)