OpenJDK

Java并发编程基础-锁-synchronized状态变换

China☆狼群 提交于 2019-11-28 14:15:11
synchoronized在Jdk1.6之前一直被称为重量锁,性能较差,很少被推荐使用。synchoronized在Jdk1.6中进行了大量优化,性能与JUC中的各种锁无差,也被逐渐的被大众所接受。 synchoronized将锁状态记录在了 对象头的MarkWord 中,包含4种锁状态:无锁、偏向锁、轻量锁和重量锁,锁状态只能升级不能降级,即 无锁-->偏向锁-->轻量锁-->重量锁,目的是提高获取锁和释放锁的效率,对象几种状态的获取和释放如下: 偏向锁 大多数情况下,锁不存在多线程竞争,而总是由同一线程获得,为了让线程获得锁的代价更低( 消除了同步 )而引入了偏向锁。当对象第一次被线程获取的时候,会把MarkWord中的偏向标识位设为01(偏向锁状态),同时使用CAS操作将该线程的ID记录在MarkWord中,如果CAS操作成功,则该线程每次进入到这个锁相关的同步块时,虚拟机都可以不进行任何同步操作。 当有另外的线程获取这个锁时,偏向模式就结束了,根据锁对象目前是否处于锁定的状态,会恢复到无锁状态(01)或者变为轻量锁状态(00),借用《Java并发编程艺术》的一张图,如下所示: 轻量锁 线程在执行同步块之前,JVM会先在当前线程栈帧中创建用于存储锁记录的空间,并将对象头中的MarkWord复制到锁记录中,官方称为 Displaced Mark Word

已经打印为文档的类

半城伤御伤魂 提交于 2019-11-28 12:05:19
1、 /openjdk/jdk/路径下的类 /openjdk/jdk/src/solaris/bin/java_md_solinux.c /openjdk/jdk/src/share/bin/java.c    2、src/cpu/x86/vm/ 路径下的文件: interp_masm_x86.hpp interp_masm_x86.cpp interp_masm_x86_64.hpp interp_masm_x86_64.cpp assembler_x86.hpp assembler_x86.cpp register_x86.hpp register_x86.cpp register_definitions_x86.cpp macroAssembler_x86.hpp stubGenerator_x84_64.cpp    3、 sr c/ share / vm / 路径下的文件: ( 1 ) asm assember.hpp assember.cpp register.hpp register.cpp ( 2 ) classfile vmSymbols.hpp vmSymbols.cpp classFileParser.hpp classFileParser.cpp classLoader.hpp classLoader.cpp classLoaderData.hpp

Java error: “Comparison method violates its general contract!”

只愿长相守 提交于 2019-11-28 12:03:51
I have this code: package org.optimization.geneticAlgorithm; import org.optimization.geneticAlgorithm.selection.Pair; public abstract class Chromosome implements Comparable<Chromosome> { public abstract double fitness(); public abstract Pair<Chromosome> crossover(Chromosome parent); public abstract void mutation(); public int compareTo(Chromosome o) { int rv = 0; if (this.fitness() > o.fitness()) { rv = -1; } else if (this.fitness() < o.fitness()) { rv = 1; } return rv; } } And every time I run this code I get this error: Exception in thread "main" java.lang.IllegalArgumentException:

Where can I find the JDK 8/JavaFX 8 source code? [closed]

▼魔方 西西 提交于 2019-11-28 11:54:31
I would like to override the Implementation of FXMLLoader and recompile the JDK 8. Where can I find the source code of the JDK8 / JavaFX 8 ? The source for JavaFX 8 is available at: http://hg.openjdk.java.net/openjfx/8/master/rt JavaFX 8 is almost completely open source today. Instructions for building JavaFX 8 with OpenJDK 8 stolsvik Quoting from this answer : For Java 8, the source of the public parts of JavaFX are actually laying right along in the JDK installation as a sibling of src.zip : javafx-src.zip - on the root of your normal JDK Java 8 installation. Eclipse doesn't by default link

linux openjkd maven

