pure4j / pure4j Goto Github PK
View Code? Open in Web Editor NEWCompile-Time Purity and Immutability Semantics For The Java Language
Home Page: http://pure4j.org
License: Other
Compile-Time Purity and Immutability Semantics For The Java Language
Home Page: http://pure4j.org
License: Other
As a developer on a large project, I have huge swaths of code that are effectively immutable except for a single method (in my case a call to Apache's ToStringBuilder in toString methods). I would very much like to be able to force ToStringBuilder to be considered Pure, so that I can gain the benefits of purity checking on the rest of the code and I can look into what to do about ToStringBuilder separately.
It would be ideal to be able to tell the pure4j maven plugin of extra .pure files of my own creation. It would further be handy to have one central .pure files (or set of them) in a multi-module Maven build. This is not as effortful as it may sound - the maven-pmd-plugin does exactly this.
The maven-pmd-plugin supports the ability to specify a list of rulesets in its configuration. The ruleset itself may exist in a jar file.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<executions>
<execution>
<id>pmd-check</id>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<rulesets>
<ruleset>pmd-ruleset.xml</ruleset>
</rulesets>
</configuration>
<dependencies>
<dependency>
<groupId>org.example</groupId>
<artifactId>code-style-requirements</artifactId>
<version>${code-style-requirements.version}</version>
</dependency>
This allows an organization to build an artifact which lists the PMD rules it wants, put them in an Maven artifact and then have it versioned and depended upon by different teams.
Possibly a separate issue, but it would be really cool if the maven plugin dumped a results.pure into the target directory after it ran which listed anything it found that was NOT_PURE. This would give me something analyse.
One impure function should 'taint' those that use it,
when we come to write out the list of pure functions at the end. This is useful when we are constructing the pure list of java built-in functions.
as described. for jdk8 version
Hi, I love the idea of pure4j
, the documentation and everything, thank you so much for it!
In our project I've created our own versions of immutable collections which I am willing to port to the ones you provide in pure4j
and I really want to annotate half of our code with @ImmutableValue
(because it already is immutable) but I cannot do that without a Gradle plugin - we use Gradle for everything and just using pure4j
without the static checking seems... wasteful. :) Have you researched into that? Has anyone helped? Has any progress been made?
Thanks again!
I have two questions which I couldn't find in the docs:
Let's say I have a class like this:
abstract class Strict<State> {
State state;
@Pure
protected abstract String functionThatMustBePure(State state, String input);
public String apply(String input) {
return functionThatMustBePure(state, input);
}
}
Can I use the @Pure
annotation in this way, to enforce that subclasses implement the function in a pure way?
Along the same lines, is it possible to annotate a @FunctionalInterface
argument of a function to be pure?
public static Supplier<R> memoizeResult(T input, @Pure Function<T, R> result) { ... }
We need some examples of using the Java8 streams API that aren't pure, for comparison with the existing pure ones, and also to show that purity checking is in force around these too.
Are constructors making defensive immutable copies of collections good enough?
https://github.com/google/guava/wiki/ImmutableCollectionsExplained
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.