Why "okhttp" internal package source file name start with "-"? - okhttp

Lately, I found a weird file name beginning with "-" on "okhttp" source code.
Why "okhttp" internal package source file name start with "-"?

It's a convention taken from Okio https://github.com/square/okio/blob/master/okio/src/jvmMain/kotlin/okio/-JvmPlatform.kt
Effectively makes these completely inaccessible to Java code.

Related

Replacing inconvenient package name. Got error: replacement module without version must be directory path (rooted or starting with ./ or ../)

Problem
In go.mod file I wrote:
module github.com/Siiir/vector
go 1.17
require github.com/huandu/go-clone v1.3.2 // indirect
replace clone => github.com/huandu/go-clone[v1.3.2]
It says that I cannot do such a replacement.
I actually solved my problem with the name of imported package.
It is convenient & working without that dash. I found that I can use clone.something to refer to a function.
No need to type go-clone.something.
Anyway, assume that a package name is indeed crazy or inconvenient. How can I replace it?
What I've seen:
I've seen a sibling question:
go modules - replace does not work - replacement module without version must be directory path (rooted or starting with
What I tried:
Working with terminal:
go mod edit -replace=clone=github.com/huandu/go-clone
got: go: -replace=clone=github: unversioned new path must be local directory
manual editing:
Attempts like: replace clone => github.com/huandu/go-clone[v1.3.2]
got: replacement module without version must be directory path (rooted or starting with ./ or ../)
Anyway, assume that a package name is indeed crazy or inconvenient. How can I replace it?
You cannot.
And you should not. The import path is something you write just once in the import declaration and the package name can be changed on a per file level with import nicename "something.you.think/is-totally/inconvenient/and/unacceptable-to/your_taste" .

getResource return null url in context of module

I am new to Java Modularity. I am using Java 9.
The program compiles without complaint. It also runs perfectly well from the "exploded module" folder, but with one exception: it throws an exception whose cause originates with the following line of code:
URL introURL = AboutPanel.class.getResource("help.html");
introURL is being assigned null.
When running the program in Eclipse, or from a jar file exported from Eclipse, the URL is populated correctly with the address of a resource file (help.html) that is in the same directory as the calling class.
Here is the command I use to run the program from the "exploded module" that is in the "out" folder:
java -p out/ -m moduleTCD/com.adonax.tanpura.TCDLaunch
The project consists of two packages that I am bundling together in a single module.
src/moduleTCD/com/adonax/tanpura
/pfaudio
The "main" class (entry point) is tanpura.TCDLaunch.
Here is the module-info.java class contents:
module moduleTCD {
exports com.adonax.tanpura;
requires java.base;
requires java.desktop;
}
The error statement, when trying to run from the command line:
java.io.IOException: invalid url
at java.desktop/javax.swing.JEditorPane.setPage(Unknown Source)
at moduleTCD/com.adonax.tanpura.documentation.AboutPanel.<init>(AboutPanel.java:28)
at moduleTCD/com.adonax.tanpura.panels.ControlPanel.initializeHelpPanel(ControlPanel.java:525)
at moduleTCD/com.adonax.tanpura.panels.ControlPanel.<init>(ControlPanel.java:163)
at moduleTCD/com.adonax.tanpura.TCDLaunch.main(TCDLaunch.java:43)
This exception is thrown in a try/catch for IOException at the point where the JEditorPane method setPage is called with null as an argument.
textArea.setPage(introURL);
At first, I didn't have an exports line in my module-info.java, but added it when I read the following from the API for Class.getResource:
Returns:
A URL object; null if no resource with this name is found, the resource cannot be located by a URL, the resource is in a package that
is not open to at least the caller module, or access to the resource
is denied by the security manager.
This raised the possibility that the package might be needed by Class in the module Java.base. The exports command there now is the broadest possible. But adding it did not change the error. I'm wondering if there is something wrong with how I did this, or if there is something else I am overlooking.
Classic error on my part. I made assumptions about the error being related to tech that is new and unfamiliar to me, rather than first verifying the obvious.
The fail was due to not realizing that the javac command did not move required resources into the target folder system.
I also verified that an "exports" statement is NOT needed in module-info in order to allow the loading of the resource.
So, in fact, this was not a java-module issue at all, just an oversight which I credit in part to a lack of chops using shell-level Java commands.
Big thank you to Alan Bateman!

Front end and back end not compatible - get more linker information

while building a project in VisualStudio 2012 I get the error message
LINK : fatal error C1905: Front end and back end not compatible (must target same processor).
Checking the project manually does not help, all involved (static) libraries have been built for the same processor. I also added
/VERBOSE:lib and /VERBOSE
to command line to get some more information but this does not help, only additional output line I got by this was a stupid
Starting pass 1
So: any ideas how I can find out what causes this strange error message? How can I get more output from the linker?
Thanks!
Old question and I'm not sure whether anyone still need an answer. I had this problem with Visual Studio 2017.
Check paths for generated .obj files, especially when you use some .cpp files in more than one project (within solution) and/or use %(RelativeDir) variable in Properties -> C/C++ -> Output Files -> Object File Name. It happened to me with this path in Object File Name '$(IntDir)\%(RelativeDir)' and this $(ProjectDir)Junk\$(Platform)\ in Intermediate Directory. Error gone when I moved $(Platform) part to Object File Name.
Old paths:
Intermediate Directory: $(ProjectDir)Junk\$(Platform)\.
Object File Name: $(IntDir)\%(RelativeDir).
New paths:
Intermediate Directory: $(ProjectDir)Junk\.
Object File Name: $(IntDir)$(Platform)\%(RelativeDir).
You can also specify Object File Name option for each file, shared between multiple projects to keep using old path (or if new paths configuration isn't working for you) and get rid of that error.

Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lex failed with exit code 1

I am trying to include a file in my resource bundle the files contains the following:
LeadPunc="({[`'
TrailPunc=}:;-]!?`,.)"'
NumLeadPunc=#({[#$
NumTrailPunc=}):;].,%
Operators=*+-/.:,()[]
Digits=0123456789
Alphas=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
*extra line*
The files is called:
eng.cube.lm
The error I get is:
IExpenseReporter/tessdata/eng.cube.lm:6: premature EOF
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lex failed with exit code 1
This file goes along with the newest version of tesseract (OCR). Does anyone have an idea what is causing this error and how to fix it?
Make sure you select the "Create folder references" option when adding the tessdata folder to your project.
From the documentation:
NOTE: This library currently requires the tessdata folder to be linked
as a referenced folder instead of a symbolic group. If Tesseract can't
find a language file in your own project, it's probably because you
created the tessdata folder as a symbolic group instead of a
referenced folder. It should look like this if you did it correctly:
Note how the tessdata folder has a blue icon, indicating it was
imported as a referenced folder instead of a symbolic group.
Trashing the current folder and adding it again as a folder reference should solve the problem.
XCode "thinks" this is a lex file and try to process it by calling lex. However, lex finds and unbalanced quote and thus a premature end of file.
You should try to call the designated tool explicitly.
I had this issue and I found that copying the folder "tessdata" from the language zip into the project directory rather then into Xcode fixed the issue.

WiX can'f find my file : unable to load file, error LGHT0103

I am using WiX 3.5 and making an installer. I have used heat.exe to bundle all the files.
It produced a WiX file. I referred in main wxs files as componentgroup ref. When I build my installer, it throws the following exception.
light.exe : error LGHT0103 : The system cannot find the file
'..........\target\tmp-release\jboss-eap-5.0\jboss-as\server\all\deploy\httpha-invoker.sar\invoker.war\WEB-INF\classes\org\jboss\invocation\http\servlet\ReadOnlyAccessFilter.class'
with type ''.
It is able load many files from this location, except the above file, even though the file is present.
Looks like you've hit the linker bug. As far as I can see, it was already reported to the WiX team, and was scheduled for v4.0. The comment to the issue states the path is more than 255 characters, so a possible workaround for you is to re-work the files/folders layout to avoid the paths of that length.
Hope this helps.
The answer of Ravz1234 works ! I used it with a environment variable e.g. env.SourcePath.
1) Set an environment variable to show on your Source Dir e.g. C:\SourceDir
2) On heat.exe add the argument -var env.SourcePath along with the other arguments
I used the variable for the directory, sys.SOURCEFILEDIR, and it worked well.

Resources