Skip to content

Commit

Permalink
Fixed compilation of GWT edition
Browse files Browse the repository at this point in the history
  • Loading branch information
thboileau committed Oct 26, 2017
1 parent c70db60 commit 660ec16
Show file tree
Hide file tree
Showing 7 changed files with 283 additions and 13 deletions.
5 changes: 3 additions & 2 deletions build/build.properties
Expand Up @@ -6,14 +6,14 @@
major-number: 2
minor-number: 4
# the last figure of the real release number: e.g. 1 in "2.2m1", "2.3rc1", "2.4.1"
release-number:0
release-number:1
# choose among: final, snapshot, rc, milestone
meta.release-type: snapshot
version-minor: ${major-number}.${minor-number}

# Version of JDK required
jdk.compilation.version: 1.8
bundle.required-execution-environment: JavaSE-1.8
bundle.required-execution-environment: JavaSE-1.7

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

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

8 changes: 4 additions & 4 deletions build/tmpl/bundles/extractmanifestLibrary.tmpl
Expand Up @@ -18,10 +18,10 @@
</#list>
<java classname="aQute.bnd.main.bnd" fork="true">
<arg value="buildx" />
<arg value="-classpath" />
<arg value="--classpath" />
<arg value="<#list library.packages as package><#noparse>${lib}</#noparse>/${library.rootDirectory}/${package.name}.jar<#if package_has_next>,</#if></#list>" />
<arg value="-noeclipse" />
<arg value="-output" />
<arg value="--noeclipse" />
<arg value="--output" />
<arg value="<#noparse>${temp}</#noparse>/${library.id}.jar" />
<arg value="<#noparse>${temp}</#noparse>/definitions/libs/global.${library.id}.bnd" />
<classpath refid="bnd-path" />
Expand All @@ -39,4 +39,4 @@
<delete file="<#noparse>${temp}</#noparse>/${library.id}.jar" />
</#list>
</target>
</project>
</project>
2 changes: 2 additions & 0 deletions build/tmpl/editions/generate-classes-extras.tmpl
Expand Up @@ -4,11 +4,13 @@
<gwtCompileModule name="core" module="org.restlet.Restlet" />
<#elseif edition.id = "gae">
<#noparse>
<!-- GAE now supports the standard public Java library
<gaeCodeChecker>
<jdkClassesWhiteLists dir="${tmpl}/editions" includes="gaeJdkClassesWhiteList.txt, extraGaeJdkClassesWhiteList.txt" />
<jdkMethodsLists dir="${tmpl}/editions" includes="gaeJdkMethodsList.txt" />
<checkedClasses dir="${classes}" />
</gaeCodeChecker>
-->
</#noparse>
</#if>
<!--
Expand Down
7 changes: 6 additions & 1 deletion build/tmpl/text/changes.txt
Expand Up @@ -4,10 +4,15 @@ Changes log
===========

@version-full@ (@release-date@)

- 2.4 Milestone 1 (10/26/2017)

- Enhancements
- Upgraded JDK version 1.8.
- Mavenify the common source code
- Misc
- Removed deprecated extensions e4, JDBC, JSSLUtils, ROME, SDC, SIP, XDB, XStream.
- Deprecated extensions Javamail, Lucene, Nio, Wadl.
- Refreshed copyright headers.
- Upgraded JDK version 1.8.
- Leveraged JDK's version of Base64.
- Upgraded Jetty to version 9.3.21.v20170918. Leads to remove support of SPDY protocol.
3 changes: 2 additions & 1 deletion libraries/org.simpleframework.xml_2.7/library.xml
Expand Up @@ -2,7 +2,7 @@
<name>Simple XML</name>
<description>Simple XML.</description>
<version>2.7</version>
<release>1</release>
<release>3</release>
<homeUri>http://simple.sourceforge.net/</homeUri>
<downloadUri>http://simple.sourceforge.net/download.php</downloadUri>
<provider>Niall Gallagher</provider>
Expand All @@ -16,6 +16,7 @@
</package>
<distributions>
<distribution id="classic" />
<distribution id="maven" />
</distributions>
<javadocs>
<link href="http://simple.sourceforge.net/download/stream/doc/javadoc/" />
Expand Down
@@ -0,0 +1,261 @@
/**
* Copyright 2005-2014 Restlet
*
* The contents of this file are subject to the terms of one of the following
* open source licenses: Apache 2.0 or or EPL 1.0 (the "Licenses"). You can
* select the license that you prefer but you may not use this file except in
* compliance with one of these Licenses.
*
* You can obtain a copy of the Apache 2.0 license at
* http://www.opensource.org/licenses/apache-2.0
*
* You can obtain a copy of the EPL 1.0 license at
* http://www.opensource.org/licenses/eclipse-1.0
*
* See the Licenses for the specific language governing permissions and
* limitations under the Licenses.
*
* Alternatively, you can obtain a royalty free commercial license with less
* limitations, transferable or non-transferable, directly at
* http://restlet.com/products/restlet-framework
*
* Restlet is a registered trademark of Restlet S.A.S.
*/

