Mar 102015
 

I use one central email address: stephen@gmail.com (email anonymized). I want to add my work address stephen@fake.company.com to my primary address so I can control it from there.

Receiving

option1: gmail's pop3 importer

Gmail cannot use IMAP to download messages (or I haven't found out how) from other mail servers. It can use POP3:

 

option2: forwarding

What i prefer is to make the mail server at fake.company.com to forward all the messages to stephen@gmail.com. This depends from server to server.

Sending

If you want to pose as stephen@fake.company.com from stephen@gmail.com, you have to use fake.company's email servers, here's how it's done:

On stephen@gmail.com's settings, do:

Gmail -> settings -> accounts -> Add another email address you own

Screen Shot 2015-03-10 at 5.56.12 PM

Then add the info of stephen@fake.company.com:

NOTE: Uncheck "Treat as an alias"

Then add the server info:

Then an email with a code will be sent to stephen@fake.company.com

Give the code to gmail:

Now we're ready, compose a new email and put a different FROM address:

Now when you receive an email to stephen@gmail.com designated for stephen@fake.company.com and you click reply, gmail will automatically put stephen@fake.company.com as the FROM address.

NOTE: People on the other side will never know you use stephen@gmail.com.

pixelstats trackingpixel
Feb 252015
 

Screen Shot 2015-02-25 at 8.32.03 PM

Today (2015.02.25) we had a bgjug sponsored "intro to nashorn" event.

IMG_3956

Mitya, presented nashorn and avatar.js. Gave a lot of examples and had a hands-on - a node.js server working with hibernate.

pixelstats trackingpixel
Feb 172015
 

Today, 17.02.2015, the Bulgarian Java User Group (BGJUG) organized another hackaton. This time we wanted to fix warnings inside the jdk.

Screen Shot 2015-02-17 at 8.33.57 PM

First we did

make clean JAVAC_WARNINGS="-Xlint:all,deprecation,rawtypes,\
unchecked,cast,serial,dep-ann,static,fallthrough,try,varargs,\
empty,finally -Xmaxwarns 10000" DISABLE_WARNINGS="-Xlint:all"\
 LOG=info images

to generate a build.log to find out all the warnings. Then with any text editor one could open jdk9/build/linux-x86_64-normal-server-release/build.log and use these searches (using regular expressions) to find all the warnings:

openjdk/jdk9/corba(.)* warning
openjdk/jdk9/jaxp(.)* warning
openjdk/jdk9/jaxws(.)* warning
openjdk/jdk9/nashorn(.)* warning
(Substitute with your username)
The result was:
359 corba
100 jaxp
500 jaxws
0 nashorn
Initially Mitya proposed nashorn, but all of them were already fixed. Then Ivan and Nayden settled on jaxp. Because we all dislike corba.
Joe Darcy has a blog post on different warning types and how to fix them. We split the warnings into different types:
rawtypes 43
unchecked 14
serial 32
cast 10
dep-ann 1

Note: Dep-ann is to add the @Deprecated annotation.

We fixed the last three types and created a patch: http://bgjug.sty.bz/bgjug/~bgjug/fix-warnings-jaxp-part1/webrev.00/, because the unchecked and the rawtypes are a bit tricky as they involve changing public APIs.

We then tried to solve as much of the latter as possible and then created a second patch: http://bgjug.sty.bz/bgjug/~bgjug/fix-warnings-jaxp-full/webrev.00/

 

pixelstats trackingpixel
Feb 052015
 

barbadan.hit.bg беше сайт с няколко книги за мотоциклетна езда преведени на български. Когато стана ясно, че ще затварят hit.bg и безплатно хостнатнатите там страници, реших да спася цялото творчество и копирах сайта, за да се запази като знание.

Теми:
>Ефективни приоми на уличната езда.
>Кейт Код.
>Снимки.
>Спирачни_накладки_и_дискове_за_мотоциклети.
>ПТП.
>Техника на спортната езда.

Адрес: http://mihail.stoynov.com/barbadan.hit.bg/

Не знам какви са правата на съответните книги/статии. Ако все пак нарушавам нечии, моля да пише.

pixelstats trackingpixel
Jan 292015
 

So we in the Bulgarian Java User Group wanted to build Valhalla, and no IDE (Eclipse, Intellij Idea) supports it. We needed some simple text editor with some java support. And Sublime Text 3 (with Javatar) is the one we chose.

Sublime is a fancy editor written in C and Python. Javatar is a plugin that adds some Java support.

Installing Sublime Text 3 beta is straight forward. Installing Javatar is:

[openjdk@localhost valhalla]$ cd ~/.config/sublime-text-3/Packages/
[openjdk@localhost Packages]$ git clone git://github.com/spywhere/Javatar.git

Setting up the correct java is: Ctrl+Shift+P --> "javatar" --> Javatar Settings - Default

Then change the javac and java locations:

Creating projects is a bit uneasy - create new project is actually called "Project -> Save as".

And then we can run some code (fist compile, then run):

pixelstats trackingpixel
Jan 292015
 

Today we had a second bgjug hackaton for the month. Its topic was Valhalla.

Project Valhalla will probably be part of Java 10 (expected 2018). Among other things it allows using primitives as generic arguments.

Here's how you can build Valhalla yourself.

Here's a virtual machine with valhalla if you're lazy (virtual box).

This is the valhalla presentation by Ivan. And this is the video of the talk (in Bulgarian).

IMG_3676

Here are some of the code we ran:

Ivan created a simple ArrayList

public class SpecialArrayList<any T> {
	private static int INITIAL_SIZE = 10;
 
	private T[] elements = null;
	private int length = 0;
 
	public SpecialArrayList() {
		elements = new T[INITIAL_SIZE];
	}
 
	public T get(int position) {
		if(position >= length) {
			throw new ArrayIndexOutOfBoundsException();
		}
 
		return elements[position];
	}
 
	public void add(T element) {
		// Check whether array is full
		elements[length] = element;
		length++;
	}
}
public class Main {
	public static void main(String[] args) {
		SpecialArrayList<int> intList = new SpecialArrayList<>();
		intList.add(1);intList.add(2);intList.add(3);intList.add(4);
		System.out.println(intList.get(2));
 
		SpecialArrayList<String> stringList = new SpecialArrayList<>();
		stringList.add("1");stringList.add("2");stringList.add("3");stringList.add("4");
		System.out.println(stringList.get(3));
	}
}

Nayden tested a bit of crazy code - which is supposed to fail (IA impl = new IAImpl();):

public class B <any T> {
   protected T t;
   protected T[] ts;
   public B(){}
 
   public B(T t){
     this.t = t;
     this.ts = new T[100];
   //  System.out.println(this.t.getClass());
   }
 
   public T[] getTs(){
     return this.ts;
   }
 
   public T getT(){
     return this.t;
   }
 
   public static void main(String[] args){
       B<int> b = new B<>(100);
       System.out.println(b.getT());
 
       System.out.println(b.getClass());
       System.out.println((new B<String>("dada")).getClass());
       System.out.println(c.getClass());
 
       IAImpl<int> ludnica = new IAImpl<int>();
       ludnica.setT(100);
       System.out.println(ludnica.getT() instanceof Object);
 
       IABase<String> base = new IAChild<int>();
       base.setT("dada");
       System.out.println(base.getT());
       System.out.println(base.getClass());
 
       IA<String> impl = new IAImpl<int>();
 
       impl.setT("dada");
       System.out.println(impl.getT());
       System.out.println(impl.getClass());
   }
}
 
 
interface IA<T>{
 public T getT();
 public void setT(T t);
}
 
 
class IABase<T>{
 private T t;
 public T getT(){
   return this.t;
 }
 public void setT(T t){
   this.t = t;
 }
}
 
class IAChild<any T> extends IABase {
 
}
 
class IAImpl<any T> implements IA {
 private Object t;
 public Object getT(){
   return this.t;
 }
 public void setT(Object t){
   this.t = t;
 }
}
pixelstats trackingpixel
Jan 292015
 

This is a tiny tutorial on how to build your own copy of OpenJDK 9 from the current sources.

Contents

Preparation
├─Install a package system
├─Install ccache
└─Command Line Tools
Download OpenJDK 9
Build OpenJDK 9
JTREG
├─JTREG: The variables
└─Running tests
webrev

Preparation

Install a package system

Install brew or macports. I prefer brew. Both are package systems for OS X.

Install ccache

ccache is a compiler cache - speeds up the build.

$ brew install ccache

Command Line Tools

We need them so we have a C compiler and other tools.

Install Xcode Command Line tools ( you don't need the whole Xcode, only the command line tools)

Download OpenJDK 9

Get the sources, in the console type:

$ mkdir jkd9
$ cd jdk9
$ hg clone http://hg.openjdk.java.net/jdk9/dev jdk9.hg

Takes 10-20 secs. This downloads basically a couple of scripts that we will execute to get the actual sources.

Now we execute the script we downloaded:

$ cd jdk9.hg
$ chmod u+x get_source.sh
$ ./get_source.sh

The last command can can take 10-20 minutes depending on the connection speed.

Build OpenJDK 9

$ chmod u+x configure
$ ./configure
$ make clean images

The second command took a bit less than 20 minutes. The first command is fast.

The result: we have this created:  build/macosx-x86_64-normal-server-release/images/jdk/ - this is the built OpenJDK 9 - SUCCESS.

JTREG

jtreg is a "testing harness" (whatever that means) made specially for OpenJDK. We need it to run the tests written for the OpenJDK

Download from https://adopt-openjdk.ci.cloudbees.com/view/OpenJDK/job/jtreg/ (not the Snapshot version, the other one).

unzip in jdk9, so we have jdk9/jtreg.

JTREG: The variables

The official instructions suggest we edit ~/.bashrc. I don't like changing global (for your user) settings, so we can put these settings in jdk9/.bashrc

$ nano .bashrc

Add the following lines:

export SOURCE_CODE=/Users/steve/jdk9/
export JTREG_INSTALL=$SOURCE_CODE/jtreg/
export JT_HOME=$JTREG_INSTALL
export JTREG_HOME=$JTREG_INSTALL
export JPRT_JTREG_HOME=${JT_HOME}
export JPRT_JAVA_HOME=${PRODUCT_HOME}
export JTREG_TIMEOUT_FACTOR=5
export PRODUCT_HOME=$SOURCE_CODE/jdk9.hg/build/macosx-x86_64-normal-server-release/images/jdk
export PATH=$PATH:$PRODUCT_HOME/bin:$JT_HOME/linux/bin/

NOTE: Change /Users/steve/jdk9/ with your folder on the top line.
NOTE: Check the correctness of PRODUCT_HOME too.

To execute this file, do:

$ source .bashrc

Running tests

$ cd jdk9.hg/test
$ make jdk_util

Webrev

Webrev crawls over your changes to generate a set of web-based views of the differences in your code. The different views allow reviewers to easily look at your proposed changes, selecting the appropriate difference format based on the type of file, the type of change, and their own preferences.

webrev.ksh is a 70kb kshell script. Pretty weird.

Go to jdk9.hg and:

jdk9.hg# wget http://hg.openjdk.java.net/code-tools/webrev/raw-file/tip/webrev.ksh
jdk9.hg# chmod u+x webrev.ksh

To prepare a webrev, make some changes. For example in the jaxp folder. Then we commit locally in the mercurial repo.

jdk9.hg# cd jaxp
jaxp# hg commit -m "BGJUG: Fix compiler warnings in jaxp repository"
jaxp# ../webrev.ksh

It will prepare a webrev/ dir and webrev.zip. The folder is then uploaded somewhere and sent to the appropriate mail list inside openjdk. Example:
http://bgjug.sty.bz/bgjug/~bgjug/fix-warnings-jaxp-part1/webrev.00/

Note: execution times come are measured on a pretty recent Macbook Air.

Source: https://java.net/projects/adoptopenjdk/pages/AdoptOpenJDKBuildInstructions

pixelstats trackingpixel
Jan 292015
 

Project Valhalla will probably be part of Java 10 (expected 2018). Among other things it allows using primitives as generic arguments.

Building Valhalla

On a linux/unix/osx box we start with:

hg clone http://hg.openjdk.java.net/valhalla/valhalla
cd valhalla
bash get_source.sh  #this one takes some time
bash configure
make clean images # this one takes some cpu

Box<int>

We can have a class like this:

public class Program  {
	public static void main(String[] args) {
		// this one still doesn't work, List not updated to List<any T>
//		List<int> l = new ArrayList<int>();
//		l.add(5);
//		System.out.println(l.get(0));
 
		Box<int> b = new Box<int>(6);
		System.out.println(b.get());
	}
}
 
class Box<any T> {
    private final T t;
    public Box(T t) { this.t = t; }
    public T get() { return t; }
}

javap

Running javap gives

$ javap -c Program.class gives:
[openjdk@localhost bin]$ ./javap -c Program.class 
Compiled from "Program.java"
public class Program {
  public Program();
    Code:
       0: aload_0
       1: invokespecial #1                  // Method java/lang/Object."<init>":()V
       4: return
 
  public static void main(java.lang.String[]);
    Code:
       0: new           #2                  // class "Box${0=I}"
       3: dup
       4: bipush        6
       6: invokespecial #3                  // Method "Box${0=I}"."<init>":(I)V
       9: astore_1
      10: getstatic     #4                  // Field java/lang/System.out:Ljava/io/PrintStream;
      13: aload_1
      14: invokevirtual #5                  // Method "Box${0=I}".get:()I
      17: invokevirtual #6                  // Method java/io/PrintStream.println:(I)V
      20: return
}

Running our pretty simple app gives:

[openjdk@localhost bin]$ ./java Program
Specializing Box${0=I}; searching for Box.class (not found)
Specializing Box${0=I}; searching for Box.class (found)
6
[openjdk@localhost bin]$

Notes: List is still not parameterized with because ... issues.

pixelstats trackingpixel