半世苍凉 提交于 2019-11-28 11:42:16
####ubuntu openjdk Ubuntu 14.04上 安装 OpenJDK8 Ubuntu16.04 安装openjdk-7-jdk ubuntu16.04搭建jdk1.8运行环境 ####maven java heap maven编译出现Java heap 来源: oschina 链接: https://my.oschina.net/u/1585200/blog/3071313

How to compile mavenized OSGi 4.3 bundle with OpenJDK 7?

纵然是瞬间 提交于 2019-11-28 11:18:12
i am trying to compile my OSGi bundle against OSGi specification 4.3 using OpenJDK7 but i am getting error: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5:compile (default-compile) on project example: Compilation failure [ERROR] /tmp/baka/example/src/main/java/org/example/Activator.java:[14,24] error: type ServiceReference does not take parameters here is my Activator.java: package org.example; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; public class Activator implements

Is the cacerts file missing in ubuntu 15.10 and openjdk-8-jdk?

岁酱吖の 提交于 2019-11-28 10:51:36
I just installed Ubuntu 15.10 and their openjdk-8-jdk (by apt-get). Now I am missing the cacerts file. There is a link at the usual location: ls -l /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/cacerts lrwxrwxrwx 1 root root 27 Oct 22 01:47 /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/cacerts -> /etc/ssl/certs/java/cacerts but nothing at /etc/ssl/certs/java/cacerts: stat /etc/ssl/certs/java/cacerts stat: cannot stat ‘/etc/ssl/certs/java/cacerts’: No such file or directory This is due to a bug already reported here: Ubuntu bug ticket The ticket above links another similar issue ,

oracle jdk和openjdk区别;idea如何调试jdk代码

為{幸葍}努か 提交于 2019-11-28 09:37:38
两个jdk的区别 oracle jdk是sun/oracle(甲骨文)公司的,部分jdk开源;相对比较稳定,使用的比较多。 openjdk是完全开源的,据说是官方oracle唯一承认的开源版本。 idea如何调试jdk代码 首先oracle默认的源码包是不全的 这是当前项目的CLASS_PATH和对应的源码路径(除了前两个zip包是自带的,其他都是我添加的) (jdk1.8源码下载路径)[ http://hg.openjdk.java.net/jdk8u ],我选用下面这个,这里不仅有jdk代码,还有hotspot等源码 选择brower可以查看目录结构,选择zip下载zip压缩后的源码包,然后在idea的sourcepath里添加这个zip包,这样jdk的源码就基本比较全了。 (openjdk github源码)[ https://github.com/openjdk/jdk ],其实openjdk是使用mercurial管理的,对应的命令是:hg相关 来源: https://www.cnblogs.com/shengulong/p/11403448.html

Properly set up Java 9 as SDK in Intellij IDEA on Linux due to new folder structure

情到浓时终转凉″ 提交于 2019-11-28 08:55:49
Before you write me off, please consider that neither of these are answers to my question: How to setup SDK in IntelliJ IDEA? How do I change the IntelliJ IDEA default JDK? In IntelliJ IDEA 2017.2.6, attempting to add JDK9 as an SDK passes but does not work as the classpaths end up empty. Steps to reproduce: Open 'Add new SDK dialog' (go to Project Settings > Project > Project SDK > New > JDK) Select JDK 9 Passes, but if you look under SDK > JDK9 classpaths are empty and your code errors out due to base classes not being found. See image: In IntelliJ IDEA 2017.3 EAP you get an error about JDK

Where is the src.zip for JDK8u40?

你离开我真会死。 提交于 2019-11-28 08:17:35
I installed the JDK8u40, but only find the javafx-src.zip. Where can I find the source code for JDK? The src.zip? Below is what I get after installation: And btw, I didn't see the installation wizard! This is quite strange. ADD 1 Today I tried several Java installation packages. All are downloaded from Oracle official site. jdk-6u45-windows-i586.exe jdk-7u75-windows-i586.exe jdk-8u20-windows-i586.exe jdk-8u25-windows-i586.exe jdk-8u31-windows-i586.exe jdk-8u40-windows-i586.exe Both 6u45 and 7u75 installed well on my box. I can see the install wizard. And the src.zip is installed. But 8u25 ~