From f0039cbf1d447cc381dac297190cd0c630bf3cb9 Mon Sep 17 00:00:00 2001 From: Christopher Frost Date: Tue, 6 Jan 2015 12:17:45 +0000 Subject: [PATCH] Auto detect Java major version The commit adds the ability to turn on Java version detection. This will scan the application to detect the major version of Java that should be used for the application and then refer to the config file for the exact version to use. [#71382852] --- .idea/dictionaries/cgfrost.xml | 7 ++ config/open_jdk_jre.yml | 13 ++- config/oracle_jre.yml | 13 ++- java-buildpack.iml | 6 +- lib/java_buildpack/jre/open_jdk_like.rb | 89 ++++++++++++++++- .../META-INF/MANIFEST.MF | 2 + .../test/ApplicationConfiguration.class | Bin 0 -> 2140 bytes .../test/ApplicationInitializer.class | Bin 0 -> 1759 bytes .../META-INF/MANIFEST.MF | 2 + .../test/ApplicationConfiguration.class | Bin 0 -> 2140 bytes .../test/ApplicationInitializer.class | Bin 0 -> 1759 bytes spec/java_buildpack/jre/open_jdk_jre_spec.rb | 91 ++++++++++++++++++ spec/java_buildpack/jre/oracle_jre_spec.rb | 91 ++++++++++++++++++ 13 files changed, 299 insertions(+), 15 deletions(-) create mode 100644 .idea/dictionaries/cgfrost.xml create mode 100644 spec/fixtures/jre_java6_application/META-INF/MANIFEST.MF create mode 100644 spec/fixtures/jre_java6_application/WEB-INF/classes/com/gopivotal/cloudfoundry/test/ApplicationConfiguration.class create mode 100644 spec/fixtures/jre_java6_application/WEB-INF/classes/com/gopivotal/cloudfoundry/test/ApplicationInitializer.class create mode 100644 spec/fixtures/jre_java7_application/META-INF/MANIFEST.MF create mode 100644 spec/fixtures/jre_java7_application/WEB-INF/classes/com/gopivotal/cloudfoundry/test/ApplicationConfiguration.class create mode 100644 spec/fixtures/jre_java7_application/WEB-INF/classes/com/gopivotal/cloudfoundry/test/ApplicationInitializer.class diff --git a/.idea/dictionaries/cgfrost.xml b/.idea/dictionaries/cgfrost.xml new file mode 100644 index 0000000000..bed05d0733 --- /dev/null +++ b/.idea/dictionaries/cgfrost.xml @@ -0,0 +1,7 @@ + + + + cafebabe + + + \ No newline at end of file diff --git a/config/open_jdk_jre.yml b/config/open_jdk_jre.yml index 2a4feb2af6..2044fd5fda 100644 --- a/config/open_jdk_jre.yml +++ b/config/open_jdk_jre.yml @@ -14,16 +14,21 @@ # limitations under the License. # Configuration for JRE repositories keyed by vendor -# To go back to Java 7, permgen should be used instead of metaspace. Please see the documentation for more detail. +# Pre Java 1.8, permgen was used instead of metaspace, the buildpack will consume the configuration as appropriate. +# Please see the documentation for more detail. --- repository_root: "{default.repository.root}/openjdk/{platform}/{architecture}" -version: 1.8.0_+ +version: + detect_compiled: enabled + 8: 1.8.0_+ + 7: 1.7.0_+ + 6: 1.6.0_+ memory_sizes: metaspace: 64m.. - # permgen: 64m.. + permgen: 64m.. memory_heuristics: heap: 75 metaspace: 10 - # permgen: 10 + permgen: 10 stack: 5 native: 10 diff --git a/config/oracle_jre.yml b/config/oracle_jre.yml index cdb6226dc2..6ffe8bf3b8 100644 --- a/config/oracle_jre.yml +++ b/config/oracle_jre.yml @@ -14,19 +14,24 @@ # limitations under the License. # Configuration for JRE repositories keyed by vendor -# Pre Java 1.8, permgen was used instead of metaspace. Please see the documentation for more detail. +# Pre Java 1.8, permgen was used instead of metaspace, the buildpack will consume the configuration as appropriate. +# Please see the documentation for more detail. --- # You must specify a the repository root of an Oracle JRE repository. Please see the documentation for more detail. # e.g. repository_root: "http://example.com/oracle-jre/{platform}/{architecture}" repository_root: "" -version: 1.8.0_+ +version: + detect_compiled: enabled + 8: 1.8.0_+ + 7: 1.7.0_+ + 6: 1.6.0_+ memory_sizes: metaspace: 64m.. -# permgen: 64m.. + permgen: 64m.. memory_heuristics: heap: 75 metaspace: 10 -# permgen: 10 + permgen: 10 stack: 5 native: 10 diff --git a/java-buildpack.iml b/java-buildpack.iml index a0bcb4d298..85fb2c22ac 100644 --- a/java-buildpack.iml +++ b/java-buildpack.iml @@ -271,7 +271,7 @@ - + @@ -281,13 +281,13 @@ - + - + diff --git a/lib/java_buildpack/jre/open_jdk_like.rb b/lib/java_buildpack/jre/open_jdk_like.rb index 4b665c02b6..6592151c92 100644 --- a/lib/java_buildpack/jre/open_jdk_like.rb +++ b/lib/java_buildpack/jre/open_jdk_like.rb @@ -15,6 +15,8 @@ # limitations under the License. require 'fileutils' +require 'zip' +require 'find' require 'java_buildpack/component/versioned_dependency_component' require 'java_buildpack/jre' require 'java_buildpack/jre/memory/openjdk_memory_heuristic_factory' @@ -39,8 +41,12 @@ def initialize(context) # (see JavaBuildpack::Component::BaseComponent#detect) def detect + version = required_java_version + version_specific_configuration = { KEY_REPOSITORY_ROOT => @configuration[KEY_REPOSITORY_ROOT], + KEY_VERSION => version } + @version, @uri = JavaBuildpack::Repository::ConfiguredItem.find_item(@component_name, - @configuration) + version_specific_configuration) @droplet.java_home.version = @version super end @@ -65,15 +71,90 @@ def release KEY_MEMORY_SIZES = 'memory_sizes'.freeze - private_constant :KEY_MEMORY_HEURISTICS, :KEY_MEMORY_SIZES + KEY_DETECT_COMPILED_VERSION = 'detect_compiled'.freeze + + KEY_JAVA_EIGHT_VERSION = 8.freeze + + KEY_JAVA_SEVEN_VERSION = 7.freeze + + KEY_JAVA_SIX_VERSION = 6.freeze + + KEY_REPOSITORY_ROOT = 'repository_root'.freeze + + KEY_VERSION = 'version'.freeze + + CAFEBABE = 'cafebabe'.freeze + + private_constant :KEY_MEMORY_HEURISTICS, :KEY_MEMORY_SIZES, :KEY_DETECT_COMPILED_VERSION, + :KEY_JAVA_SEVEN_VERSION, :KEY_JAVA_SIX_VERSION, :KEY_VERSION, :CAFEBABE def killjava @droplet.sandbox + 'bin/killjava.sh' end + def java_6?(version_code) + version_code == 32 + end + + def java_7?(version_code) + version_code == 33 + end + + def java_6_or_java_7?(version_code) + java_6?(version_code) || java_7?(version_code) + end + + def required_java_version + version_configuration = @configuration[KEY_VERSION] + detected_version = resolved_version_code version_configuration + + if java_6? detected_version + version = version_configuration[KEY_JAVA_SIX_VERSION] + elsif java_7? detected_version + version = version_configuration[KEY_JAVA_SEVEN_VERSION] + else + version = version_configuration[KEY_JAVA_EIGHT_VERSION] + end + version + end + + def resolved_version_code(configuration) + configuration[KEY_DETECT_COMPILED_VERSION] == 'enabled' ? detect_compiled_version(@application.root) : 34 + end + + # If no valid files are found with 'cafebabe' and an expected version code then + # the code '34' for Java 8 will be returned. + def detect_compiled_version(application_root) + result = 0 + Find.find(application_root.to_path) do |sub_entry| + result = check_file(sub_entry, result) if sub_entry.end_with? '.class' unless FileTest.directory?(sub_entry) + end + result == 0 ? 34 : result + end + + def check_file(entry, result) + bits = File.open(entry).read.unpack('H*')[0] + logger = JavaBuildpack::Logging::LoggerFactory.instance.get_logger OpenJDKLike + logger.debug "Scanning '#{entry}', first 8 bits are '#{bits[0, 8]}' and the version code is '#{bits[14, 2]}'." + result = [result, Integer(bits[14, 2])].max if bits[0, 8] == CAFEBABE + result + end + def memory - sizes = @configuration[KEY_MEMORY_SIZES] || {} - heuristics = @configuration[KEY_MEMORY_HEURISTICS] || {} + sizes = @configuration[KEY_MEMORY_SIZES] ? @configuration[KEY_MEMORY_SIZES].clone : {} + heuristics = @configuration[KEY_MEMORY_HEURISTICS] ? @configuration[KEY_MEMORY_HEURISTICS].clone : {} + + version_configuration = @configuration[KEY_VERSION] + detected_version = resolved_version_code version_configuration + + if java_6_or_java_7? detected_version + heuristics.delete 'metaspace' + sizes.delete 'metaspace' + else + heuristics.delete 'permgen' + sizes.delete 'permgen' + end + OpenJDKMemoryHeuristicFactory.create_memory_heuristic(sizes, heuristics, @version).resolve end diff --git a/spec/fixtures/jre_java6_application/META-INF/MANIFEST.MF b/spec/fixtures/jre_java6_application/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..58630c02ef --- /dev/null +++ b/spec/fixtures/jre_java6_application/META-INF/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/spec/fixtures/jre_java6_application/WEB-INF/classes/com/gopivotal/cloudfoundry/test/ApplicationConfiguration.class b/spec/fixtures/jre_java6_application/WEB-INF/classes/com/gopivotal/cloudfoundry/test/ApplicationConfiguration.class new file mode 100644 index 0000000000000000000000000000000000000000..70c48311b4fab8410115ab4626740126bb53414e GIT binary patch literal 2140 zcmb`I>uwV{7=~Y`he?NU-VNua95*RT4CPc>cA*C<5Gf#vxt(kxG1!rXQDQ3C$yD_l(ENSKYl-dukEkjK7Ro)ir-xvLDj*Civp@cxPjkn z?WTRy9B>zo{d~*CkS%Y!ID}CLcO2Yh7<{C(O8#Kzt5g>l`ln4G8IIPKmM_~)PeyNr z7gEcKy75K0AR=YoJB|IxdlfT`*L~CE4bxI9CJ`a`L(>ixOPtuo9|NO^j#RGtpvMD2{?Z*nQb zKhiY1VP?Ed?w#*()6Rj%=e7+Z%&ACto=S3bKIy>|%?~Y}jp`Pl4)z3rmc0Gwq{Ms z@FZ8_N9plcMk}FA?1GTCZaX~Hc7OaSy}1>CqJ*P3Mi$7+|3Urg;9d#$@t}k;JS<@x zwBV2T+IPN*B%c+_GT&DW5B5#iZY754yr6oSMfmS&v+nYYU7tq`V|$6{WhI7V)=WGU zy1`$0OSJVECi8^td$r%Lw#dANXQLEhZu$>Iq8vG~Ofu--l^+1iKTP&5YU}VDNY7JR zt{(e--$;tFTuD#uED!UEJ(wq+R~Imh!*n&--vIq-FM#1V)i{;RwvMcW{Y#YsPSA5O zZM=??R4-*6@DqNfH=vAD)XNTjL1lr;lN%_!TSs60#((Hv!@wE_|Dom#W$!*<1Vy?H zEv}pm>EMcV1D?hin&K>dv(uiV5;%_w)Xz>bN~Kj;+<-%q6t~Ek$Xi_^iyi8A)-SlY zn>9o%cPH!Ko~&V9>agyjKh@=K;LtnPw~o?I+ISbu%~4jsWs0kSD{1Uy^x-PKUnA=E LzrbSriVE;Qr^{ye literal 0 HcmV?d00001 diff --git a/spec/fixtures/jre_java6_application/WEB-INF/classes/com/gopivotal/cloudfoundry/test/ApplicationInitializer.class b/spec/fixtures/jre_java6_application/WEB-INF/classes/com/gopivotal/cloudfoundry/test/ApplicationInitializer.class new file mode 100644 index 0000000000000000000000000000000000000000..e9f0ceccd74463d715a5d6798fc412ef2e8b7094 GIT binary patch literal 1759 zcmb_d+fvj>82)-Dl3|E|cv#OXiZbH>Sv>2wx(FW7L8=_ZqP*(KG-GQ>Qk@<|U&W{J zMhYo?03XWQzmo{VR#x_6Z~E}(KYacDhkXC>@z~w z#vkT5UBV?Bm&+Kyl>uDEwE>*NbsINIxM_~JY}9Ssw(%!J-)$L4eTSh~sV*^Cvte5> z3^imRo_1GTLOtg#pCluV(Bu9RSJK=wp`~BTnBhjl3s>Dv7|FFzbKmv+u-jeJ0s1(9~S%Zp1KJX}sZUeBF(OTJwc=o9R9q23oA^ zy1_S?eamDFr+;n3P<|&`+uDnbP<7lmQZneQD84G*h3c(K8m^ZHapP_jg^Cad0lmcl zCgT;^c_~^wkH{R-0}ixh9C7Wv7Ak{l<1T|e_dejO(qnMugFvWRpU1Hvu4?&spNWo) zwMqhxWwzwKe1F{&kwFpL_>1n%u&X@rK$?`C=mFHj>XaeT!C@Ss%3@U!v!dqynJmN8 zoQ?Yq9^j#aN0?_A-T~RvrcxM~>)pzkv0;}R@boXx?yj{SH#Qm! z)!Zh@DAYK&J$q+2?w>tk+V*5Fj!c7+ z$lL9#dl;6|F_6Yj6Hw1@ntC-~p2r0>({LJ5!)jL@`ZI7FknKs&W0t-sN2Cb2dQ<%gZ zS`CzoX}Amu1;%OoPLN8tjx!h~SmQWK@GsCa#!26zZxxbO>0BV|^R$;qc8)xb_4WS^ DAhG|s literal 0 HcmV?d00001 diff --git a/spec/fixtures/jre_java7_application/META-INF/MANIFEST.MF b/spec/fixtures/jre_java7_application/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..58630c02ef --- /dev/null +++ b/spec/fixtures/jre_java7_application/META-INF/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/spec/fixtures/jre_java7_application/WEB-INF/classes/com/gopivotal/cloudfoundry/test/ApplicationConfiguration.class b/spec/fixtures/jre_java7_application/WEB-INF/classes/com/gopivotal/cloudfoundry/test/ApplicationConfiguration.class new file mode 100644 index 0000000000000000000000000000000000000000..41847273eee73f89473fbb7664bb95649dd480d1 GIT binary patch literal 2140 zcmb`Ie^V4U7{|Xke(bScm8w0kt-o7)hxI~1z=Bl~WOO{*jyQB2|H|%$Gq9H&yL$+) zp>L+`A2L&B`T~4WPM_@F-~oFAGv3T?vf1R5?~~`77x-d9>B4;cC?)m4W61rtbyb9JTVukEHM zqnE-9spWj#_##{tk+Scd#{T4uiWz3>zG?D?X{jxfh>-iCX$Nbjt%GQXCo)d>e5(~I zUnI)t1*6wgqaCF$a|~`E60u_1kx#RXR;u-Nu_d;7yczPv{V&wd@!Bd3WW=ykH&KJf ztw`y{S|pnCt%)}Hdf@rovf`A*C5aCL8Sp2ailuoXmX9+IAuqjX>qIr>s)`i_HLo?v zw;Cy?JGqniMkjJR;bOlle=LP2RymS^iYYiPeT!HUeqy2>hD8b~Pp_5A(?Oi5ol*Qn zE`|7Kn?^UxqPNeT{1i9s9C&>Bz#zhmM8fk_lB4rc51wdlws4F@rU%5xBR&h&S97=keC0{`qjZy3DcM<;U0c2 zVHULD50Be-zKJAX5*sq#R}3>JCLFX9!$MwAz04x~H?&!gc*d^JeTI9-iRfh|hGA_Wg;G6l1xPp4wR+RuX$K&poTI;u^l7tI7Tb=udkA3|~@>Q^{=W*e=-LR4L#* zJqOdqTev{=Qq}<%@fE!RWsFcSJNP-31u8G>q3~)Kef8V_p#L2P-eK@BYR*vh?gPe9 zq}$Nq%Gr<(u1GiFC@#?yU(+``?Ke~c-{La$vy)6vX%!at;Ls$+kK|0`c$dgxhkB58 z1y_%uoyp}0{joKAZGah literal 0 HcmV?d00001 diff --git a/spec/fixtures/jre_java7_application/WEB-INF/classes/com/gopivotal/cloudfoundry/test/ApplicationInitializer.class b/spec/fixtures/jre_java7_application/WEB-INF/classes/com/gopivotal/cloudfoundry/test/ApplicationInitializer.class new file mode 100644 index 0000000000000000000000000000000000000000..84967a6d3d5b923d39a9c531f82fccbb5342d60f GIT binary patch literal 1759 zcmb_d+fo!q82);9WR_(F#2Afd0+C%87>S9eRS`iFl0~ZA1dGa5?`*TS8D^$>dJ%mU zpTZj{r1SxND9gWRMp&#-yzr(E|NMuqzyC1rKfHMd;3}5OIF6c)$ubJ4nPtkxbQwpC z(6w>J9A`@S)yCB_2JqVee#f-|jN!VC8ztN{$6Ge)Hg4Ov!_aqI22$T;C|0Vg4Ay+u z77RlT8Hk77jh0aV@Rm=Kkw)lof0Zj~?wQciPh`w+qv3@cZYPZ7W~jOEdVbh#uZP{B zt)9DD#M+&UB42u3%P?4?aFYA-g-~^d{xE22u5>qI7_Bs(@=dkw)V$B*SP)mWe7uiD zN5)zu0mn02@?L(h<%!6kh;7`Xdo%1RPb^B4k~2MkdRUz{Bsw^OA1O13CB_StaQBRp z@c(M*#}4L<{qlFEi|Wc?bA29k+=P*DK-lxhG!xyFB?tF0PmJvI&oJ{PxSuL&;qzn} zo)&C8aIlC!9Q=tThT(mXO>HWLfw>O;!ru(n4kNS&?jEf|9dNqRdMZ5q6|@Iyt;dax z217NsN%9Jax+7P2uc)Zs*SYi=N-C*81N21YzobNavXpe*t;(Uja}f8Z9x-iuHWx>x zK}qE8cGf)%tLYd>RX<)-ojoh9!IJ9 z8vV7A@-7C}Cb!}2;AjyKr>q?e(yxQGhSrKB!_6HWE8y{d_|xbkcNLUSCCoKUU=q`q z!d+Sol*?(j3@Fo FKLRI-|GEGG literal 0 HcmV?d00001 diff --git a/spec/java_buildpack/jre/open_jdk_jre_spec.rb b/spec/java_buildpack/jre/open_jdk_jre_spec.rb index 62208cbefc..f15f2048da 100644 --- a/spec/java_buildpack/jre/open_jdk_jre_spec.rb +++ b/spec/java_buildpack/jre/open_jdk_jre_spec.rb @@ -27,6 +27,20 @@ let(:memory_heuristic) { double('MemoryHeuristic', resolve: %w(opt-1 opt-2)) } + let(:configuration) do + { 'version' => { 'detect_compile' => 'disabled', + 8 => '1.8.0_+', + 7 => '1.7.0_+', + 6 => '1.6.0_+' }, + 'memory_sizes' => { 'metaspace' => '64m..', + 'permgen' => '64m..' }, + 'memory_heuristics' => { 'heap' => '75', + 'metaspace' => '10', + 'permgen' => '10', + 'stack' => '5', + 'native' => '10' } } + end + before do allow(JavaBuildpack::Jre::WeightBalancingMemoryHeuristic).to receive(:new).and_return(memory_heuristic) end @@ -81,4 +95,81 @@ expect(java_opts).to include('-Djava.io.tmpdir=$TMPDIR') end + context do + + let(:configuration) { super().merge 'version' => { 'detect_compile' => 'enabled' } } + + context do + + before do + allow_any_instance_of(described_class).to receive(:java_6?).and_return(true) + end + + it 'detects with id of openjdk_jre- for a java 6 app', + cache_fixture: 'stub-java.tar.gz', + app_fixture: 'jre_java6_application' do + + expect(component.detect).to eq("open-jdk-jre=#{version}") + end + + it 'adds memory options to java_opts for a java 6 app', + cache_fixture: 'stub-java.tar.gz', + app_fixture: 'jre_java6_application' do + + component.detect + component.release + + expect(java_opts).to include('opt-1') + expect(java_opts).to include('opt-2') + end + + end + + context do + + before do + allow_any_instance_of(described_class).to receive(:java_7?).and_return(true) + end + + it 'detects with id of openjdk_jre- for a java 7 app', + cache_fixture: 'stub-java.tar.gz', + app_fixture: 'jre_java7_application' do + + expect(component.detect).to eq("open-jdk-jre=#{version}") + end + + end + + context do + + let(:component) { StubOpenJdkJRE.new context } + + before do + allow_any_instance_of(StubOpenJdkJRE).to receive(:supports?).and_return(true) + end + + it 'detects the correct version for a java 7 app', + cache_fixture: 'stub-java.tar.gz', + app_fixture: 'jre_java7_application' do + + expect(component.detect_compiled_version Pathname.new('spec/fixtures/jre_java7_application')).to eq(33) + end + + it 'detects the correct version for a java 6 app', + cache_fixture: 'stub-java.tar.gz', + app_fixture: 'jre_java6_application' do + + expect(component.detect_compiled_version Pathname.new('spec/fixtures/jre_java6_application')).to eq(32) + end + + class StubOpenJdkJRE < JavaBuildpack::Jre::OpenJdkJRE + + public :detect_compiled_version + + end + + end + + end + end diff --git a/spec/java_buildpack/jre/oracle_jre_spec.rb b/spec/java_buildpack/jre/oracle_jre_spec.rb index efec872043..534d8b8d9f 100644 --- a/spec/java_buildpack/jre/oracle_jre_spec.rb +++ b/spec/java_buildpack/jre/oracle_jre_spec.rb @@ -27,6 +27,20 @@ let(:memory_heuristic) { double('MemoryHeuristic', resolve: %w(opt-1 opt-2)) } + let(:configuration) do + { 'version' => { 'detect_compile' => 'disabled', + 8 => '1.8.0_+', + 7 => '1.7.0_+', + 6 => '1.6.0_+' }, + 'memory_sizes' => { 'metaspace' => '64m..', + 'permgen' => '64m..' }, + 'memory_heuristics' => { 'heap' => '75', + 'metaspace' => '10', + 'permgen' => '10', + 'stack' => '5', + 'native' => '10' } } + end + before do allow(JavaBuildpack::Jre::WeightBalancingMemoryHeuristic).to receive(:new).and_return(memory_heuristic) end @@ -81,4 +95,81 @@ expect(java_opts).to include('-Djava.io.tmpdir=$TMPDIR') end + context do + + let(:configuration) { super().merge 'version' => { 'detect_compile' => 'enabled' } } + + context do + + before do + allow_any_instance_of(described_class).to receive(:java_6?).and_return(true) + end + + it 'detects with id of oracle_jre- for a java 6 app', + cache_fixture: 'stub-java.tar.gz', + app_fixture: 'jre_java6_application' do + + expect(component.detect).to eq("oracle-jre=#{version}") + end + + it 'adds memory options to java_opts for a java 6 app', + cache_fixture: 'stub-java.tar.gz', + app_fixture: 'jre_java6_application' do + + component.detect + component.release + + expect(java_opts).to include('opt-1') + expect(java_opts).to include('opt-2') + end + + end + + context do + + before do + allow_any_instance_of(described_class).to receive(:java_7?).and_return(true) + end + + it 'detects with id of oracle_jre- for a java 7 app', + cache_fixture: 'stub-java.tar.gz', + app_fixture: 'jre_java7_application' do + + expect(component.detect).to eq("oracle-jre=#{version}") + end + + end + + context do + + let(:component) { StubOracleJRE.new context } + + before do + allow_any_instance_of(StubOracleJRE).to receive(:supports?).and_return(true) + end + + it 'detects the correct version for a java 7 app', + cache_fixture: 'stub-java.tar.gz', + app_fixture: 'jre_java7_application' do + + expect(component.detect_compiled_version Pathname.new('spec/fixtures/jre_java7_application')).to eq(33) + end + + it 'detects the correct version for a java 6 app', + cache_fixture: 'stub-java.tar.gz', + app_fixture: 'jre_java6_application' do + + expect(component.detect_compiled_version Pathname.new('spec/fixtures/jre_java6_application')).to eq(32) + end + + class StubOracleJRE < JavaBuildpack::Jre::OracleJRE + + public :detect_compiled_version + + end + + end + + end + end