Skip to content
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

Discussion : Does Spoon provides any support for these features ? #3774

Closed
udit-dasari opened this issue Jan 28, 2021 · 10 comments
Closed

Discussion : Does Spoon provides any support for these features ? #3774

udit-dasari opened this issue Jan 28, 2021 · 10 comments

Comments

@udit-dasari
Copy link

udit-dasari commented Jan 28, 2021

Hi, i and my team want to know more about the various features that Spoon may support, so we came up with some requirements for our project :

  • Control flow analysis
  • support for binaries
  • will it be maintained in future
  • lexeme related data
  • Data Dependancy graph
  • Incremental support
  • Data flow analysis
  • any other features ?
  • GotoDef edges
  • Reference edges
  • filtering nodes based on elementType

Can you please confirm the support for above features ?

@andrewbwogi
Copy link
Contributor

andrewbwogi commented Jan 29, 2021

Hi @udit-dasari, the documentation provides a good overview of features in Spoon. The Navigation and Query section describes many ways to query ASTs, including filtering based on the element type.

For control and data flow analysis there is the spoon-control-flow package.

If by support for binaries you mean transformation or analysis of class files, there is the spoon-decompiler package.

There are several kinds of support available for your project, including this forum and professional support.

The question of future maintenance I'm passing on to @monperrus.

@monperrus
Copy link
Collaborator

will it be maintained in future

We all hope so. We've been able to maintain it for 16 years already.

@udit-dasari
Copy link
Author

Hi @andrewbwogi , is there any way i can :

  1. Prevent spoon from accessing the JVM classpath and provide all the jars i want through launcher.getEnvironment().setSourceClassPath() only?
  2. Get the properties of an element in the form of map (key = property, value = property's value) or something similar without needing to check like say if it's a method and then looking for properties isStatic(), etc.For ex. Jdt parser provides a generic way to do that using ChildPropertyDescriptor, SimplePropertyDescriptor, etc.

@andrewbwogi
Copy link
Contributor

When launcher.getEnvironment().setNoClasspath(false) and setSourceClasspath are used together, only the argument to setSourceClasspath should be set as the classpath.

To get properties of an element through a single interface, you can use getValueByRole. It takes a CtRole (e.g. CtRole.IS_STATIC) and returns a value based on the element and the role argument.

@iamKunalGupta
Copy link

@andrewbwogi It is mentioned on the website that spoon uses either JVM or sourceClassPath to resolve, the NoClassPath mode merely prevents it from throwing exceptions in case a resolution is not found, it does not prevent spoon from using the classes currently loaded in the JVM:

Case 2 (code available as binary in the classpath): the reference points to a code element for which the source code is NOT present, but for which the binary class is in the classpath (either the JVM classpath or the --source-classpath argument). In this case, reference.getDeclaration() returns null and reference.getTypeDeclaration returns a partial CtType built using runtime reflection. Those objects built using runtime reflection are called shadow objects; and you can identify them with method isShadow. (This also holds for getFieldDeclaration and getExecutableDeclaration)

https://spoon.gforge.inria.fr/launcher.html under Resolution of elements and classpath. Also it uses the URLClassLoader by default, so it should still load both JVM classpath as well as the classpath set in the sourceClassPath

@andrewbwogi
Copy link
Contributor

@iamKunalGupta, it seems true that the JVM classpath is used even with setSourceClasspath and setNoClasspath(false) when the manually set classpath has a name that corresponds to a name in the JVM classpath. @udit-dasari, are you referring to this problem?

@udit-dasari
Copy link
Author

@andrewbwogi, yes, even when i use setSourceClasspath and setNoClasspath(false) spoon is still able to access and load the JVM classpath, even if i don't pass a library in the setSourceClasspath the library is still being loaded if it is present in the JVM classpath

@nashid
Copy link

nashid commented Nov 11, 2021

@monperrus do you think in the near future Spoon would address the following gaps?

  • Control flow analysis
  • Data flow analysis
  • def-use analysis

There are so many tools in the JVM ecosystem and yet there is no tool that works reliably, is well-maintained, and has ok enough documentation.

Alternately, could you point me to any tool/library resource that can generate control flow and data flow effectively for JDK8+ code?

@monperrus
Copy link
Collaborator

Hi @nashid See:

For def-use, nothing comes on the top of my head.

@monperrus
Copy link
Collaborator

Closing, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants