Coder Social home page Coder Social logo

manifold-systems / manifold Goto Github PK

View Code? Open in Web Editor NEW
2.2K 35.0 121.0 123.38 MB

Manifold is a Java compiler plugin, its features include Metaprogramming, Properties, Extension Methods, Operator Overloading, Templates, a Preprocessor, and more.

Home Page: http://manifold.systems/

License: Apache License 2.0

Shell 0.01% Java 98.30% JavaScript 0.08% EJS 0.01% PLpgSQL 1.17% TSQL 0.45%
java intellij json template-engine reflection-framework extension-methods structural-typing duck-typing java-tooling java-development

manifold's Introduction


latest slack GitHub Repo stars


What is Manifold?

Manifold is a Java compiler plugin. It supplements Java with:

All fully supported in JDK LTS releases 8 - 21 + latest with comprehensive IDE support in IntelliJ IDEA and Android Studio. Manifold consists of a set of modules, one for each feature. Simply add the Manifold dependencies of your choosing to your existing project and begin taking advantage of them.

What's New...

Manifold SQL lets you write native SQL directly and type-safely in your Java code.

  • Query types are instantly available as you type native SQL of any complexity in your Java code
  • Schema types are automatically derived from your database, providing type-safe CRUD, decoupled TX, and more
  • No ORM, No DSL, No wiring, and No code generation build steps

    img_3.png

Who is using Manifold?

Sampling of companies using Manifold:

What can you do with Manifold?

Use the framework to gain direct, type-safe access to any type of resource, such as SQL, JSON, GraphQL, XML, YAML, CSV, and even other languages such as JavaScript. Remove the code gen step in your build process.   Check it out!

SQL: Use native SQL of any complexity directly and type-safely from Java.

Language english =
  "[.sql/]select * from Language where name = 'English'".fetchOne();
Film film = Film.builder("My Movie", english)
  .withDescription("Nice movie")
  .withReleaseYear(2023)
  .build();
MyDatabase.commit();

GraphQL: Use types defined in .graphql files directly, no code gen steps! Make GraphQL changes and immediately use them with code completion.

var query = MovieQuery.builder(Action).build();
var result = query.request("http://com.example/graphql").post();
var actionMovies = result.getMovies();
for (var movie : actionMovies) {
  out.println(
    "Title: " + movie.getTitle() + "\n" +
    "Genre: " + movie.getGenre() + "\n" +
    "Year: " + movie.getReleaseDate().getYear() + "\n");
}

JSON: Use .json schema files directly and type-safely, no code gen steps! Find usages of .json properties in your Java code.

// From User.json
User user = User.builder("myid", "mypassword", "Scott")
  .withGender(male)
  .withDob(LocalDate.of(1987, 6, 15))
  .build();
User.request("http://api.example.com/users").postOne(user);

Add your own methods to existing Java classes, even String, List, and File. Eliminate boilerplate code.   Check it out!

String greeting = "hello";
greeting.myMethod(); // Add your own methods to String!

Favor composition over inheritance. Use @link and @part for automatic interface implementation forwarding and true delegation.

class MyClass implements MyInterface {
  @link MyInterface myInterface; // transfers calls on MyInterface to myInterface

  public MyClass(MyInterface myInterface) {
    this.myInterface = myInterface; // dynamically configure behavior
  }

  // No need to implement MyInterface here, but you can override myInterface as needed
}

Eliminate boilerplate getter/setter code, improve your overall dev experience with properties.

public interface Book {
  @var String title; // no more boilerplate code!
}
// refer to it directly by name
book.title = "Daisy";     // calls setter
String name = book.title; // calls getter 
book.title += " chain";   // calls getter & setter

Additionally, the feature automatically infers properties, both from your existing source files and from compiled classes your project uses. Reduce property use from this:

Actor person = result.getMovie().getLeadingRole().getActor();
Likes likes = person.getLikes();
likes.setCount(likes.getCount() + 1);

to this:

result.movie.leadingRole.actor.likes.count++;

Implement operator methods on any type to directly support arithmetic, relational, index, and unit operators.

// BigDecimal expressions
if (bigDec1 > bigDec2) {
  BigDecimal result = bigDec1 + bigDec2;
  ...
}
// Implement operators for any type
MyType value = myType1 + myType2;

Tuple expressions provide concise syntax to group named data items in a lightweight structure.

var t = (name: "Bob", age: "35");
System.out.println("Name: " + t.name + " Age: " + t.age);

var t = (person.name, person.age);
System.out.println("Name: " + t.name + " Age: " + t.age);

You can also use tuples with new auto type inference to enable multiple return values from a method.

Unit or binding operations are unique to the Manifold framework. They provide a powerfully concise syntax and can be applied to a wide range of applications.

import static manifold.science.util.UnitConstants.*; // kg, m, s, ft, etc
...
Length distance = 100 mph * 3 hr;
Force f = 5.2 kg m/s/s; // same as 5.2 N
Mass infant = 9 lb + 8.71 oz;

Easily work with the Range API using unit expressions. Simply import the RangeFun constants to create ranges.

// imports the `to`, `step`, and other "binding" constants
import static manifold.collections.api.range.RangeFun.*;
...
for (int i: 1 to 5) {
  out.println(i);
}

for (Mass m: 0kg to 10kg step 22r unit g) {
  out.println(m);
}

Use the manifold-science framework to type-safely incorporate units and precise measurements into your applications.

import static manifold.science.util.UnitConstants.*; // kg, m, s, ft, etc.
...
Velocity rate = 65mph;
Time time = 1min + 3.7sec;
Length distance = rate * time;

Use familiar directives such as #define and #if to conditionally compile your Java projects. The preprocessor offers a simple and convenient way to support multiple build targets with a single codebase.   Check it out!

#if JAVA_8_OR_LATER
  @Override
  public void setTime(LocalDateTime time) {...}
#else
  @Override
  public void setTime(Calendar time) {...}
#endif

Unify disparate APIs. Bridge software components you do not control. Access maps through type-safe interfaces.   Check it out!

Map<String, Object> map = new HashMap<>();
MyThingInterface thing = (MyThingInterface) map; // O_o
thing.setFoo(new Foo());
Foo foo = thing.getFoo();
out.println(thing.getClass()); // prints "java.util.HashMap"

Access private features with @Jailbreak to avoid the drudgery and vulnerability of Java reflection.   Check it out!

@Jailbreak Foo foo = new Foo();
// Direct, *type-safe* access to *all* foo's members
foo.privateMethod(x, y, z);
foo.privateField = value;

You now have an option to make checked exceptions behave like unchecked exceptions! No more unintended exception swallowing. No more try/catch/wrap/rethrow boilerplate!

List<String> strings = ...;
List<URL> urls = strings.stream()
  .map(URL::new) // No need to handle the MalformedURLException!
  .collect(Collectors.toList());

Inline variables and expressions in String literals, no more clunky string concat!   Check it out!

int hour = 15;
// Simple variable access with '$'
String result = "The hour is $hour"; // Yes!!!
// Use expressions with '${}'
result = "It is ${hour > 12 ? hour-12 : hour} o'clock";

Author template files with the full expressive power of Java, use your templates directly in your code as types. Supports type-safe inclusion of other templates, shared layouts, and more.   Check it out!

List<User> users = ...;
String content = abc.example.UserSample.render(users);

A template file abc/example/UserSample.html.mtl

<%@ import java.util.List %>
<%@ import com.example.User %>
<%@ params(List<User> users) %>
<html lang="en">
<body>
<% for(User user: users) { %> 
  <% if(user.getDateOfBirth() != null) { %>
    User: ${user.getName()} <br>
    DOB: ${user.getDateOfBirth()} <br>
  <% } %>
<% } %>
</body>
</html>

