Merge lp:~james-page/ubuntu/oneiric/jenkins-xstream/827463 into lp:ubuntu/oneiric/jenkins-xstream
- Oneiric (11.10)
- 827463
- Merge into oneiric
Proposed by
James Page
Status: | Merged |
---|---|
Merge reported by: | James Page |
Merged at revision: | not available |
Proposed branch: | lp:~james-page/ubuntu/oneiric/jenkins-xstream/827463 |
Merge into: | lp:ubuntu/oneiric/jenkins-xstream |
Diff against target: |
393 lines (+329/-0) 6 files modified
.pc/applied-patches (+1/-0) .pc/openjdk-icedtea-support.patch/xstream/src/java/com/thoughtworks/xstream/core/JVM.java (+267/-0) debian/changelog (+9/-0) debian/patches/openjdk-icedtea-support.patch (+40/-0) debian/patches/series (+1/-0) xstream/src/java/com/thoughtworks/xstream/core/JVM.java (+11/-0) |
To merge this branch: | bzr merge lp:~james-page/ubuntu/oneiric/jenkins-xstream/827463 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu Development Team | Pending | ||
Review via email: mp+72022@code.launchpad.net |
Commit message
Description of the change
Patched to add support for JVM's based on OpenJDK or IcedTea as they should have the required language features.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.pc/applied-patches' |
2 | --- .pc/applied-patches 2011-06-29 11:57:40 +0000 |
3 | +++ .pc/applied-patches 2011-08-18 11:18:31 +0000 |
4 | @@ -1,2 +1,3 @@ |
5 | build.patch |
6 | sax.patch |
7 | +openjdk-icedtea-support.patch |
8 | |
9 | === added directory '.pc/openjdk-icedtea-support.patch' |
10 | === added directory '.pc/openjdk-icedtea-support.patch/xstream' |
11 | === added directory '.pc/openjdk-icedtea-support.patch/xstream/src' |
12 | === added directory '.pc/openjdk-icedtea-support.patch/xstream/src/java' |
13 | === added directory '.pc/openjdk-icedtea-support.patch/xstream/src/java/com' |
14 | === added directory '.pc/openjdk-icedtea-support.patch/xstream/src/java/com/thoughtworks' |
15 | === added directory '.pc/openjdk-icedtea-support.patch/xstream/src/java/com/thoughtworks/xstream' |
16 | === added directory '.pc/openjdk-icedtea-support.patch/xstream/src/java/com/thoughtworks/xstream/core' |
17 | === added file '.pc/openjdk-icedtea-support.patch/xstream/src/java/com/thoughtworks/xstream/core/JVM.java' |
18 | --- .pc/openjdk-icedtea-support.patch/xstream/src/java/com/thoughtworks/xstream/core/JVM.java 1970-01-01 00:00:00 +0000 |
19 | +++ .pc/openjdk-icedtea-support.patch/xstream/src/java/com/thoughtworks/xstream/core/JVM.java 2011-08-18 11:18:31 +0000 |
20 | @@ -0,0 +1,267 @@ |
21 | +/* |
22 | + * Copyright (C) 2004, 2005, 2006 Joe Walnes. |
23 | + * Copyright (C) 2006, 2007, 2008 XStream Committers. |
24 | + * All rights reserved. |
25 | + * |
26 | + * The software in this package is published under the terms of the BSD |
27 | + * style license a copy of which has been included with this distribution in |
28 | + * the LICENSE.txt file. |
29 | + * |
30 | + * Created on 09. May 2004 by Joe Walnes |
31 | + */ |
32 | +package com.thoughtworks.xstream.core; |
33 | + |
34 | +import com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider; |
35 | +import com.thoughtworks.xstream.converters.reflection.ReflectionProvider; |
36 | + |
37 | +import java.lang.ref.WeakReference; |
38 | +import java.lang.reflect.Field; |
39 | +import java.security.AccessControlException; |
40 | +import java.text.AttributedString; |
41 | +import java.util.HashMap; |
42 | +import java.util.Map; |
43 | + |
44 | +public class JVM { |
45 | + |
46 | + private ReflectionProvider reflectionProvider; |
47 | + private transient Map loaderCache = new HashMap(); |
48 | + |
49 | + private final boolean supportsAWT = loadClass("java.awt.Color") != null; |
50 | + private final boolean supportsSwing = loadClass("javax.swing.LookAndFeel") != null; |
51 | + private final boolean supportsSQL = loadClass("java.sql.Date") != null; |
52 | + |
53 | + private static final String vendor = System.getProperty("java.vm.vendor"); |
54 | + private static final float majorJavaVersion = getMajorJavaVersion(); |
55 | + private static final boolean reverseFieldOrder = isHarmony() || (isIBM() && !is15()); |
56 | + |
57 | + static final float DEFAULT_JAVA_VERSION = 1.3f; |
58 | + |
59 | + /** |
60 | + * Parses the java version system property to determine the major java version, |
61 | + * i.e. 1.x |
62 | + * |
63 | + * @return A float of the form 1.x |
64 | + */ |
65 | + private static final float getMajorJavaVersion() { |
66 | + try { |
67 | + return Float.parseFloat(System.getProperty("java.specification.version")); |
68 | + } catch ( NumberFormatException e ){ |
69 | + // Some JVMs may not conform to the x.y.z java.version format |
70 | + return DEFAULT_JAVA_VERSION; |
71 | + } |
72 | + } |
73 | + |
74 | + public static boolean is14() { |
75 | + return majorJavaVersion >= 1.4f; |
76 | + } |
77 | + |
78 | + public static boolean is15() { |
79 | + return majorJavaVersion >= 1.5f; |
80 | + } |
81 | + |
82 | + public static boolean is16() { |
83 | + return majorJavaVersion >= 1.6f; |
84 | + } |
85 | + |
86 | + private static boolean isSun() { |
87 | + return vendor.indexOf("Sun") != -1; |
88 | + } |
89 | + |
90 | + private static boolean isApple() { |
91 | + return vendor.indexOf("Apple") != -1; |
92 | + } |
93 | + |
94 | + private static boolean isHPUX() { |
95 | + return vendor.indexOf("Hewlett-Packard Company") != -1; |
96 | + } |
97 | + |
98 | + private static boolean isIBM() { |
99 | + return vendor.indexOf("IBM") != -1; |
100 | + } |
101 | + |
102 | + private static boolean isBlackdown() { |
103 | + return vendor.indexOf("Blackdown") != -1; |
104 | + } |
105 | + |
106 | + private static boolean isDiablo() { |
107 | + return vendor.indexOf("FreeBSD Foundation") != -1; |
108 | + } |
109 | + |
110 | + private static boolean isHarmony() { |
111 | + return vendor.indexOf("Apache Software Foundation") != -1; |
112 | + } |
113 | + |
114 | + /* |
115 | + * Support for sun.misc.Unsafe and sun.reflect.ReflectionFactory is present |
116 | + * in JRockit versions R25.1.0 and later, both 1.4.2 and 5.0 (and in future |
117 | + * 6.0 builds). |
118 | + */ |
119 | + private static boolean isBEAWithUnsafeSupport() { |
120 | + // This property should be "BEA Systems, Inc." |
121 | + if (vendor.indexOf("BEA") != -1) { |
122 | + |
123 | + /* |
124 | + * Recent 1.4.2 and 5.0 versions of JRockit have a java.vm.version |
125 | + * string starting with the "R" JVM version number, i.e. |
126 | + * "R26.2.0-38-57237-1.5.0_06-20060209..." |
127 | + */ |
128 | + String vmVersion = System.getProperty("java.vm.version"); |
129 | + if (vmVersion.startsWith("R")) { |
130 | + /* |
131 | + * We *could* also check that it's R26 or later, but that is |
132 | + * implicitly true |
133 | + */ |
134 | + return true; |
135 | + } |
136 | + |
137 | + /* |
138 | + * For older JRockit versions we can check java.vm.info. JRockit |
139 | + * 1.4.2 R24 -> "Native Threads, GC strategy: parallel" and JRockit |
140 | + * 5.0 R25 -> "R25.2.0-28". |
141 | + */ |
142 | + String vmInfo = System.getProperty("java.vm.info"); |
143 | + if (vmInfo != null) { |
144 | + // R25.1 or R25.2 supports Unsafe, other versions do not |
145 | + return (vmInfo.startsWith("R25.1") || vmInfo |
146 | + .startsWith("R25.2")); |
147 | + } |
148 | + } |
149 | + // If non-BEA, or possibly some very old JRockit version |
150 | + return false; |
151 | + } |
152 | + |
153 | + private static boolean isOracle() { |
154 | + return vendor.indexOf("Oracle") != -1; |
155 | + } |
156 | + |
157 | + private static boolean isHitachi() { |
158 | + return vendor.indexOf("Hitachi") != -1; |
159 | + } |
160 | + |
161 | + private static boolean isSAP() { |
162 | + return vendor.indexOf("SAP AG") != -1; |
163 | + } |
164 | + |
165 | + public Class loadClass(String name) { |
166 | + try { |
167 | + WeakReference reference = (WeakReference) loaderCache.get(name); |
168 | + if (reference != null) { |
169 | + Class cached = (Class) reference.get(); |
170 | + if (cached != null) { |
171 | + return cached; |
172 | + } |
173 | + } |
174 | + |
175 | + Class clazz = Class.forName(name, false, getClass().getClassLoader()); |
176 | + loaderCache.put(name, new WeakReference(clazz)); |
177 | + return clazz; |
178 | + } catch (ClassNotFoundException e) { |
179 | + return null; |
180 | + } |
181 | + } |
182 | + |
183 | + public synchronized ReflectionProvider bestReflectionProvider() { |
184 | + if (reflectionProvider == null) { |
185 | + try { |
186 | + if ( canUseSun14ReflectionProvider() ) { |
187 | + String cls = "com.thoughtworks.xstream.converters.reflection.Sun14ReflectionProvider"; |
188 | + reflectionProvider = (ReflectionProvider) loadClass(cls).newInstance(); |
189 | + } else if (canUseHarmonyReflectionProvider()) { |
190 | + String cls = "com.thoughtworks.xstream.converters.reflection.HarmonyReflectionProvider"; |
191 | + reflectionProvider = (ReflectionProvider) loadClass(cls).newInstance(); |
192 | + } |
193 | + if (reflectionProvider == null) { |
194 | + reflectionProvider = new PureJavaReflectionProvider(); |
195 | + } |
196 | + } catch (InstantiationException e) { |
197 | + reflectionProvider = new PureJavaReflectionProvider(); |
198 | + } catch (IllegalAccessException e) { |
199 | + reflectionProvider = new PureJavaReflectionProvider(); |
200 | + } catch (AccessControlException e) { |
201 | + // thrown when trying to access sun.misc package in Applet context. |
202 | + reflectionProvider = new PureJavaReflectionProvider(); |
203 | + } |
204 | + } |
205 | + return reflectionProvider; |
206 | + } |
207 | + |
208 | + private boolean canUseSun14ReflectionProvider() { |
209 | + return (isSun() |
210 | + || isApple() |
211 | + || isHPUX() |
212 | + || isIBM() |
213 | + || isBlackdown() |
214 | + || isBEAWithUnsafeSupport() |
215 | + || isOracle() |
216 | + || isHitachi() |
217 | + || isSAP() |
218 | + || isDiablo()) |
219 | + && is14() |
220 | + && loadClass("sun.misc.Unsafe") != null; |
221 | + } |
222 | + |
223 | + private boolean canUseHarmonyReflectionProvider() { |
224 | + return isHarmony(); |
225 | + } |
226 | + |
227 | + public static boolean reverseFieldDefinition() { |
228 | + return reverseFieldOrder; |
229 | + } |
230 | + |
231 | + /** |
232 | + * Checks if the jvm supports awt. |
233 | + */ |
234 | + public boolean supportsAWT() { |
235 | + return this.supportsAWT; |
236 | + } |
237 | + |
238 | + /** |
239 | + * Checks if the jvm supports swing. |
240 | + */ |
241 | + public boolean supportsSwing() { |
242 | + return this.supportsSwing; |
243 | + } |
244 | + |
245 | + /** |
246 | + * Checks if the jvm supports sql. |
247 | + */ |
248 | + public boolean supportsSQL() { |
249 | + return this.supportsSQL; |
250 | + } |
251 | + |
252 | + private Object readResolve() { |
253 | + loaderCache = new HashMap(); |
254 | + return this; |
255 | + } |
256 | + |
257 | + public static void main(String[] args) { |
258 | + boolean reverse = false; |
259 | + Field[] fields = AttributedString.class.getDeclaredFields(); |
260 | + for (int i = 0; i < fields.length; i++) { |
261 | + if (fields[i].getName().equals("text")) { |
262 | + reverse = i > 3; |
263 | + break; |
264 | + } |
265 | + } |
266 | + if (reverse) { |
267 | + fields = JVM.class.getDeclaredFields(); |
268 | + for (int i = 0; i < fields.length; i++) { |
269 | + if (fields[i].getName().equals("reflectionProvider")) { |
270 | + reverse = i > 2; |
271 | + break; |
272 | + } |
273 | + } |
274 | + } |
275 | + |
276 | + JVM jvm = new JVM(); |
277 | + System.out.println("XStream JVM diagnostics"); |
278 | + System.out.println("java.specification.version: " + System.getProperty("java.specification.version")); |
279 | + System.out.println("java.vm.vendor: " + vendor); |
280 | + System.out.println("Version: " + majorJavaVersion); |
281 | + System.out.println("XStream support for enhanced Mode: " + (jvm.canUseSun14ReflectionProvider() || jvm.canUseHarmonyReflectionProvider())); |
282 | + System.out.println("Supports AWT: " + jvm.supportsAWT()); |
283 | + System.out.println("Supports Swing: " + jvm.supportsSwing()); |
284 | + System.out.println("Supports SQL: " + jvm.supportsSQL()); |
285 | + System.out.println("Reverse field order detected (may have failed): " + reverse); |
286 | + } |
287 | +} |
288 | |
289 | === modified file 'debian/changelog' |
290 | --- debian/changelog 2011-06-29 11:57:40 +0000 |
291 | +++ debian/changelog 2011-08-18 11:18:31 +0000 |
292 | @@ -1,3 +1,12 @@ |
293 | +jenkins-xstream (1.3.1-hudson-8-0ubuntu2) oneiric; urgency=low |
294 | + |
295 | + [ Xerces Ranby ] |
296 | + * debian/patches/openjdk-icedtea-support.patch: Add support for OpenJDK |
297 | + or IcedTea based JVM's to enable use on ARM based architectures |
298 | + (LP: #827463). |
299 | + |
300 | + -- James Page <james.page@ubuntu.com> Thu, 18 Aug 2011 09:14:29 +0100 |
301 | + |
302 | jenkins-xstream (1.3.1-hudson-8-0ubuntu1) oneiric; urgency=low |
303 | |
304 | * Initial release |
305 | |
306 | === added file 'debian/patches/openjdk-icedtea-support.patch' |
307 | --- debian/patches/openjdk-icedtea-support.patch 1970-01-01 00:00:00 +0000 |
308 | +++ debian/patches/openjdk-icedtea-support.patch 2011-08-18 11:18:31 +0000 |
309 | @@ -0,0 +1,40 @@ |
310 | +Description: Patch to enable support for JVM's based on OpenJDK or IcedTea. |
311 | +Author: Xerxes RĂ„nby <xerxes@zafena.se> |
312 | +Bug: https://issues.jenkins-ci.org/browse/JENKINS-10752 |
313 | + |
314 | +Index: jenkins-xstream-1.3.1-hudson-8/xstream/src/java/com/thoughtworks/xstream/core/JVM.java |
315 | +=================================================================== |
316 | +--- jenkins-xstream-1.3.1-hudson-8.orig/xstream/src/java/com/thoughtworks/xstream/core/JVM.java 2010-10-09 17:20:48.000000000 +0000 |
317 | ++++ jenkins-xstream-1.3.1-hudson-8/xstream/src/java/com/thoughtworks/xstream/core/JVM.java 2011-08-17 22:01:49.951226001 +0000 |
318 | +@@ -31,6 +31,7 @@ |
319 | + private final boolean supportsSQL = loadClass("java.sql.Date") != null; |
320 | + |
321 | + private static final String vendor = System.getProperty("java.vm.vendor"); |
322 | ++ private static final String runtime = System.getProperty("java.runtime.name"); |
323 | + private static final float majorJavaVersion = getMajorJavaVersion(); |
324 | + private static final boolean reverseFieldOrder = isHarmony() || (isIBM() && !is15()); |
325 | + |
326 | +@@ -63,6 +64,14 @@ |
327 | + return majorJavaVersion >= 1.6f; |
328 | + } |
329 | + |
330 | ++ private static boolean isIcedTea() { |
331 | ++ return runtime.indexOf("IcedTea") != -1; |
332 | ++ } |
333 | ++ |
334 | ++ private static boolean isOpenJDK() { |
335 | ++ return runtime.indexOf("OpenJDK") != -1; |
336 | ++ } |
337 | ++ |
338 | + private static boolean isSun() { |
339 | + return vendor.indexOf("Sun") != -1; |
340 | + } |
341 | +@@ -187,6 +196,8 @@ |
342 | + |
343 | + private boolean canUseSun14ReflectionProvider() { |
344 | + return (isSun() |
345 | ++ || isOpenJDK() |
346 | ++ || isIcedTea() |
347 | + || isApple() |
348 | + || isHPUX() |
349 | + || isIBM() |
350 | |
351 | === modified file 'debian/patches/series' |
352 | --- debian/patches/series 2011-06-29 11:57:40 +0000 |
353 | +++ debian/patches/series 2011-08-18 11:18:31 +0000 |
354 | @@ -1,2 +1,3 @@ |
355 | build.patch |
356 | sax.patch |
357 | +openjdk-icedtea-support.patch |
358 | |
359 | === modified file 'xstream/src/java/com/thoughtworks/xstream/core/JVM.java' |
360 | --- xstream/src/java/com/thoughtworks/xstream/core/JVM.java 2011-06-29 11:57:40 +0000 |
361 | +++ xstream/src/java/com/thoughtworks/xstream/core/JVM.java 2011-08-18 11:18:31 +0000 |
362 | @@ -31,6 +31,7 @@ |
363 | private final boolean supportsSQL = loadClass("java.sql.Date") != null; |
364 | |
365 | private static final String vendor = System.getProperty("java.vm.vendor"); |
366 | + private static final String runtime = System.getProperty("java.runtime.name"); |
367 | private static final float majorJavaVersion = getMajorJavaVersion(); |
368 | private static final boolean reverseFieldOrder = isHarmony() || (isIBM() && !is15()); |
369 | |
370 | @@ -63,6 +64,14 @@ |
371 | return majorJavaVersion >= 1.6f; |
372 | } |
373 | |
374 | + private static boolean isIcedTea() { |
375 | + return runtime.indexOf("IcedTea") != -1; |
376 | + } |
377 | + |
378 | + private static boolean isOpenJDK() { |
379 | + return runtime.indexOf("OpenJDK") != -1; |
380 | + } |
381 | + |
382 | private static boolean isSun() { |
383 | return vendor.indexOf("Sun") != -1; |
384 | } |
385 | @@ -187,6 +196,8 @@ |
386 | |
387 | private boolean canUseSun14ReflectionProvider() { |
388 | return (isSun() |
389 | + || isOpenJDK() |
390 | + || isIcedTea() |
391 | || isApple() |
392 | || isHPUX() |
393 | || isIBM() |