All Projects → amelentev → Java Oo

amelentev / Java Oo

Java Operator Overloading

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Java Oo

Intellij Makefile
Makefile support for IntelliJ-based IDEs
Stars: ✭ 164 (-27.43%)
Mutual labels:  intellij
J2c
Java to C++ translator
Stars: ✭ 189 (-16.37%)
Mutual labels:  eclipse-plugin
Dotfiles
🐧 Simple, fast, productivity-increaser dotfiles
Stars: ✭ 213 (-5.75%)
Mutual labels:  intellij
Autorefactor
Eclipse plugin to automatically refactor Java code bases
Stars: ✭ 168 (-25.66%)
Mutual labels:  eclipse-plugin
Deeplearning4j Examples
Deeplearning4j Examples (DL4J, DL4J Spark, DataVec)
Stars: ✭ 2,215 (+880.09%)
Mutual labels:  intellij
Intellij Csv Validator
CSV validator, highlighter and formatter plugin for JetBrains Intellij IDEA, PyCharm, WebStorm, ...
Stars: ✭ 198 (-12.39%)
Mutual labels:  intellij
Intellij Community
IntelliJ IDEA Community Edition & IntelliJ Platform
Stars: ✭ 13,072 (+5684.07%)
Mutual labels:  intellij
Intellij Key Promoter X
Modern IntelliJ plugin to learn shortcuts for buttons
Stars: ✭ 2,689 (+1089.82%)
Mutual labels:  intellij
Intellij Haxe
Haxe plugin for IntelliJ Platform based IDEs (IDEA, Android-Studio)
Stars: ✭ 188 (-16.81%)
Mutual labels:  intellij
Intellij Hcl
HCL language support for IntelliJ platform based IDEs
Stars: ✭ 207 (-8.41%)
Mutual labels:  intellij
Deeplearning4j
Suite of tools for deploying and training deep learning models using the JVM. Highlights include model import for keras, tensorflow, and onnx/pytorch, a modular and tiny c++ library for running math code and a java based math library on top of the core c++ library. Also includes samediff: a pytorch/tensorflow like library for running deep learni…
Stars: ✭ 12,277 (+5332.3%)
Mutual labels:  intellij
Wolfram Language Intellij Plugin Archive
Wolfram Language and Mathematica plugin for IntelliJ IDEA.
Stars: ✭ 177 (-21.68%)
Mutual labels:  intellij
Intellij Emberjs
Ember.js support for JetBrains IDEs (IntelliJ, WebStorm, ...)
Stars: ✭ 202 (-10.62%)
Mutual labels:  intellij
Eclipse Instasearch
Eclipse plug-in for fast code search
Stars: ✭ 165 (-26.99%)
Mutual labels:  eclipse-plugin
Idea Php Annotation Plugin
Add PHP annotation support for PhpStorm and IntelliJ
Stars: ✭ 216 (-4.42%)
Mutual labels:  intellij
Eclipse Wakatime
Eclipse plugin for automatic time tracking and metrics generated from your programming activity.
Stars: ✭ 161 (-28.76%)
Mutual labels:  eclipse-plugin
Amateras Modeler
UML and ER-diagram editor for Eclipse
Stars: ✭ 190 (-15.93%)
Mutual labels:  eclipse-plugin
Intellij Sdk Code Samples
Mirror of the IntelliJ SDK Docs Code Samples
Stars: ✭ 217 (-3.98%)
Mutual labels:  intellij
Hyperium
Hyperium, Free Minecraft client with HUDs and Popular mods
Stars: ✭ 217 (-3.98%)
Mutual labels:  intellij
Idea Live Templates
My IntelliJ Live Templates
Stars: ✭ 207 (-8.41%)
Mutual labels:  intellij

Java Operator Overloading

Java-OO is a modular extension (plugin) to Java compilers and IDEs for (Scala-like) Operator Overloading support. Works with standard JavaC compiler, Netbeans IDE, Eclipse IDE, IntelliJ IDEA IDE and any build tools.

Example (see other examples at examples/ dir):

import java.math.*;
import java.util.*;
public class Test {
  public static void main(String[] args) {
    BigInteger a = BigInteger.valueOf(1), // without OO
               b = 2, // with OO

    c1 = a.negate().add(b.multiply(b)).add(b.divide(a)), // without OO
    c2 = -a + b*b + b/a; // with OO

    if (c1.compareTo(c2)<0 || c1.compareTo(c2)>0) // without OO
      System.out.println("impossible");
    if (c1<c2 || c1>c2) // with OO
      System.out.println("impossible");

    HashMap<String, String> map = new HashMap<>();
    if (!map.containsKey("qwe")) map.put("qwe", map.get("asd")); // without OO
    if (map["qwe"]==null) map["qwe"] = map["asd"]; // with OO
  }
}

Versions

JavaC/Netbeans: 0.5
JavaC8:         0.5
Eclipse:        0.5
IntelliJ IDEA:  0.7

Note plugin versions are independent. If version for X > version for Y then it doesn't mean Y is behind feature wise.

News

16 Nov 2019. IntelliJ IDEA plugin v0.7 released with support of IDEA 2019.2+.

20 May 2017. IntelliJ IDEA plugin v0.6 released with support of IDEA 2017.

14 July 2016. As a workaround Eclipse plugin works fine on Eclipse 4.4+ if you install Scala IDE plugin first.

2 Feb 2016. IntelliJ IDEA plugin v0.5 released with support of IDEA 15. Requires Java8 to run the plugin.