Use the Manifold plugin to fully leverage Manifold with IntelliJ IDEA and Android Studio. The plugin provides comprehensive support for Manifold including code completion, navigation, usage searching, refactoring, incremental compilation, hotswap debugging, full-featured template editing, integrated preprocessor, and more.

manifold ij plugin

Get the plugin from JetBrains Marketplace

The Manifold project consists of the core Manifold framework and a collection of sub-projects implementing SPIs provided by the core framework. Each project consists of one or more dependencies you can easily add to your project:

Manifold : Core

Manifold : Extensions

Manifold : Delegation

Manifold : Properties

Manifold : Tuples

Manifold : SQL
Manifold : GraphQL
Manifold : JSON
Manifold : XML
Manifold : YAML
Manifold : CSV
Manifold : Property Files
Manifold : Image
Manifold : Dark Java
Manifold : JavaScript

Manifold : Java Templates

Manifold : String Interpolation
Manifold : (Un)checked Exceptions

Manifold : Preprocessor

Manifold : Science

Manifold : Collections
Manifold : I/0
Manifold : Text

Experiment with sample projects:

Platforms

Manifold supports:

Comprehensive IDE support is also available for IntelliJ IDEA and Android Studio.

Join our Slack Group to start a discussion, ask questions, provide feedback, etc. Someone is usually there to help.


manifold's People

Contributors

0xflotus avatar artsiomch avatar bbjubjub2494 avatar cc007 avatar culmat avatar dependabot[bot] avatar dpukyle avatar dylanmeeus avatar eott123 avatar iadcode avatar migroskub avatar p13i avatar proximyst avatar rsmckinney avatar vsch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

manifold's Issues

The program is slow

Hi,I have a test ,It takes a lot of time to run the program for the first time.
image

The project is generated by maven archetype.

Error when compiling in IntelliJ

After upgrading IntelliJ and maybe also the Manifold plugin, I started to get these

Seems to go away ( sometimes ) if I clean the IntelliJ cache

_Error:java: Fatal error processing with Manifold type processor: manifold.ext.ExtensionManifold
on type: temp.Manifold_Temp_Main_2
Please report the error with the accompanying stack trace.
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at manifold.util.ReflectUtil$MethodRef.invokeStatic(ReflectUtil.java:346)
at manifold.ext.ExtensionTransformer.getIncrementalCompileDrivers(ExtensionTransformer.java:410)
at manifold.ext.ExtensionTransformer.findDrivers(ExtensionTransformer.java:378)
at manifold.ext.ExtensionTransformer.incrementalCompileClasses(ExtensionTransformer.java:362)
at manifold.ext.ExtensionTransformer.visitClassDef(ExtensionTransformer.java:277)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:774)
at manifold.ext.ExtensionManifold.process(ExtensionManifold.java:241)
at manifold.internal.javac.TypeProcessor.process(TypeProcessor.java:97)
at manifold.internal.javac.CompiledTypeProcessor.finished(CompiledTypeProcessor.java:256)
at jdk.compiler/com.sun.tools.javac.api.ClientCodeWrapper$WrappedTaskListener.finished(ClientCodeWrapper.java:828)
at jdk.compiler/com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:120)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1410)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1367)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:965)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:100)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:142)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:96)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:90)
at org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:193)
at org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.java:448)
at org.jetbrains.jps.incremental.java.JavaBuilder.compile(JavaBuilder.java:318)
at org.jetbrains.jps.incremental.java.JavaBuilder.doBuild(JavaBuilder.java:243)
at org.jetbrains.jps.incremental.java.JavaBuilder.build(JavaBuilder.java:201)
at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1317)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:993)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1065)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:956)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:788)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:377)
at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:184)
at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:138)
at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:309)
at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:137)
at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:235)
at org.jetbrains.jps.service.impl.SharedThreadPoolImpl.lambda$executeOnPooledThread$0(SharedThreadPoolImpl.java:42)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:514)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at manifold.util.ReflectUtil$MethodRef.invokeStatic(ReflectUtil.java:342)
... 39 more
Caused by: java.lang.IllegalStateException
at manifold.ij.jps.IjIncrementalCompileDriver.getInstance(IjIncrementalCompileDriver.java:26)
... 44 more

Code Completion on Gradle Projects does not work

Intelij does not show the extension methods.

build.grade
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
// -- All manifold, includes all other dependencies listed here --
compile group: 'systems.manifold', name: 'manifold-all', version: '0.48-alpha'
compile files("${System.getProperty('java.home')}/../lib/tools.jar")
}

tasks.withType(JavaCompile) {
options.compilerArgs += '-Xplugin:Manifold'
options.fork = true
}

image

image

Whats wrong here?
Normal Projects without gradle works.

StackOverflowError while large project opening

Describe the bug
StackOverflowError while large project opening

To Reproduce
Open large project: IntellyJ Idea CE source code

Desktop (please complete the following information):
IntelliJ IDEA 2018.3.2 (Community Edition)
Build #IC-183.4886.37, built on December 17, 2018
JRE: 1.8.0_152-release-1343-b26 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.4.0-141-generic

  • Manifold version: 0.39-alpha
  • Manifold IntelliJ plugin version: v0.39-alpha

Stack trace

java.lang.StackOverflowError
	at manifold.api.host.IModule.findTypeManifoldsFor(IModule.java:136)
	at manifold.ij.core.ManModule.findTypeManifoldsFor(ManModule.java:121)
	at manifold.ij.core.ManModule.findTypeManifoldsFor(ManModule.java:131)
	at manifold.ij.core.ManModule.findTypeManifoldsFor(ManModule.java:131)
        .... same line till the end of the stack

Remove manifold yellow pop up

The yellow popup about manifold not being setup for project, can we please default this off and only warn if the project uses manifold and detects a problem.

it is super annoying seeing this on projects that do not use manifold.

Compilation error: Manifold and Spring have a problem

Describe the bug
After the manifold dependencies in gradle.build have been added to the existing project,
the project can not be compiled anymore.

To Reproduce
Steps to reproduce the behavior:

  1. I have installed the Manifold plugin in IntelliJ and restarted IntelliJ.
  2. I've configured the dependencies for Manifold according documentation in existing Gradle project.
    In build.gradle:
    dependencies {
    ...
    compile group: 'systems.manifold', name: 'manifold-all', version: '0.43-alpha'
    compile files("${System.getProperty('java.home')}/../lib/tools.jar")
    }
    tasks.withType(JavaCompile) {
    options.compilerArgs += '-Xplugin:Manifold strings'
    options.fork = true
    }
  3. For Java compiler, I have configured the following parameter in Intellijs:
    -Xplugin:"Manifold dynamic strings"
  4. All Spring-Bean classes from the existing project that have an "Value" annotation can no longer be compiled
    (i.e. when building with Gradle "build" or compile from IntelliJ).
    Here is an example:
    import org.springframework.beans.factory.annotation.Value;
    import org.springframework.stereotype.Component;
    @component
    public class TestProperties {
    ...
    @value("${"agent.username}")
    private String username;
    ...
    }

When compiling the class with Gradle, the following error occurs:
TestProperties.java:95: error: ';' expected
@value("${agent.username}")

When compiling the class from IntelliJ, the following error occurs:
Error: java: package agent.username does not exist

Desktop:

  • OS Type & Version: Microsoft Windows 10 Enterprise, Build 10.0.14393
  • Java/JDK version: 1.8.0_144-b01
  • IntelliJ IDEA version: IntelliJ IDEA 2018.3.4 (Community Edition), Build #IC-183.5429.30, built on January 29, 2019
  • Manifold version: 0.43-alpha
  • Manifold IntelliJ plugin version: v0.43-alpha
  • Gradle version: 4.1
  • Spring boot: 2.0.1.RELEASE
  • Spring (core, beans, test etc.): 5.0.5.RELEASE

Support GraphQL

Support GraphQL with a new type manifold.

GraphQL Java clients suffer from conventional tooling limitations, which include the usual code generation issues, but more specific to the nature of GraphQL is that query response data consists of partially serialized objects. While this is GraphQL's primary strength -- you can specify exactly the bits of information you want in an otherwise fat graph of data -- it also represents a challenge to nominally typed, static OOP languages. How is Java supposed to maintain type-safety and retain the efficiency of GraphQL's tailored query results?

For example, if we have a movie type we can query for a movie, but we only want the name of the movie, the rest of movie's fields, regardless of declared nullability etc. are absent.

{
  movie {
    name
   }
}

How can Java expose this query response type-safely?

The GraphQL type system can likely be modeled with manifold's structural interfaces. Since the query responses encoded as JSON (or YAML) are just Maps of name/value pairs and since a Map dynamically satisfies any structured interface, we can build on the JSON Schema manifold framework.

Work involved:

  1. Write type manifold for GraphQL's type system. This could be a transpiler where we leverage existing work with JSON Schema, or since GraphQL is relatively simple just a straight parser could be easier. Keep in mind token location information must be retained in the parse tree.
  2. No work is necessary (or possible) for the query language. Since a query can be assembled programmatically, there is no static representation, therefore the result of a query can simply be cast to the expected structural interface type. While this is not ideal, it is infinitely more type-safe than a map of name/value pairs.

Note, we can probably do better. In most cases the query is a string literal, therefore it's possible to parse the query statically. What's more, we only need the top-level type -- we don't care about the specifics of the guts of the query, we only need to know outermost type. Thus, even if the query is not a string literal, if we can tease out the toplevel type name, we can determine the type statically.

@JailBreak should work with increment, decrement, and compound assignment operators

@JailBreak should work with increment, decrement, and compound assignment operators

Currently @JailBreak lets you assign to a private field with a standard assignment:

@JailBreak Foo foo = new Foo();
foo.privateField = 8;

This works, but a compound assignment operator fails at runtime:

@JailBreak Foo foo = new Foo();
foo.privateField += 8; // runtime exception

Compile error missing with extension method on generic specialization

If We use nested generic types in defining extension methods it will probably generate a wrong return type.
Example:

public static <T> List<T> awaitAll(@NotNull @This Iterable<? extends CompletionStage<T>> thiz) {
return Flux.fromIterable(thiz).flatMap(Mono::fromCompletionStage).parallel(thiz.toList().size()).collectSortedList((t1, t2) -> 1).block();
    }

Now if we use this extension:

List<CompletableFuture<SendResult<Long, IngesterData>>> completableFutures = ...
List<CompletableFuture<SendResult<Long, IngesterData>>> actualAndWrongType = completableFutures.awaitAll();

While the correct return type must be:

List<SendResult<Long, IngesterData>> wantedAndCorrectType = completableFutures.awaitAll();

Even if I use a list of strings, awaitAll() accepts it and returns a list of strings:

List<String> strings = Arrays.asList("").awaitAll();

If I use direct static method call, I will get correct return type:

List<SendResult<Long, IngesterData>> sendResults = ScIterableExt.awaitAll(completableFutures);

Issue with multiple module project and Extension Methods

Describe the bug
I have module "Empire" and module "EmpireCraft-API"
org.bukkit.entity.Player is in EmpireCraft-API
I created extensions.org.bukkit.entity.Player; in the Empire module which depends on EmpireCraft-API

I receive the following warning:
https://i.imgur.com/P6bxIHr.png

Expected behavior
To not get this warning as it's in a different module

Desktop (please complete the following information):

  • OS Type & Version: Linux Mint 19
  • Java/JDK version: 8/202
  • IntelliJ IDEA version: 2019.1
  • Manifold version: RELEASE
  • Manifold IntelliJ plugin version: .53 alpha

Additional context
Trying to use "New Extension class" gives same issue.

Spring and Spring boot support

Is it possible to use Manifold with Spring and Spring Boot projects?
I tried Manifold with Spring Boot 1.x and it crashed with different exceptions each time.
Probably should try again and post trace here.
Thank you.

Extension method on abstract classes if child implements interface

Is this possible?

package EMC.extensions.org.bukkit.event.block.BlockEvent;

import com.empireminecraft.systems.residence.PermsBuilder;
import com.empireminecraft.systems.residence.flags.Flag;
import manifold.ext.api.Extension;
import manifold.ext.api.This;
import org.bukkit.event.Cancellable;
import org.bukkit.event.block.BlockEvent;

@Extension
public class BlockEventExtensions {
    public static <T extends BlockEvent & Cancellable> boolean checkPerm(@This T event, Flag... flags) {
        return PermsBuilder.at(event.getBlock()).cancel(event).check(flags);
    }
}

I have an abstract class that children may conditionally implement Cancellable.

i want this extension method to only show up on cancellable.

Though I did end up doing this since it was more useful for me anyways, just curious about the other idea

public static boolean checkPerm(@This BlockEvent event, Flag... flags) {
        PermsBuilder builder = PermsBuilder.at(event.getBlock());
        if (event instanceof Cancellable) {
            builder.cancel((Cancellable) event);
        }
        return builder.check(flags);
    }

Support extension methods on a specialized version of a raw type

In addition to generic types, also support extension methods on specific parameterized instances of generic types. For example:

package extensions.java.util.List;

import manifold.ext.api.Extension;
import manifold.ext.api.This;
import java.util.List;

@Extension
public class MyListOfStringExt {
  public static String foo(@This List<String>  thiz) {
    return thiz.get( 0 );
  }
}

The idea is the type variables are inferred from the @this parameter type and, thus, only apply accordingly. An alternative format follows more closely with a normal extension method on a generic class, which specifies the type var. This one has the advantage of supporting covariance:

  public static <E extends String> String foo(@This List<E>  thiz) {
    return thiz.get( 0 );
  }

Should be straightforward to implement in Manifold. The challenge is probably more with Intellij to get code completion to filter out such extension methods when they don't apply.

@Self on array will produce a CCE in a subclass context

Describe the bug
@self on array will produce a CCE in a subclass context

To Reproduce

class Foo {
    @Self Foo[] getArray() {
      return new Foo[] {this};
    }
}

class Bar extends Foo {
}

Bar[] bars = new Bar().getArray(); // ClassCastException at runtime

Expected behavior
Should work without error.

Screenshots
If applicable, add screenshots to help explain your problem (drag/drop them here).

Desktop (please complete the following information):

  • Java/JDK version: 8
  • IntelliJ IDEA version: 2018.3
  • Manifold version: 0.28-alpha
  • Manifold IntelliJ plugin version: 0.28-alpha

Stack trace
java.lang.ClassCastException: [Lmanifold.ext.SelfTypeTest$Foo; cannot be cast to [Lmanifold.ext.SelfTypeTest$Bar;

"plug-in not found" using dependency "manifold" instead of "manifold-all"

Oracle JDK 8 (1.8.0_131) and Gradle 4.10.3:

tasks.withType(JavaCompile) {
    options.compilerArgs += '-Xplugin:Manifold'
    options.fork = true
}

dependencies {
    compileOnly libraries.lombok

    compile group: 'systems.manifold', name: 'manifold', version: '0.45-alpha'
    compile group: 'systems.manifold', name: 'manifold-properties', version: '0.45-alpha'
    compile files("\${System.getProperty('java.home')}/../lib/tools.jar")
}

When the tasks compileJava or compileTestJava are executed the following message is logged:
plug-in not found: Manifold

This message is not logged if manifold-all.jar is used as dependency.

IntelliJ plugin does not play nice with Lombok

Describe the bug

The issue appears to be that the IntelliJ plugin always adds the "-processorpath" flag to the IntelliJ javac params. This causes javac to not check the rest of the classpath for additional annotation processors, like Lombok.

I didn't have time today to check as to whether or not this also occurs in single-module Gradle projects, but I can confirm this is an issue on multi-modular ones, at least.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new Gradle project
  2. Create a subproject with Manifold as a compile and annotationProcessor dependency along with Lombok as a compileOnly and annotationProcessor dependency
  3. Import the project as a Gradle project in IntelliJ
  4. Install the Manifold and Lombok plugins to IntelliJ
  5. Enable annotation processing on the project
  6. Create a class using some Lombok features (e.g., @getter)
  7. Create a class using Manifoold features, like an extension method
  8. Compile and watch as javac successfully processes the Manifold annotations, yet fails to handle Lombok

Expected behavior

I expect the plugin to not add the '-processorpath' parameter when Manifold is already specified as an annotation processor in Gradle.

Screenshots

N/A

Desktop (please complete the following information):

  • OS Type & Version: Windows 10 LTSC 1809
  • Java/JDK version: 11.0.1
  • IntelliJ IDEA version: 2018.3.3
  • Manifold version: 0.39-alpha
  • Manifold IntelliJ plugin version: 0.39-alpha
  • Gradle version: 5.1

Additional context

N/A

Stack trace

N/A

Does manifold support properties files in the "default package"?

In my Gradle project I have a properties file src/main/resources/abc-info.properties. Code completion with Intellij doesn't work for this properties file, neither an import abc_info;. Moving abc-info.properties to a subfolder abc, code completion works as documented in the manifold doc.

Is this a known limitation?

References to extension methods do not compile with latest IntelliJ IDEA 2019.1 EAP

Describe the bug
References to extension methods defined in extensions local to a project do not compile with latest IntelliJ EAP Snapshot (2019.1)

To Reproduce
Steps to reproduce the behavior:

  1. Create an extension class in IntelliJ for String, add a method foo()
  2. Use the method in another class: "hi".foo()
  3. Compile with IntelliJ

Expected behavior
Should compile without errors

Actual Behavior
Compile error, method not found for foo()

Desktop (please complete the following information):

  • IntelliJ IDEA version: Latest EAP Snapshot (2019.1)
  • Manifold version: 0.29-alpha
  • Manifold IntelliJ plugin version: 0.29-alpha

JDK plugin configuration cause NullPointerException bug

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. configura the maven-resources-plugin compiler args by adding.
   <compilerArgs>

              <!-- Add the Manifold plugin, with string templates and checked exception suppression enabled -->
              <!--<arg>-Xplugin:Manifold strings exceptions</arg>-->
              <arg>-Xplugin:Manifold strings</arg>
            </compilerArgs>

Other configuration related to JDK 8, I have followed the set up instructions.
2. run a hello world project created by myself.
3. When do mvn compile, I got a null pointer exception.
4. If I commented Manifold configurations JDK8 in pom.xml and comment Manifold related code, my project compiles and runs successfuly. so I think there is something wrong with this part or the manifold plugin or other manifold configuration. Could you help take a look?

Capture

Expected behavior
We expect the project to be compiled successfuly

Screenshots
If applicable, add screenshots to help explain your problem (drag/drop them here).

Desktop (please complete the following information):

  • OS Type & Version: Windows Server 2017 Datacenter
  • Java/JDK version: 1.8.0_131
  • IntelliJ IDEA version: 2018.3.2
  • Manifold version:0.59-alpha
  • Manifold IntelliJ plugin version: 0.59-alpha

Additional context
Add any other context about the problem here.

Stack trace
Please include a stack trace if applicable
An exception has occurred in the compiler (1.8.0_131). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException
at com.sun.tools.javac.main.Main.compile(Main.java:473)
at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:126)
at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:174)
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:1129)
at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:188)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
at manifold.internal.javac.JavacPlugin.injectManFileManager(JavacPlugin.java:445)
at manifold.internal.javac.JavacPlugin.hijackJavacFileManager(JavacPlugin.java:306)
at manifold.internal.javac.JavacPlugin.init(JavacPlugin.java:172)
at com.sun.tools.javac.main.Main.compile(Main.java:470)
... 29 more
Caused by: java.lang.NullPointerException
at manifold.util.concurrent.ConcurrentWeakHashMap.get(ConcurrentWeakHashMap.java:1009)
at manifold.util.ReflectUtil.getRawMethodFromCache(ReflectUtil.java:710)
at manifold.util.ReflectUtil.getMethodFromCache(ReflectUtil.java:700)
at manifold.util.ReflectUtil.method(ReflectUtil.java:156)
at manifold.internal.javac.JavacPlugin.injectManFileManager(JavacPlugin.java:413)
... 32 more

IDE support for custom Manifolds

Hello!

First of all: Great project, I love the idea.

I'm trying to create a custom manifold. For getting started I created a simple example based on the "Build Your Own Manifold" documentation. It creates a class with a single method.

    public SrcClass make() {

        return new SrcClass(fqn, SrcClass.Kind.Class)
            .addMethod(new SrcMethod()
                .modifiers(Modifier.PUBLIC)
                .name("sayHello")
                .body(new SrcStatementBlock()
                    .addStatement(new SrcRawStatement()
                    .rawText("System.out.println(\"Hello!\");")))
                );
    }

I created a test which creates an object of that class and calls the sayHello method. It compiles and works as expected. However, IntelliJ does not recognize the class or the package and marks it as an error. Is there a way to get IntelliJ to find the generated package/class?

java.lang.NullPointerException when Intellij Idea starts with Manifold plugin and Lombok plugin installed

I am getting an exception when Intellij Idea starts with Manifold and Lombok (https://github.com/mplushnikov/lombok-intellij-plugin) plugins installed.

Version information

  • Manifold plugin version: Version: 0.26.1-alpha
  • IDEA Version: IntelliJ IDEA 2018.2.5 (Ultimate Edition)
    Build #IU-182.4892.20, built on October 16, 2018
  • JDK Version: JRE: 1.8.0_152-release-1248-b19 amd64
    JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
  • OS Type & Version: Linux 4.15.0-29-generic Kubuntu 18.04
  • Lombok Plugin Version: Version: 0.22.2018.2
  • Lombok Dependency Version: 1.16.20

Steps to reproduce

  1. Install lombok plugin
  2. Install manifold plugin
  3. Close and open Intellij Idea

Stacktrace

de.plushnikov.intellij.plugin.LombokPluginProjectValidatorComponent@7b64959

java.lang.NullPointerException
	at manifold.ij.core.IjManifoldHost.addTypeSystemListenerAsWeakRef(IjManifoldHost.java:57)
	at manifold.api.type.ResourceFileTypeManifold.init(ResourceFileTypeManifold.java:58)
	at manifold.api.image.ImageTypeManifold.init(ImageTypeManifold.java:23)
	at manifold.internal.host.SimpleModule.lambda$initializeTypeManifolds$1(SimpleModule.java:180)
	at java.lang.Iterable.forEach(Iterable.java:75)
	at manifold.internal.host.SimpleModule.initializeTypeManifolds(SimpleModule.java:180)
	at manifold.ij.core.ManProject.defineModules(ManProject.java:394)
	at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:941)
	at manifold.ij.core.ManProject.lambda$init$1(ManProject.java:168)
	at manifold.util.concurrent.LockingLazyVar$1.init(LockingLazyVar.java:131)
	at manifold.util.concurrent.LockingLazyVar.get(LockingLazyVar.java:45)
	at manifold.ij.core.ManProject.getModules(ManProject.java:199)
	at manifold.ij.extensions.ManTypeFinder.findPackage(ManTypeFinder.java:227)
	at com.intellij.psi.impl.JavaPsiFacadeImpl.findPackage(JavaPsiFacadeImpl.java:239)
	at de.plushnikov.intellij.plugin.LombokPluginProjectValidatorComponent.hasLombokLibrary(LombokPluginProjectValidatorComponent.java:110)
	at de.plushnikov.intellij.plugin.LombokPluginProjectValidatorComponent.projectOpened(LombokPluginProjectValidatorComponent.java:53)
	at com.intellij.openapi.project.impl.ProjectManagerImpl.fireProjectOpened(ProjectManagerImpl.java:781)
	at com.intellij.openapi.project.impl.ProjectManagerImpl.lambda$null$6(ProjectManagerImpl.java:390)
	at com.intellij.openapi.application.TransactionGuardImpl.lambda$submitTransactionAndWait$2(TransactionGuardImpl.java:165)
	at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:88)
	at com.intellij.openapi.application.TransactionGuardImpl.lambda$submitTransaction$1(TransactionGuardImpl.java:111)
	at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.doRun(LaterInvocator.java:447)
	at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.runNextEvent(LaterInvocator.java:431)
	at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:415)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:762)
	at java.awt.EventQueue.access$500(EventQueue.java:98)
	at java.awt.EventQueue$3.run(EventQueue.java:715)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:732)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:781)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:722)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:382)
	at com.intellij.ide.IdeEventQueue.pumpEventsForHierarchy(IdeEventQueue.java:864)
	at com.intellij.openapi.progress.util.ProgressWindow.startBlocking(ProgressWindow.java:205)
	at com.intellij.openapi.progress.util.ProgressWindow.startBlocking(ProgressWindow.java:191)
	at com.intellij.openapi.application.impl.ApplicationImpl.runProcessWithProgressSynchronously(ApplicationImpl.java:588)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcessWithProgressSynchronously(CoreProgressManager.java:446)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcessWithProgressSynchronously(ProgressManagerImpl.java:109)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcessWithProgressSynchronously(CoreProgressManager.java:250)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcessWithProgressSynchronously(CoreProgressManager.java:203)
	at com.intellij.openapi.project.impl.ProjectManagerImpl.loadProjectUnderProgress(ProjectManagerImpl.java:439)
	at com.intellij.openapi.project.impl.ProjectManagerImpl.openProject(ProjectManagerImpl.java:414)
	at com.intellij.platform.PlatformProjectOpenProcessor.doOpenProject(PlatformProjectOpenProcessor.java:245)
	at com.intellij.ide.RecentProjectsManagerBase.doOpenProject(RecentProjectsManagerBase.java:579)
	at com.intellij.ide.RecentProjectsManagerBase.doReopenLastProject(RecentProjectsManagerBase.java:706)
	at com.intellij.ide.RecentProjectsManagerBase$MyAppLifecycleListener.appStarting(RecentProjectsManagerBase.java:748)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.intellij.util.messages.impl.MessageBusConnectionImpl.deliverMessage(MessageBusConnectionImpl.java:117)
	at com.intellij.util.messages.impl.MessageBusImpl.doPumpMessages(MessageBusImpl.java:426)
	at com.intellij.util.messages.impl.MessageBusImpl.pumpWaitingBuses(MessageBusImpl.java:387)
	at com.intellij.util.messages.impl.MessageBusImpl.pumpMessages(MessageBusImpl.java:376)
	at com.intellij.util.messages.impl.MessageBusImpl.sendMessage(MessageBusImpl.java:357)
	at com.intellij.util.messages.impl.MessageBusImpl.access$200(MessageBusImpl.java:43)
	at com.intellij.util.messages.impl.MessageBusImpl$2.invoke(MessageBusImpl.java:208)
	at com.sun.proxy.$Proxy56.appStarting(Unknown Source)
	at com.intellij.idea.IdeaApplication$IdeStarter.lambda$main$1(IdeaApplication.java:374)
	at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:88)
	at com.intellij.openapi.application.TransactionGuardImpl.lambda$submitTransaction$1(TransactionGuardImpl.java:111)
	at com.intellij.openapi.application.TransactionGuardImpl.submitTransaction(TransactionGuardImpl.java:120)
	at com.intellij.openapi.application.TransactionGuard.submitTransaction(TransactionGuard.java:122)
	at com.intellij.idea.IdeaApplication$IdeStarter.main(IdeaApplication.java:372)
	at com.intellij.idea.IdeaApplication.lambda$run$1(IdeaApplication.java:212)
	at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:195)
	at com.intellij.idea.IdeaApplication.run(IdeaApplication.java:212)
	at com.intellij.idea.IdeaApplication.lambda$initApplication$0(IdeaApplication.java:75)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:762)
	at java.awt.EventQueue.access$500(EventQueue.java:98)
	at java.awt.EventQueue$3.run(EventQueue.java:715)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:732)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:361)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

Support `Self` type with extension methods

Is There any way that we could write extension methods for generic types? For example:

    public static <T> T println(@This T thiz) {
        System.out.println(thiz); 
        return thiz;
    }

Or

    public static <T extends Collection<? extends Long>> T printMax(@This T thiz) {
        System.out.println(thiz.max(Long::compareTo));
        return thiz;
    }

Thanks again for this awesome library.

Support method reference to extension method

Describe the bug
Support method reference to extension method:

public static String hello(@This String thiz) {
  return "hello";
}

void foo(Supplier<String> supplier) { . . . )

String str = "hi";
foo(str::hello); // Boom

Workaround
Use a lambda instead:

String str = "foo";
foo(() -> str.hello()); // Ok

Include use cases / case studies

I think it would be a great addition to the documentation to include user stories or case studies. Like:

"Ben wanted to create a library for Java, but he was afraid other people couldn't use it because of nominative typing limitations, so he decided to use @structural annotations from the manifold Java library".

In my case, yes, I am creating a Java library - but I want to make it easy for my users to incorporate the library into their existing code, and structural typing makes that a lot easier as far as I can tell.

Referencing other local JSON Schemas

I have strong doubts whether this is a bug or not, but it is definitely a nice-to-have feature which is foreseen by the JSON Schema specification.

What the specification states

The Schema References With "$ref" section states the following:

Schemas can be identified by any URI that has been given to them, including a JSON Pointer or their URI given directly by "$id". In all cases, dereferencing a "$ref" reference involves first resolving its value as a URI reference against the current base URI per RFC 3986.

As an example it provides the following simple case:

When an implementation encounters the reference to "other.json", it resolves this to <http://example.net/other.json>, which is not defined in this document. If a schema with that identifier has otherwise been supplied to the implementation, it can also be used automatically.

And this is how it works in the latest version of the Manifold, no offense here. 😄 We are able to reference the schema with the same base URI, i.e. on the same level in the filesystem's directory structure. It compiles and it runs smoothly.

At the same time, it is impossible to introduce any hierarchical structure on top of one's schemas, i.e. to use subdirectories and reference other schemas relatively in both directions: forth with "sub/other.json" and back with "../other.json".

But there are these "can be identified by any URI" and "In all cases <...> resolving its value as a URI reference against the current base URI" parts that make me believe that such a scenario is also considered possible, yet omitted in the current Manifold's implementation.

