-
-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove the over-complicated generics #784
Conversation
…aAnnotationSootMethods
# Conflicts: # sootup.callgraph/src/main/java/sootup/callgraph/AbstractCallGraphAlgorithm.java
You updated the documentation - Doc Preview. |
WIP: Generics Draft/Playground package com.github.apiassist.sast;
import com.google.common.collect.Sets;
import java.util.Collections;
import java.util.Optional;
import java.util.Set;
public class SootUpGenericTest {
public static void main(String[] args) {
JView jView = new JView();
Optional<JSC> c = jView.getC();
Set<AnaInp<? extends JSCS>> anaInps2 = jView.getAnaInps();
// make this possible Set<JavAnaInp> anaInps = jView.getAnaInps();
}
}
interface Lang<C, M, CS, MS> {
// unused.. necessary?
// intention: subclass with actual values and use that to define grouped generic parameters?
}
interface JLang extends Lang<JSC, JSM, JSCS, JSMS> {
}
interface AnaInp<CS> {
CS getClassSource();
}
class JSCAnaInp implements AnaInp<JSCS> {
@Override
public JSCS getClassSource() {
return new JSCS();
}
}
class JCPAnaInp implements AnaInp<JSCS> {
@Override
public JSCS getClassSource() {
return new JSCS();
}
}
interface View<C, M, CS extends SCS> {
Set<AnaInp<? extends CS>> getAnaInps();
Set<M> getM();
Optional<C> getC();
}
class SMS {
}
class JSMS extends SMS {
}
class SCS {
}
class JSCS extends SCS {
}
class JASCS extends JSCS {
}
class JMSCS extends JSMS {
}
class SM {
}
class JSM extends SM {
}
class JASM extends JSM {
}
abstract class SC<SM, SMS> {
Set<SMS> classSources;
abstract public Set<SM> getM();
}
abstract class AbstractJSC<M extends SM, MS extends SMS> extends SC<M, MS> {
MS methodSource;
abstract public Set<M> getM();
}
class JSC extends AbstractJSC<JSM, JSMS> {
public Set<JSM> getM() {
return Collections.singleton(new JSM());
}
}
class JASC extends AbstractJSC<JASM, JSMS> {
public Set<JASM> getM() {
return Collections.singleton(new JASM());
}
}
abstract class AbsJavAnaInp<CS> implements AnaInp<CS> {
public abstract CS getClassSource();
}
class JavAnaInp extends AbsJavAnaInp<JSCS> {
public JSCS getClassSource() {
return new JSCS();
}
}
abstract class AbsView<SC, SM, CS extends SCS> implements View<SC, SM, CS> {
@Override
public abstract Set<AnaInp<? extends CS>> getAnaInps();
public abstract Set<SM> getM();
public abstract Optional<SC> getC();
}
class JView extends AbsView<JSC, JSM, JSCS> {
@Override
public Set<AnaInp<? extends JSCS>> getAnaInps() {
return Sets.newHashSet(new JSCAnaInp(), new JCPAnaInp());
}
public Set<JSM> getM() {
return Collections.singleton(new JSM());
}
public Optional<JSC> getC() {
return Optional.of(new JSC());
}
} |
@@ -461,17 +459,17 @@ public static Optional<? extends SootMethod> findConcreteMethod( | |||
+ " to resolve the concrete method"); | |||
return Optional.empty(); | |||
} | |||
Optional<? extends SootMethod> startMethod = startclass.getMethod(sig.getSubSignature()); | |||
Optional<SootMethod> startMethod = startclass.getMethod(sig.getSubSignature()).map(method -> (SootMethod) method); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to make SootClass.getMethod() return SootMethod (i.e. override getMethod() and cast it there) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, not if we use an Optional.
In order to override it in the JavaSootClass with 'Optional<JavaSootClass> getMethod()', it needs to have Optional<? extends SootClass> as return type.
# Conflicts: # sootup.core/src/main/java/sootup/core/util/printer/JimplePrinter.java
…was actually resolving the superclass
No description provided.