Fix handling of types not in cha

Before the TypeSafeInstructionFactory would throw. Now it ignores.
This commit is contained in:
Tobias Blaschke 2014-02-25 20:55:32 +01:00 committed by Juergen Graf
parent 1121b59b3b
commit 1dc721710f
3 changed files with 47 additions and 5 deletions

View File

@ -0,0 +1,38 @@
/*
* Copyright (c) 2013,
* Tobias Blaschke <code@tobiasblaschke.de>
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The names of the contributors may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package com.ibm.wala.util.ssa;
public class ClassLookupException extends RuntimeException {
public ClassLookupException(String message) {
super(message);
}
}

View File

@ -588,10 +588,10 @@ public class ParameterAccessor { // extends Param-Manager
switch (this.base) {
case IMETHOD:
return new Parameter(self, "this", asType, ParamerterDisposition.THIS,
return new Parameter(self, "self", asType, ParamerterDisposition.THIS,
this.base, this.method.getReference(), this.descriptorOffset);
case METHOD_REFERENCE:
return new Parameter(self, "this", asType, ParamerterDisposition.THIS,
return new Parameter(self, "self", asType, ParamerterDisposition.THIS,
this.base, this.mRef, this.descriptorOffset);
default:
throw new UnsupportedOperationException("No implementation of getThis() for base " + this.base);
@ -1442,7 +1442,7 @@ public class ParameterAccessor { // extends Param-Manager
}
if (fromClass == null) {
throw new IllegalArgumentException("Unable to look up the type of from=" + from +
throw new ClassLookupException("Unable to look up the type of from=" + from +
" in the ClassHierarchy");
}
}
@ -1461,7 +1461,7 @@ public class ParameterAccessor { // extends Param-Manager
if (toClass == null) {
logger.error("Unable to look up the type of to={} in the ClassHierarchy", to);
return false;
//throw new IllegalArgumentException("Unable to look up the type of to=" + to +
//throw new ClassLookupException("Unable to look up the type of to=" + to +
// " in the ClassHierarchy");
}
}

View File

@ -631,7 +631,11 @@ public class TypeSafeInstructionFactory {
}
private boolean isAssignableFrom(final TypeReference from, final TypeReference to) {
return ParameterAccessor.isAssignable(from, to, this.cha);
try {
return ParameterAccessor.isAssignable(from, to, this.cha);
} catch (ClassLookupException e) {
return true;
}
}
// ************