What the specification doesn't state yet

What causes my doubts is an associated cite reference:

What should implementations do when the referenced schema is not known? Are there circumstances in which automatic network dereferencing is allowed? A same origin policy? A user-configurable option? In the case of an evolving API described by Hyper-Schema, it is expected that new schemas will be added to the system dynamically, so placing an absolute requirement of pre-loading schema documents is not feasible.

While it is not feasible in the wild (a.k.a. World Wild Web), we are dealing with a special case of "static resources as Java Types" and it would seem that it doesn't matter much. However, there might be matters to discuss.

What everyone (including myself) definitely wants to be able to do is to work with such references without fuss in the Manifold's "dynamic mode".

Scenarios in scope

Test 1

Checks an ability to reference the "sub/other.json" schema from the current one.

Manifold is unable to compile such a schema in the current implementation:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project manifold-json-subschema-test: Compilation failure: Compilation failure:
[ERROR] /abc/res/Test1.java:[39,11] cannot find symbol
[ERROR] symbol:   class SubTest1
[ERROR] location: interface abc.res.Test1
[ERROR] /abc/res/Test1.java:[44,27] cannot find symbol
[ERROR] symbol:   class SubTest1
[ERROR] location: interface abc.res.Test1
[ERROR] /abc/res/Test1.java:[70,32] cannot find symbol
[ERROR] symbol:   class SubTest1
[ERROR] location: class abc.res.Test1.Builder
[ERROR] /abc/res/Test1.java:[82,27] cannot find symbol
[ERROR] symbol:   class SubTest1
[ERROR] location: class abc.res.Test1.Copier 

It also happens that Manifold's IntelliJ plugin is dealing fine (w/o "No such file or directory" error) with such a "$ref".

test-1

Test 2

Checks an ability to back-reference the "../other.json" schema from the current one.

⚠️ In case Test 1 succeeds, this one is also expected to pass according to the URI Relative Resolution rules.

Now it gives almost the same compilation error:

[ERROR] /abc/res/sub/SubTest2.java:[39,11] cannot find symbol
[ERROR] symbol:   class Test2
[ERROR] location: interface abc.res.sub.SubTest2
[ERROR] /abc/res/sub/SubTest2.java:[44,25] cannot find symbol
[ERROR] symbol:   class Test2
[ERROR] location: interface abc.res.sub.SubTest2
[ERROR] /abc/res/sub/SubTest2.java:[70,30] cannot find symbol
[ERROR] symbol:   class Test2
[ERROR] location: class abc.res.sub.SubTest2.Builder
[ERROR] /abc/res/sub/SubTest2.java:[82,25] cannot find symbol
[ERROR] symbol:   class Test2
[ERROR] location: class abc.res.sub.SubTest2.Copier

And is equally located by the IntelliJ plugin.

test-2


As always, test project is available here:
https://github.com/marksto/manifold-json-subschema-test

@Self not working with annotation processors such as lombok

Hi

This is an extension method with @Self type from Manifold Docs:

public static <K,V> @Self Map<K,V> add(@This Map<K,V> thiz, K key, V value) {
  thiz.put(key, value);
  return thiz;
}

If I use this extension method it will throw a compile time error:

// Will throw Error: java: incompatible types: java.util.Map<java.lang.Integer,java.lang.String> cannot be converted to java.util.HashMap<java.lang.Integer,java.lang.String>
HashMap<Integer,String> map1 = new HashMap<Integer, String>().add(1, "One").add(2, "Two").add(3, "Three");

I use Manfold version RELEASE and JDK 8.

New feature announcement: @JailBreak

Gain direct, type-safe access to otherwise inaccessible classes/methods/fields with @JailBreak:

Annotate the type on a variable, parameter, or new expression with @JailBreak to avoid the drudgery and vulnerability of Java reflection.

@JailBreak Foo foo = new Foo();
foo.callPrivateMethod();

and with the new jailbreak() extension method on Object:

anyThing.jailbreak().anyPrivateMethod();

Almost never write another line of junky reflection code again.

Learn more

Type Manifold for Yaml

Type Manifold for Json is great, and we also use Yaml a lot, so will you please add support for Yaml in the future? Thanks!

Support String literal templates

Support String literal templates where String literals can have embedded expressions:

int count = 0;
. . .
String count = "Count: $count";

and

int extra = 0;
. . .
int count = 0;
. . .
String count = "Count: ${count + extra}";

Add a separate component for this where JavacPlugin's TaskListener#finished() triggers it during the PARSE phase. The idea is to scan String literals for $ expressions, build expression parse trees via JavaParser#parseText(), and use them as operands to a String concatenation AST we build by hand. The AST replaces the String literal. Note the AST will be wrapped as a parenthesized expression so that it can be treated as an atomic String literal eg:

"abc $123" + "def"

becomes:

("abc " + 123) + "def"

NPE out of the blue while working with JS Files

Describe the bug
While using IntelliJ version 2018.3.5 and working with JS files, I am experiencing periodical plugin crashes.

