Bug 1237 - Clarify IOUtil.getResource(..) for better efficiency, i.e. allow caller to skip relative futile lookup
Summary: Clarify IOUtil.getResource(..) for better efficiency, i.e. allow caller to sk...
Status: RESOLVED FIXED
Alias: None
Product: Newt
Classification: JogAmp
Component: core (show other bugs)
Version: 2.3.2
Hardware: pc_all linux
: --- enhancement
Assignee: Sven Gothel
URL:
Depends on:
Blocks: 1238
  Show dependency treegraph
 
Reported: 2015-09-29 10:43 CEST by Xerxes Rånby
Modified: 2015-10-03 05:09 CEST (History)
0 users

See Also:
Type: FEATURE
SCM Refs:
gluegen d78bb1be0a6290cb94918b21865a023c01825048 gluegen 48cef027ec727d3e03b78f577208d1ce10b705d1 jogl 731c473740e3e7ccd26ecda7ea0200382795c3a6
Workaround: ---


Attachments
test_dbg.log.tar.gz (211.09 KB, application/force-download)
2015-09-29 10:43 CEST, Xerxes Rånby
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Xerxes Rånby 2015-09-29 10:43:57 CEST
Created attachment 751 [details]
test_dbg.log.tar.gz

JoglUtilPNGIcon IOUtil fails to find the jogamp-16x16.png during the first try to resolve it.
however it does find the png at the second try.
AssetURLContext.resolve: type 2: url

steps to reproduce:

wget http://jogamp.org/deployment/archive/master/gluegen_896-joal_622-jogl_1451-jocl_1094-signed/archive/jogamp-all-platforms.7z
7z x jogamp-all-platforms.7z
cd jogamp-all-platforms
sh etc/test_dbg.sh

output from the logfile:

IOUtil: locating <com/jogamp/newt/newt/data/jogamp-16x16.png>, has cl: true
AssetURLContext.resolve: <com/jogamp/newt/newt/data/jogamp-16x16.png>
ERR(0): no protocol: com/jogamp/newt/newt/data/jogamp-16x16.png
AssetURLContext.resolve: type -1: url <null>, conn <null>, connURL <null>
IOUtil: Caught Exception:
java.io.FileNotFoundException: Could not look-up: com/jogamp/newt/newt/data/jogamp-16x16.png as URL, w/ ClassLoader or as File
	at com.jogamp.common.net.AssetURLContext.resolve(AssetURLContext.java:199)
	at com.jogamp.common.util.IOUtil.getResource(IOUtil.java:552)
	at com.jogamp.common.util.IOUtil.getResource(IOUtil.java:505)
	at com.jogamp.common.util.IOUtil$ClassResources.resolve(IOUtil.java:472)
	at jogamp.newt.driver.opengl.JoglUtilPNGIcon.arrayToX11BGRAImages(JoglUtilPNGIcon.java:48)
	at jogamp.newt.driver.PNGIcon.arrayToX11BGRAImages(PNGIcon.java:76)
	at jogamp.newt.driver.x11.WindowDriver.<clinit>(WindowDriver.java:80)
	at jogamp.newt.driver.x11.DisplayDriver.initIDs0(Native Method)
	at jogamp.newt.driver.x11.DisplayDriver.<clinit>(DisplayDriver.java:55)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:264)
	at com.jogamp.newt.NewtFactory.getCustomClass(NewtFactory.java:111)
	at jogamp.newt.DisplayImpl.getDisplayClass(DisplayImpl.java:275)
	at jogamp.newt.DisplayImpl.create(DisplayImpl.java:285)
	at com.jogamp.newt.NewtFactory.createDisplay(NewtFactory.java:203)
	at com.jogamp.newt.NewtFactory.createWindowImpl(NewtFactory.java:309)
	at com.jogamp.newt.NewtFactory.createWindow(NewtFactory.java:234)
	at com.jogamp.newt.opengl.GLWindow.create(GLWindow.java:168)
	at com.jogamp.newt.opengl.GLWindow.main(GLWindow.java:1080)
