See also: Heapify

Pages: 1

Build hsdis for JDK 1.11 on Ubuntu 18.04.2 LTS

The following instructions are valid for a default installation of Ubuntu 18.04.2 LTS preinstalled with gcc make perl

For JDK 12 the same works except I've only confirmed it with binutils-2.29 and binutils-2.32

...

Read more

There are no comments on this post.

Build hsdis for JDK 1.8 on Ubuntu

I wanted to build hsdis for my Ubuntu system. Virtually all of the instructions out there are slightly wrong. As per the comment on this gist a recent change (bbd1da3f538f) to the HotSpot source to be compatible with binutils 2.29 broke all the prior instructions. So literally.. my contribution here is to publicly point this out and offer copy and pasta instructions to solve it.

Gist: https://gist.github.com/kay/ec70aa7469d216ab88eb411d8dab187d

...

Read more

There are no comments on this post.

Testing code that calls System.exit in Java

It sometimes comes up in the course of unit testing where a unit of code calls System.exit(status). If you've a sane codebase this is normally within a main class. Consider an insane codebase:

Consider

public class DisgruntledPenguin {
    public static boolean happy() {
        System.exit(5);
    }
}

...

Read more

There are no comments on this post.

Detecting, locating and fixing referenced based heap memory leaks (Java)

A common problem we all have to deal with is fixing memory leaks. In garbage collecting languages like Java we typically expect not to ever need to worry about memory management. However the limitations of how a garbage collector works means that we can still create leaks. Which defeats the advantage of a garbage collector.

How do leaks get formed?

The Java GC determines which objects to collect by looking for references to the object. If there is no references, then the object is no longer in use and can be safely destroyed without making the application unstable. If an object is now unused but still referenced, a leak occurs. Let's create a leak:

...

Read more

There are no comments on this post.

Strong, Soft, Weak and Phantom References (Java)

There are four distinct forms of references in the JVM, and indeed many of these apply to other garbage collected languages.

  • Strong references
  • Soft references
  • Weak references
  • Phantom references

It's important to know the differences, what affect they have on the collector and when you should be using them.

...

Read more

There are 2 comments on this post.

A caffine induced sense of humour? I surely hope not

Super serial!

import java.io.PrintWriter;
import java.io.Serializable;    
class Doug implements Serializable {
  public Doug(PrintWriter out) {
    out.println(getMood());
  }
  private static String getMood() {
    return ":-(";
  }
}
/*
 * __        ___   ___   __  ____   ___
 * \ \      / / | | \ \ / / / ___| / _ \
 *  \ \ /\ / /| |_| |\ V /  \___ \| | | |
 *   \ V  V / |  _  | | |    ___) | |_| |
 *    \_/\_/  |_| |_| |_|   |____/ \___/
 *
 *  ____  _____ ____  ___    _    _    ___
 * / ___|| ____|  _ \|_ _|  / \  | |  |__ \
 * \___ \|  _| | |_) || |  / _ \ | |    / /
 *  ___) | |___|  _ < | | / ___ \| |___|_|
 * |____/|_____|_| \_\___/_/   \_\_____(_)
 */

...

Read more

There are no comments on this post.

A Java WHOIS protocol implementation

This should all be quite self explanatory. I can't remember why I went ahead and implemented this in Java. I think I was just rusty and wanted some practice. What follows is an implementation of the WHOIS protocol used to get information about a record name (in this case specifically domain name records). The nature of the information is contact information, ownership rights, etc.

The full source code and documentation can be downloaded here. This includes the source package and documentation. Depends only on Java core packages (java.io, java.net, and java.util).

Let's start with the whois server pool (WhoisServerPool.java). This is a static map of top level domain names to the whois server that is responsible for maintaining information on domains with that top level domain name.

...

Read more

There are 6 comments on this post.

Pages: 1

RSS
Powered by Debian, Guinness, and excessive quantities of caffeine and sugar.