10 April 2015. IntelliJ IDEA plugin v0.4.1 released with support of IDEA 14.1.

27 January 2015. Eclipse-oo-plugin version 0.5 released with support of reverse binary operator overload.

2 December 2014. New feature: Reverse binary operator overload via operatorRev methods.
Plugin versions updated:
JavaC7 & JavaC8: 0.5
IntelliJ IDEA: 0.4. Support of IDEA 14

31 May 2014. Javac8 plugin version 0.1.1 released. Removed runtime depencendy on nbjavac.

24 May 2014. IntelliJ IDEA plugin v0.3.1 released. Bugfixes for IDEA 13 Ultimate and for type resolution for binary expressions with primitives.

30 April 2014. IJPLA published a paper about Java-OO.

3 Feb 2014. New JavaC8 plugin version 0.1 for JDK8 was released. It has the same features as JavaC plugin for JDK7 but doesn't work in Netbeans yet.

12 Jan 2014. JavaC plugin version 0.4 and Eclipse plugin version 0.4 released. Now operator overloading perform autoboxing/autounboxing primitive to/from wrapper types where appropriate. Fixed javac plugin bug with index-set OO.

3 Jan 2014. JavaC plugin version 0.3 released. Fixed #10 javac: binary operator adds erroneous cast on 1st operand.

8 Sep 2013. Eclipse plugin version 0.3 released. Removed copypasta from Eclipse Compiler. Plugin should be more steady agains compiler changes.

14 May 2013. IntelliJ IDEA IDE plugin v0.2.1 with IDEA Ultimate Edition support.

17 Apr 2013. IntelliJ IDEA IDE plugin v0.2.

26 Nov 2012. Version 0.2 released. New feature: Assignment operator overloading via static #valueOf method.

Installation

javac, ant, etc

Just add to classpath: javac8-oo-plugin.jar for JDK8 or javac-oo-plugin.jar for JDK7.

javac -cp javac8-oo-plugin.jar <sources>

Demo at examples/compile.sh

Eclipse IDE update site

Click in menu: Help - Install New Software. Enter in Work with field:

http://amelentev.github.io/eclipse.jdt-oo-site/

Tested on Eclipse Standard 4.3.2. Should work with older versions too.
To work on 4.4+ you need to install Scala IDE plugin (or similar plugin with Equanox weaving). You can find it in Help -> Eclipse Marketplace. This is workaround until normal solution will be found. Tested on 4.4 and 4.6.

Netbeans IDE

  1. Add javac-oo-plugin.jar as compile or processor library to Netbeans.
  2. Enable "Annotation Processing in Editor": Project Properties -> Build -> Compiling.

Tested on 7.2.1

IntelliJ IDEA IDE

  1. Install Java Operator Overloading support plugin: File -> Settings -> Plugins -> Browse repositories. Mirror: idea-oo-plugin.jar)
    For Maven projects installation is done. IDEA should setup everything according to pom.xml.
    For other project types:
  2. Add javac8-oo-plugin.jar as compile or processor library.
  3. Enable Annotation Processing: Menu File -> Settings -> Compiler -> Annotation Processing -> Enable annotation processing
  4. Make sure you use javac compiler in Settings -> Java Compiler -> Use compiler.
    Tested on IDEA 2019.2.4 Ultimate & Community editions. You can use earlier plugin versions for older IDEA releases.

Android project in IDEA 12

Add javac-oo-plugin.jar to File - Settings - Compiler - Annotation Processors - Processor path

Android Studio (IDEA 13) / Gradle

add to build.gradle:

repositories {
	maven { url 'http://amelentev.github.io/mvnrepo/' }
}
dependencies {
	compile 'java-oo:javac-oo-plugin:0.5'
}

Maven

Look at javac-oo-mvndemo/pom.xml

Details

Read the paper to learn more. Supported operators (operator to method name map):

binary:

| OPERATOR | METHOD NAME|
-------------------------
| +        | add        |
| -        | subtract   |
| *        | multiply   |
| /        | divide     |
| %        | remainder  |
| &        | and        |
| |        | or         |
| ^        | xor        |
| <<       | shiftLeft  |
| >>       | shiftRight |

If left operand has no such method then the plugin will try to use 'reverse' method <methodName>Rev on right operand. So 2*a will be transformed to a.multiplyRev(2) if a has such method.

unary:

| -        | negate     |
| ~        | not        |

comparison:

| <, <=, >, >= | compareTo	| example: `a < b` <=> `a.compareTo(b)<0`
`==` and `!=` are not overloadable because it will break things

index:

| []  | get       | `v = lst[i]` <=> `v = lst.get(i)`
| []= | set, put  | `map[s] = v` <=> `map.put(s,v)`,  `lst[i] = v` <=> `lst.set(i,v)`

assignment:

| var = expr | var = VarClass.valueOf(expr) |

if expr is not assignable to var and var is an instance of VarClass and expr has type ExprType and there are static method VarClass#valueOf(ExprType)
then var = expr is transformed to var = VarClass.valueOf(expr). example:
BigInteger a = 1 is transformed to BigInteger a = BigInteger.valueOf(1)

These methods exists in many java classes (example: BigInteger, BigDecimal) so you can use operators on them "out of the box". Or you can add these methods to your classes to use OO (see examples/Vector.java).

Subprojects / Implementation details

Publications

"Java Modular Extension for Operator Overloading", IJPLA, April 2014.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].