IOUtil: found <newt/data/jogamp-16x16.png> within class package <com/jogamp/newt/> of given class <com.jogamp.newt.NewtFactory>: false
IOUtil: locating <newt/data/jogamp-16x16.png>, has cl: true
AssetURLContext.resolve: <newt/data/jogamp-16x16.png>
ERR(0): no protocol: newt/data/jogamp-16x16.png
AssetURLContext.resolve: type 2: url <jar:file:/home/familjen/2.3.2-27sept/jogamp-all-platforms/jar/jogl-all.jar!/newt/data/jogamp-16x16.png>, conn <sun.net.www.protocol.jar.JarURLConnection:jar:file:/home/familjen/2.3.2-27sept/jogamp-all-platforms/jar/jogl-all.jar!/newt/data/jogamp-16x16.png>, connURL <jar:file:/home/familjen/2.3.2-27sept/jogamp-all-platforms/jar/jogl-all.jar!/newt/data/jogamp-16x16.png>
IOUtil: found <newt/data/jogamp-16x16.png> by classloader: true
PNGPixelRect: ImageInfo [cols=16, rows=16, bitDepth=8, channels=4, bitspPixel=32, bytesPixel=4, bytesPerRow=64, samplesPerRow=64, samplesPerRowP=64, alpha=true, greyscale=false, indexed=false, packed=false]
PNGPixelRect: indexed false, alpha true, grayscale false, channels 4/4, bytesPerPixel 4/4, grayAlpha false, pixels 16x16, dpi 72.009x72.009, format RGBA8888
PNGPixelRect: destFormat BGRA8888 (BGRA8888, fast-path false), destDirectBuffer false, destIsGLOriented (flip) false
PNGPixelRect: destStrideInBytes 64 (destMinStrideInBytes 0)
IOUtil: locating <com/jogamp/newt/newt/data/jogamp-32x32.png>, has cl: true
AssetURLContext.resolve: <com/jogamp/newt/newt/data/jogamp-32x32.png>
ERR(0): no protocol: com/jogamp/newt/newt/data/jogamp-32x32.png
AssetURLContext.resolve: type -1: url <null>, conn <null>, connURL <null>
IOUtil: Caught Exception:
java.io.FileNotFoundException: Could not look-up: com/jogamp/newt/newt/data/jogamp-32x32.png as URL, w/ ClassLoader or as File
	at com.jogamp.common.net.AssetURLContext.resolve(AssetURLContext.java:199)
	at com.jogamp.common.util.IOUtil.getResource(IOUtil.java:552)
	at com.jogamp.common.util.IOUtil.getResource(IOUtil.java:505)
	at com.jogamp.common.util.IOUtil$ClassResources.resolve(IOUtil.java:472)
	at jogamp.newt.driver.opengl.JoglUtilPNGIcon.arrayToX11BGRAImages(JoglUtilPNGIcon.java:48)
	at jogamp.newt.driver.PNGIcon.arrayToX11BGRAImages(PNGIcon.java:76)
	at jogamp.newt.driver.x11.WindowDriver.<clinit>(WindowDriver.java:80)
	at jogamp.newt.driver.x11.DisplayDriver.initIDs0(Native Method)
	at jogamp.newt.driver.x11.DisplayDriver.<clinit>(DisplayDriver.java:55)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:264)
	at com.jogamp.newt.NewtFactory.getCustomClass(NewtFactory.java:111)
	at jogamp.newt.DisplayImpl.getDisplayClass(DisplayImpl.java:275)
	at jogamp.newt.DisplayImpl.create(DisplayImpl.java:285)
	at com.jogamp.newt.NewtFactory.createDisplay(NewtFactory.java:203)
	at com.jogamp.newt.NewtFactory.createWindowImpl(NewtFactory.java:309)
	at com.jogamp.newt.NewtFactory.createWindow(NewtFactory.java:234)
	at com.jogamp.newt.opengl.GLWindow.create(GLWindow.java:168)
	at com.jogamp.newt.opengl.GLWindow.main(GLWindow.java:1080)
IOUtil: found <newt/data/jogamp-32x32.png> within class package <com/jogamp/newt/> of given class <com.jogamp.newt.NewtFactory>: false
IOUtil: locating <newt/data/jogamp-32x32.png>, has cl: true
AssetURLContext.resolve: <newt/data/jogamp-32x32.png>
ERR(0): no protocol: newt/data/jogamp-32x32.png
AssetURLContext.resolve: type 2: url <jar:file:/home/familjen/2.3.2-27sept/jogamp-all-platforms/jar/jogl-all.jar!/newt/data/jogamp-32x32.png>, conn <sun.net.www.protocol.jar.JarURLConnection:jar:file:/home/familjen/2.3.2-27sept/jogamp-all-platforms/jar/jogl-all.jar!/newt/data/jogamp-32x32.png>, connURL <jar:file:/home/familjen/2.3.2-27sept/jogamp-all-platforms/jar/jogl-all.jar!/newt/data/jogamp-32x32.png>
IOUtil: found <newt/data/jogamp-32x32.png> by classloader: true
PNGPixelRect: ImageInfo [cols=32, rows=32, bitDepth=8, channels=4, bitspPixel=32, bytesPixel=4, bytesPerRow=128, samplesPerRow=128, samplesPerRowP=128, alpha=true, greyscale=false, indexed=false, packed=false]
PNGPixelRect: indexed false, alpha true, grayscale false, channels 4/4, bytesPerPixel 4/4, grayAlpha false, pixels 32x32, dpi 72.009x72.009, format RGBA8888
PNGPixelRect: destFormat BGRA8888 (BGRA8888, fast-path false), destDirectBuffer false, destIsGLOriented (flip) false
PNGPixelRect: destStrideInBytes 128 (destMinStrideInBytes 0)
Def. Icon: data_size 1284 * elem_size 8 = data java.nio.DirectByteBuffer[pos=0 lim=10272 cap=10272]
Comment 1 Sven Gothel 2015-10-03 04:07:25 CEST
IOUtil.getResource(..) and in this reported case IOUtil.ClassResources,
needs more clarity.
ClassLoader shall be passed explicitly next to the optional 
relative context Class instance.
This allows better efficiency, i.e. caller can pass ClassLoader
but skip a possible relative lookup, if not existing.
Comment 2 Sven Gothel 2015-10-03 04:10:44 CEST
commit d78bb1be0a6290cb94918b21865a023c01825048
  Fixed as described in comment 1
Comment 3 Sven Gothel 2015-10-03 04:29:22 CEST
gluegen 48cef027ec727d3e03b78f577208d1ce10b705d1
  Minor Cleanup: AssetURLContext and IOUtil.getResource(..) DEBUG Messages
Comment 4 Sven Gothel 2015-10-03 05:08:50 CEST
jogl 731c473740e3e7ccd26ecda7ea0200382795c3a6

  Adopt GlueGen's clarification of IOUtil.getResource(..), 
  commit d78bb1be0a6290cb94918b21865a023c01825048
    
  - Skip relative lookup for IOUtil.ClassResources using 'asset' only 
    (from JAR file)
    
  - Tested w/ jar file and build-dir, see scripts/tests.sh 'USE_BUILDDIR'