Remove the over-complicated generics#784
Merged
Conversation
…aAnnotationSootMethods
# Conflicts: # sootup.callgraph/src/main/java/sootup/callgraph/AbstractCallGraphAlgorithm.java
Contributor
|
You updated the documentation - Doc Preview. |
Collaborator
|
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());
}
} |
swissiety
reviewed
Dec 22, 2023
| return Optional.empty(); | ||
| } | ||
| Optional<? extends SootMethod> startMethod = startclass.getMethod(sig.getSubSignature()); | ||
| Optional<SootMethod> startMethod = startclass.getMethod(sig.getSubSignature()).map(method -> (SootMethod) method); |
Collaborator
There was a problem hiding this comment.
is it possible to make SootClass.getMethod() return SootMethod (i.e. override getMethod() and cast it there) ?
Collaborator
Author
There was a problem hiding this comment.
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
JonasKlauke
approved these changes
Jan 10, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.