Stack trace
java.lang.NullPointerException
at manifold.api.gen.SrcType.(SrcType.java:53)
at manifold.api.gen.SrcType.(SrcType.java:48)
at manifold.api.gen.SrcParameter.type(SrcParameter.java:62)
at manifold.api.gen.SrcParameter.(SrcParameter.java:39)
at manifold.js.parser.tree.ParameterNode.toParamList(ParameterNode.java:54)
at manifold.js.JavascriptProgram.makeSrcParameters(JavascriptProgram.java:86)
at manifold.js.JavascriptProgram.genProgram(JavascriptProgram.java:72)
at manifold.js.JavascriptCodeGen.make(JavascriptCodeGen.java:69)
at manifold.js.JavascriptTypeManifold.contribute(JavascriptTypeManifold.java:55)
at manifold.js.JavascriptTypeManifold.contribute(JavascriptTypeManifold.java:29)
at manifold.api.type.ResourceFileTypeManifold.contribute(ResourceFileTypeManifold.java:377)
at manifold.ij.extensions.ManifoldPsiClassCache.createPrimaryType(ManifoldPsiClassCache.java:238)
at manifold.ij.extensions.ManifoldPsiClassCache.getPsiClass_NoShortCircuit(ManifoldPsiClassCache.java:132)
at manifold.ij.extensions.ManifoldPsiClassCache._getPsiClass(ManifoldPsiClassCache.java:90)
at manifold.ij.extensions.ManifoldPsiClassCache.getPsiClass(ManifoldPsiClassCache.java:78)
at manifold.ij.extensions.ManShortNamesCache.findPsiClasses(ManShortNamesCache.java:65)
at manifold.ij.extensions.ManShortNamesCache.findPsiClasses(ManShortNamesCache.java:47)
at manifold.ij.extensions.ManShortNamesCache.getClassesByName(ManShortNamesCache.java:40)
at com.intellij.psi.search.PsiShortNamesCache.processClassesWithName(PsiShortNamesCache.java:206)
at com.intellij.psi.impl.CompositeShortNamesCache.processClassesWithName(CompositeShortNamesCache.java:262)
at com.intellij.ide.util.gotoByName.DefaultClassNavigationContributor.processElementsWithName(DefaultClassNavigationContributor.java:114)
at com.intellij.ide.util.gotoByName.ContributorsBasedGotoByModel.lambda$getElementsByName$1(ContributorsBasedGotoByModel.java:174)
at com.intellij.concurrency.ApplierCompleter.execAndForkSubTasks(ApplierCompleter.java:133)
at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1163)
at com.intellij.concurrency.ApplierCompleter.lambda$wrapInReadActionAndIndicator$1(ApplierCompleter.java:105)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:582)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:532)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:87)
at com.intellij.concurrency.ApplierCompleter.wrapInReadActionAndIndicator(ApplierCompleter.java:116)
at com.intellij.concurrency.ApplierCompleter.compute(ApplierCompleter.java:99)
at java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:731)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool.helpComplete(ForkJoinPool.java:1870)
at java.util.concurrent.ForkJoinPool.externalHelpComplete(ForkJoinPool.java:2467)
at java.util.concurrent.ForkJoinTask.externalAwaitDone(ForkJoinTask.java:324)
at java.util.concurrent.ForkJoinTask.doJoin(ForkJoinTask.java:391)
at java.util.concurrent.ForkJoinTask.join(ForkJoinTask.java:719)
at java.util.concurrent.ForkJoinPool.invoke(ForkJoinPool.java:2616)
at com.intellij.concurrency.JobLauncherImpl.invokeConcurrentlyUnderProgress(JobLauncherImpl.java:65)
at com.intellij.concurrency.JobLauncher.invokeConcurrentlyUnderProgress(JobLauncher.java:56)
at com.intellij.ide.util.gotoByName.ContributorsBasedGotoByModel.getElementsByName(ContributorsBasedGotoByModel.java:210)
at com.intellij.ide.util.gotoByName.DefaultChooseByNameItemProvider.processByNames(DefaultChooseByNameItemProvider.java:221)
at com.intellij.ide.util.gotoByName.DefaultChooseByNameItemProvider.filterElements(DefaultChooseByNameItemProvider.java:85)
at com.intellij.ide.util.gotoByName.DefaultChooseByNameItemProvider.filterElements(DefaultChooseByNameItemProvider.java:45)
at com.intellij.ide.actions.searcheverywhere.AbstractGotoSEContributor.lambda$fetchElements$1(AbstractGotoSEContributor.java:92)
at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1168)
at com.intellij.openapi.progress.util.ProgressIndicatorUtils.lambda$runInReadActionWithWriteActionPriority$0(ProgressIndicatorUtils.java:70)
at com.intellij.openapi.progress.util.ProgressIndicatorUtils.lambda$runWithWriteActionPriority$1(ProgressIndicatorUtils.java:123)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:164)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:539)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:87)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:151)
at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runWithWriteActionPriority(ProgressIndicatorUtils.java:112)
at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runInReadActionWithWriteActionPriority(ProgressIndicatorUtils.java:70)
at com.intellij.ide.actions.searcheverywhere.AbstractGotoSEContributor.fetchElements(AbstractGotoSEContributor.java:86)
at com.intellij.ide.actions.searcheverywhere.MultiThreadSearcher$ContributorSearchTask.lambda$run$1(MultiThreadSearcher.java:200)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:164)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:582)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:532)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:87)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:151)
at com.intellij.ide.actions.searcheverywhere.MultiThreadSearcher$ContributorSearchTask.run(MultiThreadSearcher.java:200)
at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:229)
at com.intellij.util.ConcurrencyUtil$3.run(ConcurrencyUtil.java:215)
at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:314)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Inconsistency in extension method

In my eyes extension method is just a syntax sugar. so if a non-extension method works, so sould extension method. And I found some cases that violates above principle.

package ir.mohaymen.analytics.utilities.extensions.java.util.List;

import manifold.ext.api.Extension;
import manifold.ext.api.This;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;

@Extension
public class MyListOfStringExt {
  public static <P, T extends List<P>, R> R let4(@This List<P> thiz, Function<T, R> mapper) {
    return mapper.apply((T) thiz);
  }

  public static void test() {
    List<String> x = new ArrayList<>();

    String x1 = x.let4(it -> it.get(0));  // Doesn't compile: Bad return type in lambda expression: P cannot 
                                              // be converted to Object 
    String x2 = let4(x, it -> it.get(0)); // Works

    Integer x3 = x.let4((List<String> it) -> it.size()); // Doesn't compile: no instance(s) of type variable(s) 
                                                           //exist so that List<String> conforms to List<P>
    Integer x4 = let4(x, (List<String> it) -> it.size());  // Works

  }
}

manifold version: 0.45-alpha
JDK version: 11.0.2

Manifold Structural interfaces and Avro Framework

Hi,

in a project that I am involved at the moment, we are using Apache Avro Framework (specialised on schema based byte serialisation/deserialisation) unfortunately due to nature of this framework, it does not support that schema defined classes inheriting form interfaces.

To solve this problem, I thought Manifold and Structural interfaces could be good solution, so I build something from existing examples but now I getting an exception that I can't do anything about. The question is this a bug or I am using the manifold wrongly... the exception that I am getting is the following.

[ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] /org/salgar/avro/DemoAvro.java:[102,7] reference to SpecificRecordBuilderBase is ambiguous both constructor SpecificRecordBuilderBase(org.apache.avro.specific.SpecificRecordBuilderBase<T>) in org.apache.avro.specific.SpecificRecordBuilderBase and constructor SpecificRecordBuilderBase(T) in org.apache.avro.specific.SpecificRecordBuilderBase match [ERROR] /org/salgar/avro/DemoAvro.java:[105,7] reference to SpecificRecordBuilderBase is ambiguous both constructor SpecificRecordBuilderBase(org.apache.avro.specific.SpecificRecordBuilderBase<T>) in org.apache.avro.specific.SpecificRecordBuilderBase and constructor SpecificRecordBuilderBase(T) in org.apache.avro.specific.SpecificRecordBuilderBase match [ERROR] /org/salgar/avro/DemoAvro.java:[108,7] reference to SpecificRecordBuilderBase is ambiguous both constructor SpecificRecordBuilderBase(org.apache.avro.specific.SpecificRecordBuilderBase<T>) in org.apache.avro.specific.SpecificRecordBuilderBase and constructor SpecificRecordBuilderBase(T) in org.apache.avro.specific.SpecificRecordBuilderBase match [INFO] 3 errors

I produced two maven project to reproduce the problem...one is responsible to create Avro classes 'avro-demo' (must run first
manifold_avro_demo.zip
) and the other to make Manifold extension and some logic 'manifold-demo' but it crashes during the 'mvn clean install'..

Thx for feedback

Can't use extension methods from Jar dependency

I asked a question by email. The question was this:

Could we use Extensions from other libraries?
I have written a library of extensions. But I can't call these extension methods from other projects and the compiler throws this error:

java: cannot find symbol
symbol: method println()
location: variable hello of type java.lang.String

My extensions can be called from their project successfully but can't be called from other projects.
Is there any way to support this?

Remove "unused" variable warnings when used in String Template

Describe the bug
Remove "unused" variable warnings when used in String Template

Example

String name = "foo"; // Warning: Variable 'name' is assigned but never access
String str = "Name = $name";

The warning is invalid because name is used in the string literal.

Expected behavior
No warning

Desktop (please complete the following information):

  • Manifold version: 0.59-alpha

Runtime exception: Structural identity doesn't work for method references

Describe the bug
items.stream().map(item -> item.getId()).forEach(System.out::println)
items.stream().map(Item::getId).forEach(System.out::println); 🆘

To Reproduce
Test project: https://github.com/marksto/manifold-cast-exception
mvn clean install

Expected behavior
Structural identity works for method references in Java 8+.

Desktop (please complete the following information):

  • OS Type & Version: "mac os x", version: "10.14.3", arch: "x86_64", family: "mac"
  • Java/JDK version: Java version: 1.8.0_172, vendor: Oracle Corporation
  • IntelliJ IDEA version: 2018.1.2
  • Manifold version: 0.59-alpha
  • Manifold IntelliJ plugin version: 0.59-alpha

