"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/main/java/org/codehaus/groovy/runtime/typehandling/DefaultTypeTransformation.java" between
apache-groovy-src-3.0.8.zip and apache-groovy-src-3.0.9.zip

About: Groovy is an agile dynamic (scripting) language for the Java Platform. It has features similar to those of Python, Ruby, Perl, and Smalltalk. Source release.

DefaultTypeTransformation.java  (apache-groovy-src-3.0.8):DefaultTypeTransformation.java  (apache-groovy-src-3.0.9)
skipping to change at line 373 skipping to change at line 373
args = collection.toArray(); args = collection.toArray();
} else if (object instanceof Object[]) { } else if (object instanceof Object[]) {
args = (Object[]) object; args = (Object[]) object;
} else if (object instanceof Map) { } else if (object instanceof Map) {
// emulate named params constructor // emulate named params constructor
args = new Object[1]; args = new Object[1];
args[0] = object; args[0] = object;
} }
Exception nested = null; Exception nested = null;
Exception suppressed = null;
if (args != null) { if (args != null) {
try { try {
return InvokerHelper.invokeConstructorOf(type, args); return InvokerHelper.invokeConstructorOf(type, args);
} catch (InvokerInvocationException iie) { } catch (InvokerInvocationException iie) {
throw iie; throw iie;
} catch (GroovyRuntimeException e) { } catch (GroovyRuntimeException e) {
if (e.getMessage().contains("Could not find matching constructor for")) { if (e.getMessage().contains("Could not find matching constructor for")) {
try { try {
return InvokerHelper.invokeConstructorOf(type, object); return InvokerHelper.invokeConstructorOf(type, object);
} catch (InvokerInvocationException iie) { } catch (InvokerInvocationException iie) {
throw iie; throw iie;
} catch (Exception ex) { } catch (Exception ex) {
// let's ignore exception and return the original object // let's ignore exception and return the original object
// as the caller has more context to be able to throw a more // as the caller has more context to be able to throw a more
// meaningful exception (but stash to get message later) // meaningful exception (but stash to get message later)
nested = e; nested = e;
// keep the original exception as suppressed exception t
o allow easier failure analysis
suppressed = ex;
} }
} else { } else {
nested = e; nested = e;
} }
} catch (Exception e) { } catch (Exception e) {
// let's ignore exception and return the original object // let's ignore exception and return the original object
// as the caller has more context to be able to throw a more // as the caller has more context to be able to throw a more
// meaningful exception (but stash to get message later) // meaningful exception (but stash to get message later)
nested = e; nested = e;
} }
} }
GroovyCastException gce; GroovyCastException gce;
if (nested != null) { if (nested != null) {
gce = new GroovyCastException(object, type, nested); gce = new GroovyCastException(object, type, nested);
} else { } else {
gce = new GroovyCastException(object, type); gce = new GroovyCastException(object, type);
} }
if (suppressed != null) {
gce.addSuppressed(suppressed);
}
throw gce; throw gce;
} }
public static Object asArray(Object object, Class type) { public static Object asArray(Object object, Class type) {
if (type.isAssignableFrom(object.getClass())) { if (type.isAssignableFrom(object.getClass())) {
return object; return object;
} }
Collection list = asCollection(object); Collection list = asCollection(object);
int size = list.size(); int size = list.size();
 End of changes. 3 change blocks. 
0 lines changed or deleted 7 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)