package org.restlet.engine.util;

import java.util.Arrays;

import org.restlet.engine.io.IoUtils;

/**
* Minimal but fast Base64 codec.
*
* @author Ray Waldin (ray@waldin.net)
*/
public class Base64 {

/** alphabet used for encoding bytes into base64 */
private static final char[] BASE64_DIGITS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
.toCharArray();

/**
* Decoding involves replacing each character with the character's value, or
* position, from the above alphabet, and this table makes such lookups
* quick and easy. Couldn't help myself with the corny name :)
*/
private static final byte[] DECODER_RING = new byte[128];

/**
* Initializes the decoder ring.
*/
static {
Arrays.fill(DECODER_RING, (byte) -1);
int i = 0;
for (final char c : BASE64_DIGITS) {
DECODER_RING[c] = (byte) i++;
}
DECODER_RING['='] = 0;
}

/**
* Returns the byte value at a given position in a bytes array.
*
* @param data
* The bytes array.
* @param block
* The block size.
* @param off
* The offset value.
* @return The extracted byte.
*/
private final static int byteAt(byte[] data, int block, int off) {
return unsign(data[(block * 3) + off]);
}

/**
* Decodes base64 characters into bytes. Newline characters found at block
* boundaries will be ignored.
*
* @param chars
* The characters array to decode.
* @return The decoded byte array.
*/
public static byte[] decode(final char[] chars) {
// prepare to ignore newline chars
int newlineCount = 0;
for (char c : chars) {
switch (c) {
case '\r':
case '\n':
newlineCount++;
break;
default:
}
}

int len = chars.length - newlineCount;

if (len % 4 != 0) {
throw new IllegalArgumentException(
"Base64.decode() requires input length to be a multiple of 4");
}

int numBytes = ((len + 3) / 4) * 3;

// fix up length relative to padding
if (len > 1) {
if (chars[chars.length - 2] == '=') {
numBytes -= 2;
} else if (chars[chars.length - 1] == '=') {
numBytes--;
}
}

byte[] result = new byte[numBytes];
int newlineOffset = 0;

// decode each block of 4 chars into 3 bytes
for (int i = 0; i < (len + 3) / 4; ++i) {
int charOffset = newlineOffset + (i * 4);

final char c1 = chars[charOffset++];
final char c2 = chars[charOffset++];
final char c3 = chars[charOffset++];
final char c4 = chars[charOffset++];

if (!(validChar(c1) && validChar(c2) && validChar(c3) && validChar(c4))) {
throw new IllegalArgumentException(
"Invalid Base64 character in block: '" + c1 + c2 + c3
+ c4 + "'");
}

// pack
final int x = DECODER_RING[c1] << 18 | DECODER_RING[c2] << 12
| (c3 == '=' ? 0 : DECODER_RING[c3] << 6)
| (c4 == '=' ? 0 : DECODER_RING[c4]);

// unpack
int byteOffset = i * 3;
result[byteOffset++] = (byte) (x >> 16);
if (c3 != '=') {
result[byteOffset++] = (byte) ((x >> 8) & 0xFF);
if (c4 != '=') {
result[byteOffset++] = (byte) (x & 0xFF);
}
}

// skip newlines after block
outer: while (chars.length > charOffset) {
switch (chars[charOffset++]) {
case '\r':
case '\n':
newlineOffset++;
break;

default:
break outer;
}
}
}
return result;
};

/**
* Decodes a base64 string into bytes. Newline characters found at block
* boundaries will be ignored.
*
* @param encodedString
* The string to decode.
* @return The decoded byte array.
*/
public static byte[] decode(String encodedString) {
return decode(encodedString.toCharArray());
}

/**
* Encodes an entire byte array into a Base64 string, with optional newlines
* after every 76 characters.
*
* @param bytes
* The byte array to encode.
* @param newlines
* Indicates whether or not newlines are desired.
* @return The encoded string.
*/
public static String encode(byte[] bytes, boolean newlines) {
return encode(bytes, 0, bytes.length, newlines);
}

/**
* Encodes specified bytes into a Base64 string, with optional newlines
* after every 76 characters.
*
* @param bytes
* The byte array to encode.
* @param off
* The starting offset.
* @param len
* The number of bytes to encode.
* @param newlines
* Indicates whether or not newlines are desired.
*
* @return The encoded string.
*/
public static String encode(byte[] bytes, int off, int len, boolean newlines) {
char[] output = new char[(((len + 2) / 3) * 4)
+ (newlines ? len / 43 : 0)];
int pos = 0;

// encode each block of 3 bytes into 4 chars
for (int i = 0; i < (len + 2) / 3; ++i) {
int pad = 0;

if (len + 1 < (i + 1) * 3) {
// two trailing '='s
pad = 2;
} else if (len < (i + 1) * 3) {
// one trailing '='
pad = 1;
}

// pack
int x = (byteAt(bytes, i, off) << 16)
| (pad > 1 ? 0 : (byteAt(bytes, i, off + 1) << 8))
| (pad > 0 ? 0 : (byteAt(bytes, i, off + 2)));

// unpack
output[pos++] = BASE64_DIGITS[x >> 18];
output[pos++] = BASE64_DIGITS[(x >> 12) & 0x3F];
output[pos++] = pad > 1 ? '=' : BASE64_DIGITS[(x >> 6) & 0x3F];
output[pos++] = pad > 0 ? '=' : BASE64_DIGITS[x & 0x3F];

if (newlines && ((i + 1) % 19 == 0)) {
output[pos++] = '\n';
}
}
return new String(output, 0, pos);
}

/**
* Computes the unsigned value of a byte.
*
* @param b
* The input byte.
* @return The output unsigned value.
*/
private final static int unsign(byte b) {
return b < 0 ? b + 256 : b;
}

/**
* Indicates if the character is valid and can be decoded.
*
* @param c
* The input character.
* @return True if the character is valid.
*/
private final static boolean validChar(char c) {
return (c < 128) && (DECODER_RING[c] != -1);
}
}
Expand Up @@ -104,7 +104,7 @@ private static class CharacterEntitySolver {
*/
public CharacterEntitySolver() {
toName = new String[10000];
toValue = new HashMap<>();
toValue = new HashMap<String, Integer>();
}

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

static {
xml10 = new ArrayList<>();
xml10 = new ArrayList<CharacterEntity>();
xml10.add(new CharacterEntity(34, "quot"));
xml10.add(new CharacterEntity(38, "amp"));
xml10.add(new CharacterEntity(62, "gt"));
xml10.add(new CharacterEntity(60, "lt"));
htmlLat1 = new ArrayList<>();
htmlLat1 = new ArrayList<CharacterEntity>();
htmlLat1.add(new CharacterEntity(160, "nbsp"));
htmlLat1.add(new CharacterEntity(161, "iexcl"));
htmlLat1.add(new CharacterEntity(162, "cent"));
Expand Down Expand Up @@ -262,7 +262,7 @@ public Integer getValue(String name) {
htmlLat1.add(new CharacterEntity(253, "yacute"));
htmlLat1.add(new CharacterEntity(254, "thorn"));
htmlLat1.add(new CharacterEntity(255, "yuml"));
htmlSymbol = new ArrayList<>();
htmlSymbol = new ArrayList<CharacterEntity>();
htmlSymbol.add(new CharacterEntity(402, "fnof"));
htmlSymbol.add(new CharacterEntity(913, "Alpha"));
htmlSymbol.add(new CharacterEntity(914, "Beta"));
Expand Down Expand Up @@ -386,7 +386,7 @@ public Integer getValue(String name) {
htmlSymbol.add(new CharacterEntity(9827, "clubs"));
htmlSymbol.add(new CharacterEntity(9829, "hearts"));
htmlSymbol.add(new CharacterEntity(9830, "diams"));
htmlSpecial = new ArrayList<>();
htmlSpecial = new ArrayList<CharacterEntity>();
htmlSpecial.add(new CharacterEntity(34, "quot"));
htmlSpecial.add(new CharacterEntity(38, "amp"));
htmlSpecial.add(new CharacterEntity(39, "apos"));
Expand Down

0 comments on commit 660ec16

Please sign in to comment.