Stack trace

Exception in thread "main" java.lang.ClassCastException: manifold.ext.DataBindings cannot be cast to abc.schema.Item
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
	at abc.RunMe.loadItemsArray_PlainInterface(RunMe.java:39)
	at abc.RunMe.main(RunMe.java:22)

Compilation error: JSON Schema

Describe the bug
Manifold doesn't seem to compile the provided JSON Schema properly with Java 8.
Test project: https://github.com/marksto/manifold-json-schema-test

To Reproduce
mvn clean install

Expected behavior
Project compiles without errors.

Desktop (please complete the following information):

  • OS Type & Version: "mac os x", version: "10.14.3", arch: "x86_64", family: "mac"
  • Java/JDK version: Java version: 1.8.0_172, vendor: Oracle Corporation
  • IntelliJ IDEA version: 2018.1.2
  • Manifold version: 0.56-alpha
  • Manifold IntelliJ plugin version: 0.56-alpha

Stack trace

/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/bin/java -Dmaven.multiModuleProjectDirectory=XXX/manifold-json-schema-test "-Dmaven.home=/Applications/IntelliJ IDEA CE.app/Contents/plugins/maven/lib/maven3" "-Dclassworlds.conf=/Applications/IntelliJ IDEA CE.app/Contents/plugins/maven/lib/maven3/bin/m2.conf" "-javaagent:/Applications/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar=60100:/Applications/IntelliJ IDEA CE.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Applications/IntelliJ IDEA CE.app/Contents/plugins/maven/lib/maven3/boot/plexus-classworlds-2.5.2.jar" org.codehaus.classworlds.Launcher -Didea.version=2018.1.2 clean install -e
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building manifold-json-schema-test 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ manifold-json-schema-test ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ manifold-json-schema-test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ manifold-json-schema-test ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to XXX/manifold-json-schema-test/target/classes
[INFO] /abc/res/Test.java: abc/res/Test.java uses unchecked or unsafe operations.
[INFO] /abc/res/Test.java: Recompile with -Xlint:unchecked for details.
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /abc/res/Test.java:[210,52] unexpected type
  required: reference
  found:    double
[ERROR] /abc/res/Test.java:[102,48] unexpected type
  required: reference
  found:    double
[ERROR] /abc/res/Test.java:[231,53] unexpected type
  required: reference
  found:    int
[ERROR] /abc/res/Test.java:[113,49] unexpected type
  required: reference
  found:    int
[ERROR] /abc/res/Test.java:[149,53] unexpected type
  required: reference
  found:    double
[ERROR] /abc/res/Test.java:[154,54] unexpected type
  required: reference
  found:    int
[ERROR] /abc/res/Test.java:[176,48] unexpected type
  required: reference
  found:    double
[ERROR] /abc/res/Test.java:[181,49] unexpected type
  required: reference
  found:    int
[INFO] 8 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.255 s
[INFO] Finished at: 2019-04-07T13:58:02+03:00
[INFO] Final Memory: 39M/219M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project manifold-json-schema-test: Compilation failure: Compilation failure:
[ERROR] /abc/res/Test.java:[210,52] unexpected type
[ERROR] required: reference
[ERROR] found:    double
[ERROR] /abc/res/Test.java:[102,48] unexpected type
[ERROR] required: reference
[ERROR] found:    double
[ERROR] /abc/res/Test.java:[231,53] unexpected type
[ERROR] required: reference
[ERROR] found:    int
[ERROR] /abc/res/Test.java:[113,49] unexpected type
[ERROR] required: reference
[ERROR] found:    int
[ERROR] /abc/res/Test.java:[149,53] unexpected type
[ERROR] required: reference
[ERROR] found:    double
[ERROR] /abc/res/Test.java:[154,54] unexpected type
[ERROR] required: reference
[ERROR] found:    int
[ERROR] /abc/res/Test.java:[176,48] unexpected type
[ERROR] required: reference
[ERROR] found:    double
[ERROR] /abc/res/Test.java:[181,49] unexpected type
[ERROR] required: reference
[ERROR] found:    int
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project manifold-json-schema-test: Compilation failure
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
	at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
	at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:1215)
	at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:188)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
	... 21 more
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Enum's without default constructor can't be extended

Describe the bug
Given this ugly file:
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/Material.java
Simply trying to start the stub of extensions like this:

package EMC.extensions.org.bukkit.Material;
import manifold.ext.api.Extension;
@Extension
public class MaterialExtensions {}

I can no longer compile as I get this error:
https://gist.github.com/aikar/9beca78a2fa7b6f9abc774aec31bdb45

Deleting the empty extension file fixes the issue. but I am prevented from extending this class.

Same issue happens to me on World.java here too:
https://gist.github.com/aikar/ac868af870375dca458d84ff2a32007c

Expected behavior
No errors

OS Type & Version: Linux Mint 19
Java/JDK version: 1.8.0_191
IntelliJ IDEA version: 2019.1
Maven Compiler Plugin 3.7.0
Manifold version: RELEASE
Manifold IntelliJ plugin version: .55 alpha

-Xplugin:Manifold strings

Relevant context: Lombok is also in use - but other Extensions work. Just specific classes giving trouble.

Make @This work on type parameters

Manifold version: 0.45-alpha
JDK version: 11.0.2

Example of requested feature:

package utilities.extensions.java.lang.Object;

import manifold.ext.api.Extension;
import manifold.ext.api.This;

import java.util.function.Function;

@Extension
public class MyObjectExt {

    public static <T extends Object, R> R let1(@This Object thiz, Function<T, R> mapper) {
        return mapper.apply((T) thiz);
    }

    // Cannot compile, Type of thiz must be Object. **Please make this work**
    public static <T extends Object, R> R let2(@This T thiz, Function<T, R> mapper) {
        return mapper.apply((T) thiz);
    }

    public static <T extends Object, R> R let3(T thiz, Function<T, R> mapper) {
        return mapper.apply((T) thiz);
    }
    
    public static void test() {
        String str = "abc";
        String x11 = str.let1((String it) -> it.trim());     // This is ok, but I have to specify type of 'it'
        Object x12 = str.let1(it -> it.trim());            // Error, type of 'it' is deduced as Object

        String x21 = str.let2(it -> it.trim());            // Ideal state, type of 'it' should be deduced as String, if method let2 works
        
        String x31 = let3(str, it -> it.trim());        // without extension method, it's type deduction is working
    }
}

When I call method let1 with argument of some type T, it's type info is lost in method body, so type parameter T of mapper cannot get its correct type.
In my eyes extension method is just syntax sugar, so if let3 is working, so should let1.

kotlinc support

Excellent project, just what I was looking for (or looking-to-avoid-writing-myself).
I am developing in Kotlin, JVM 8, linux/server. Gradle.
Manifold works find 'out of the box' using IntelliJ while editing kotlin files,
however builds do not find the manifold plugin
I tried using the kotlinc variant "-Xplugin=path-to-plugin" ... guessing at which .jar file that might be -- but no errors except 'class not found' during compile.

Any suggestions?

Java > 8 support

Describe the bug
When compiling with Java 10 or 11 (did not try 9, but assuming same issue), i receive the following error:
https://gist.github.com/aikar/14f04ec1633541149ee9aa60711c6ad0
Another dev on Windows received same issue

To Reproduce
Steps to reproduce the behavior:

  1. JAVA_HOME="/usr/lib/jvm/11" mvn clean install -X

Expected behavior
Works

openjdk 11.0.1 2018-10-16
OpenJDK Runtime Environment (build 11.0.1+13-Ubuntu-3ubuntu116.04ppa1)

  • Manifold version: 0.55-alpha

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.